Fix inconsistent JSON schema for explanation field in prompt template#29
Merged
kriserickson merged 2 commits intoadd-explainfrom Mar 1, 2026
Merged
Fix inconsistent JSON schema for explanation field in prompt template#29kriserickson merged 2 commits intoadd-explainfrom
explanation field in prompt template#29kriserickson merged 2 commits intoadd-explainfrom
Conversation
…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 Mar 1, 2026
explanation field in prompt template
kriserickson
approved these changes
Mar 1, 2026
Contributor
There was a problem hiding this comment.
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
promptTemplateto include an optionalexplanationfield. - Added an explicit rule stating
explanationis optional unless explicitly requested. - Extended the prompt test to assert
explanationis 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
promptTemplateJSON schema example omitted the"explanation"field, whileexplainInstruction(injected when--explainis 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 requestedinternal/llm/prompt_test.go: ExtendedTestBuildSystemPrompt_ContainsJSONInstructionsto 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.