fix(translation): preserve final answers in buffered Responses - #284
Merged
Conversation
Signed-off-by: nachiketb <nachiketb@nvidia.com>
Walkthrough
ChangesResponses output handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
grahamking
approved these changes
Aug 4, 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.
What
Normalize buffered OpenAI Responses output items into one semantic assistant output.
Why
first_output()means the first semanticResponseOutput, not the first content block or modality. OneResponseOutputcan contain ordered reasoning, text, tool calls, images, and other normalized content blocks. Chat, Anthropic, and accumulated streams already represent one completed assistant response this way.The Responses wire format can instead split one logical completion across multiple top-level
output[]items, such as a reasoning item followed by a message containing the visible final answer. The buffered decoder incorrectly mapped each wire item to a separateResponseOutput. Anthropic and Chat then encoded the first semantic output, preserving its reasoning but never reaching the separately stored final message. Requests therefore returned HTTP 200 while silently dropping the visible answer.This change normalizes the supported Responses output item types: reasoning, message, and function call. It does not broaden multimodal output support; audio, video, and unknown top-level Responses output items remain separate translation coverage gaps.
This fixes SWITCH-1187.
How
ResponseOutput.What to review
Live validation
Built the release server from this branch and ran the issue reproducer with live credentials:
reasoning,message, exact final-answer marker present.thinking,text, exact final-answer marker present.One earlier Anthropic-format generation returned reasoning only. Since each call is a separate stochastic generation, it did not establish translation loss; every retry that produced final text preserved it.
Validation
cargo fmt --all --checkcargo test -p switchyard-translationcargo clippy -p switchyard-translation --all-targets -- -D warnings