Repository navigation
Use structured output for Copilot responses - #23170
Merged
Merged
Conversation
Use separate string-enum and null branches for conflict actions to avoid Claude schema rejection. Restrict enums to scalar strings and add regression coverage for all valid actions. Document the compatibility issue and unverified hosted inference.
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Conflict-resolution changes can replace file contents and warrant deeper human review of SDK event ordering and teardown, while hosted-provider enforcement and validation with committed dependencies remain unverified.
No open issues 🎉
What changed in this PR
This PR addresses malformed Copilot JSON responses reported in #22958 by adding schema-backed output to GitHub Desktop’s commit-message generation, assisted commit planning, and conflict resolution.
Changes:
- Supplies feature-specific response schemas on every request, including existing fallback and retry paths, while preserving application-level validation.
- Updates event-driven completion handling to select the final matching root response and reject failed or aborted runs.
- Adds schema, lifecycle, and local SDK integration coverage, plus documentation of provider compatibility and verification limits.
| File | Description |
|---|---|
| docs/technical/copilot-structured-output.md | Documents schemas, completion handling, and provider limitations. |
| docs/technical/assisted-commit-planning.md | Explains the structured response envelope. |
| app/test/unit/stores/copilot-store-test.ts | Tests schema forwarding, conflict retries, and cleanup. |
| app/test/unit/stores/copilot-assisted-commit-test.ts | Verifies schemas accompany assisted planning requests. |
| app/test/unit/stores/assisted-commit-run-test.ts | Updates planning fixtures and asserts schema usage. |
| app/test/unit/copilot-response-schema-test.ts | Tests schema contracts and preserved semantic validation. |
| app/test/unit/copilot-operation-test.ts | Tests response correlation, completion ordering, and cancellation. |
| app/test/unit/copilot-assisted-commit-sdk-test.ts | Exercises native schema forwarding through local synthetic providers. |
| app/test/helpers/copilot-assisted-commit.ts | Updates mock responses and correlated lifecycle events. |
| app/src/lib/stores/copilot-store.ts | Integrates schemas and shared conflict-response waiting. |
| app/src/lib/copilot-operation.ts | Defines schema types and correlated final-response handling. |
| app/src/lib/copilot-conflict-resolution.ts | Adds the conflict schema and nullable-action prompt guidance. |
| app/src/lib/copilot-commit-message.ts | Defines the commit-message response schema. |
| app/src/lib/copilot-assisted-commit.ts | Adds the assisted schema, envelope parser, and matching prompts. |
Review effort: Balanced
Review feedback: F2 from the adversarial review of #23170. The existing parser searched for Markdown fences before parsing the complete response. A schema-valid JSON description containing a fenced example caused it to parse escaped inner string content and reject a valid commit message. This defect predates the structured-output changes. Remove legacy fence extraction and parse the complete response directly. Markdown-wrapped responses are now rejected without a fallback, as requested. Keep object, title and description validation and omitted-body normalization unchanged. Add regression cases for JSON, shell and plain fences inside descriptions and for rejecting outer Markdown wrappers. Document the bare-JSON-only contract. Both regression tests failed before the fix and passed afterward. Validation: - npm test -- app/test/unit/copilot-commit-message-test.ts app/test/unit/copilot-response-schema-test.ts app/test/unit/stores/copilot-store-test.ts app/test/unit/copilot-assisted-commit-sdk-test.ts: 79 passed. - npm test: 3428 passed, 2 skipped, using a process-local safe.bareRepository=all override for the existing synthetic bare fixtures. - npm run lint:fix and npm run lint: passed. - node_modules/.bin/tsc --noEmit -p tsconfig.json: passed. - npm run build:dev: passed. - Markdown lint for the updated technical document and git diff --check: passed. Validation used the existing local dugite 3.3.2 pin. Those unrelated manifest and lockfile edits are intentionally excluded from this commit.
tidy-dev
approved these changes
Nov 11, 2026
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.
Closes #22958
Description
Copilot models can return malformed JSON or wrap otherwise valid JSON in Markdown, causing errors such as "Copilot returned invalid JSON for commit message generation." This requests schema-backed responses instead of relying on prompt instructions alone.
responseSchemafor assisted commit planning, ordinary commit-message generation, and conflict resolution, including existing fallback turns and every conflict chunk/retry.Structured-output support still depends on the model and endpoint. Unsupported routes remain explicit failures. Local integration tests do not establish hosted-model enforcement; successful hosted Claude Haiku inference after the nullable-action fix remains unverified.
Validation
Validation covers the source now committed as
0b9efe19d84245d3d628afd946eb4effea0f9996.npm test -- app/test/unit/copilot-response-schema-test.ts app/test/unit/copilot-assisted-commit-sdk-test.ts app/test/unit/copilot-conflict-resolution-test.ts app/test/unit/stores/copilot-store-test.tsnpm run lint:fixnpm run lintnode_modules/.bin/tsc --noEmit -p tsconfig.jsonnpm run build:devnode_modules/.bin/markdownlint docs/technical/copilot-structured-output.md --config .markdownlint.js --rules .markdownlint-rules.jsgit diff --checkFull unit/UI suite:
Passed: 3,426 tests, 2 skipped. The process-local Git override allows the suite's synthetic bare repositories; no Git configuration files were changed.
The shipped SDK/runtime was exercised with a local synthetic provider on OpenAI Chat Completions, OpenAI Responses, and native Anthropic Messages. Coverage includes actual native schema forwarding, stop-hook corrections, intermediate/unrelated/child responses, failed and aborted runs, validation retries, cancellation, deadlines, and cleanup.
Screenshots
Not applicable: no UI changes. Automated request/lifecycle tests provide the relevant evidence.
Team-authored review
Evidence: See Validation.
Review path:
needs-deep-review. Review response-origin correlation, completion/error races, and teardown incopilot-operation.tsandrunConflictResolutionTurn. These responses feed conflict resolutions that can replace file contents, so accepting an incorrect or superseded response risks losing changes. Existing validation and apply paths remain unchanged.Release notes
Notes: [Fixed] Reduce response-format failures when generating commit messages and resolving conflicts with Copilot - #22958