Skip to content

Fix inconsistent JSON schema for explanation field in prompt template#29

Merged
kriserickson merged 2 commits intoadd-explainfrom
copilot/sub-pr-27
Mar 1, 2026
Merged

Fix inconsistent JSON schema for explanation field in prompt template#29
kriserickson merged 2 commits intoadd-explainfrom
copilot/sub-pr-27

Conversation

Copy link
Contributor

Copilot AI commented Mar 1, 2026

The promptTemplate JSON schema example omitted the "explanation" field, while explainInstruction (injected when --explain is active) required it. This gave the model conflicting instructions about the expected output shape.

Changes

  • internal/llm/prompt.go: Added "explanation" as an optional field in the command object schema example; added a rule explicitly stating it is only required when requested
  • internal/llm/prompt_test.go: Extended TestBuildSystemPrompt_ContainsJSONInstructions to assert "explanation" is present in the base schema
{
  "command": "the shell command to run",
  "description": "brief explanation of what it does",
  "risk": "safe or risky",
  "certainty": 90,
  "explanation": "(optional) step-by-step breakdown of the command's flags and arguments"
}

The rule list now includes: "explanation" is optional and only required when explicitly requested.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…pt template

Co-authored-by: kriserickson <325934+kriserickson@users.noreply.github.com>
Copilot AI changed the title [WIP] Update explain flag and command explanations based on feedback Fix inconsistent JSON schema for explanation field in prompt template Mar 1, 2026
@kriserickson kriserickson marked this pull request as ready for review March 1, 2026 20:29
Copilot AI review requested due to automatic review settings March 1, 2026 20:29
@kriserickson kriserickson merged commit 4568baa into add-explain Mar 1, 2026
@kriserickson kriserickson deleted the copilot/sub-pr-27 branch March 1, 2026 20:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR resolves a mismatch in the LLM system prompt instructions by ensuring the shell command JSON example includes the explanation field (marked optional) while explicitly stating it’s only required when --explain is active, aligning the base schema example with the injected explainInstruction.

Changes:

  • Updated the command JSON example in promptTemplate to include an optional explanation field.
  • Added an explicit rule stating explanation is optional unless explicitly requested.
  • Extended the prompt test to assert explanation is present in the base JSON instructions.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
internal/llm/prompt.go Updates the system prompt’s command JSON example and rules to include/clarify explanation.
internal/llm/prompt_test.go Ensures tests assert explanation is present in the base prompt JSON instructions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants