Repository navigation
fix: preserve reasoning_details with Bedrock/Meta and unknown formats - #593
Open
LukasParke wants to merge 2 commits into
Open
LukasParke wants to merge 2 commits into
LukasParke wants to merge 2 commits into
Conversation
The ReasoningFormat enum was missing bedrock-openai-responses-v1, bedrock-xai-responses-v1 and meta-responses-v1, so details carrying those formats failed schema validation and were silently dropped. Add them, and accept any string for `format` so formats added server-side in the future are passed through verbatim instead of dropped. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This was referenced Oct 22, 2026
Distinct signed reasoning blocks have distinct signatures. The fixture reused one signature for both, which collapses them once the duplicate tracker keys signed text by signature (#610). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Description
Bug:
ReasoningFormat(src/schemas/format.ts) was missing three formats that OpenRouter emits and documents (projects/docs/guides/best-practices/reasoning-tokens.mdx, andpackages/llm-interfaces/schemas/response/reasoning-schemas/format.tsin the backend):bedrock-openai-responses-v1(OpenAI-authored models on Bedrock Mantle)bedrock-xai-responses-v1(xAI-authored models on Bedrock Mantle)meta-responses-v1(Meta Responses adapter)Because
formatwas validated withz.enum(ReasoningFormat), any detail with one of these formats failed the union and was turned intonullby the unknown-entry fallback inReasoningDetailArraySchema/OutputUnionToReasoningDetailsSchema. The detail was silently dropped from the response metadata, so it was never replayed on the next turn, and reasoning continuity broke for those providers.Repro: parse
{ type: 'reasoning.encrypted', data: '...', format: 'bedrock-openai-responses-v1' }withReasoningDetailArraySchemaand you get[].Fix:
format(z.union([z.enum(ReasoningFormat), z.string()])). A format the backend adds after an SDK release is now passed through verbatim instead of dropped. The server minted the format, so it can validate it when it comes back. Unknown detail types are still dropped individually, as before.Test: new
src/schemas/reasoning-details.test.ts. For each new format plus an unrecognisedsome-future-provider-v1, it checks that summary, encrypted and text details surviveReasoningDetailArraySchema, the response message and delta schemas, andOpenRouterProviderOptionsSchema, and that they round-trip throughconvertToOpenRouterChatMessages. I also tightened the existing unknown-format resilience test insignature-roundtrip.test.tsto assert that the entry is preserved. I ran the new test file againstorigin/mainsource: all 16 cases fail there and pass with this fix.Related: a follow-up opt-in
reasoningReplayoption (#542) builds a format-to-family map. It will use these enum members once this PR is merged.Checklist
pnpm stylecheckandpnpm typecheckpnpm testand all tests passChangeset
pnpm changesetto create a changeset file🤖 Generated with Claude Code