feat(responses): deliver structured output to routed openai-chat models - #985
feat(responses): deliver structured output to routed openai-chat models#985DevMello wants to merge 3 commits into
Conversation
📝 WalkthroughWalkthroughStructured output support now preserves Responses ChangesStructured output handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant ResponsesAPI
participant ResponsesParser
participant OpenAIChatAdapter
participant UpstreamChatCompletions
ResponsesAPI->>ResponsesParser: Parse text.format
ResponsesParser->>OpenAIChatAdapter: Pass options.textFormat
OpenAIChatAdapter->>UpstreamChatCompletions: Send response_format
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/server/responses/core.ts`:
- Around line 1667-1669: Clear parsed._structuredOutput in the routed compaction
normalization block alongside the existing parsed.options.textFormat removal,
ensuring the synthetic compaction request is sent as plain prose to the Kiro
adapter. Add a regression test covering Kiro-routed compaction with text.format
and verify it succeeds with a prose summary.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 3e283b5a-c413-40ee-bb21-25f779684ab0
📒 Files selected for processing (11)
docs/github-copilot-app.mdsrc/adapters/openai-chat.tssrc/responses/parser.tssrc/server/chat-completions.tssrc/server/responses/core.tssrc/types.tstests/chat-completions-endpoint.test.tstests/kiro-adapter.test.tstests/openai-chat-hardening.test.tstests/responses-compaction-routing.test.tstests/responses-parser.test.ts
💤 Files with no reviewable changes (1)
- src/server/chat-completions.ts
| // The compaction turn is a plain prose summary; a surviving structured-output format | ||
| // would force schema-constrained JSON into the synthetic compaction item. | ||
| delete parsed.options.textFormat; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Clear _structuredOutput for routed compaction.
Line 1669 removes options.textFormat, but _structuredOutput remains true. A Kiro-routed compaction request with text.format still reaches the Kiro adapter as structured output. The Kiro adapter rejects that flag, so compaction fails instead of returning the required prose summary.
Delete parsed._structuredOutput in this block. Add a Kiro routed-compaction regression test.
Proposed fix
delete parsed.options.parallelToolCalls;
delete parsed.options.textFormat;
+ delete parsed._structuredOutput;
parsed.context.messages.push({ role: "user", content: COMPACT_PROMPT, timestamp: Date.now() });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/server/responses/core.ts` around lines 1667 - 1669, Clear
parsed._structuredOutput in the routed compaction normalization block alongside
the existing parsed.options.textFormat removal, ensuring the synthetic
compaction request is sent as plain prose to the Kiro adapter. Add a regression
test covering Kiro-routed compaction with text.format and verify it succeeds
with a prose summary.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: db284da38a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| delete parsed.options.parallelToolCalls; | ||
| // The compaction turn is a plain prose summary; a surviving structured-output format | ||
| // would force schema-constrained JSON into the synthetic compaction item. | ||
| delete parsed.options.textFormat; |
There was a problem hiding this comment.
Strip text.format from raw compaction bodies
When routed compaction is sent to a noncanonical openai-responses provider, deleting only parsed.options.textFormat does not change the payload: that adapter's buildRequest starts from parsed._rawBody and buildRoutedCompactionBody only removes tools/tool_choice/parallel. With --output-schema/text.format, the compaction summarizer still receives text.format and can be forced to emit schema JSON instead of the prose summary that the synthetic compaction item needs. Strip text from the raw compaction body as well.
Useful? React with 👍 / 👎.
| tool calls, prompt cache keys, metadata, and `response_format` on native Responses | ||
| routes. Routed `openai-chat` models reject `response_format` with HTTP 400 because | ||
| their structured-output support is not verified. Other Chat Completions fields, | ||
| including penalties, `n`, and logprobs, are not currently supported. | ||
| routes and routed `openai-chat` models (`json_object` and `json_schema` are | ||
| forwarded as-is; a backend without structured-output support returns its own |
There was a problem hiding this comment.
Update the public docs site for response_format
Because this change exposes response_format support to OpenAI-compatible clients, updating only docs/github-copilot-app.md leaves the hosted docs-site reference/guides without the new behavior; users reading the public docs still have no indication that routed openai-chat can accept structured output. Add the corresponding docs-site/ update, including locales if relevant, alongside this docs change.
AGENTS.md reference: AGENTS.md:L224-L225
Useful? React with 👍 / 👎.
Summary
text.formatwas reduced to a boolean and discarded, so structured output (Codex--output-schema) silently never reached routed models, and the chat surface returned HTTP 400 forresponse_formaton routed openai-chat models.response_format, the exact inverse of the existing inbound mapping. The 400 guard is removed, routed compaction strips the format so summaries stay prose, and the native Responses passthrough is untouched.Verification
bun run typecheck && bun run lint:gui && bun run test && bun run privacy:scanChecklist
Summary by CodeRabbit
New Features
Bug Fixes