Gate reasoning emission on the tool-call-only path across providers#257
Merged
Conversation
Extend the model-capability reasoning gate (resolveReasoningForModel) to the tool-call-only response path of every provider — OpenAI chat + Responses, Cohere, Bedrock (invoke + Converse), Ollama (incl. content+tool), and WebSocket Responses — plus the Gemini chat tool-only path and the Gemini audio companion. A tool-only fixture carrying reasoning now emits the provider-native reasoning channel for reasoning-capable models and is suppressed under strict mode / warns otherwise, matching the text and content+tool paths. Leading reasoning blocks shift streaming tool/output indices by one where applicable.
Per-provider stream + non-stream tests for the tool-only reasoning gate (capable emits / non-reasoning strict-OFF warns+emits / strict-ON suppresses / no-reasoning no-op), including streaming block-index ordering assertions for the leading reasoning block.
commit: |
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.
Summary
Follow-up to #255 (model-capability-aware reasoning gating) and #256 (extended-thinking invariants). The capability gate previously covered only the text and content+tool response paths; the tool-call-only path silently dropped reasoning for every provider (except Claude, fixed in #256), and the Gemini audio companion reasoning was emitted ungated.
This closes the systemic gap surfaced by a reasoning-pattern recon: a tool-only fixture carrying
reasoningnow emits the provider-native reasoning channel for reasoning-capable models, suppressed under strict mode (warn-and-emit otherwise), consistent with the text and content+tool paths.What changed
Threaded + capability-gated reasoning (
resolveReasoningForModel) on the tool-call-only path of every provider:helpers.ts+server.ts) and Responses API (responses.ts, output-index shifted for the leading reasoning item)/api/chatcontent+tool builders, which previously dropped reasoning, + tool-only)defaults.upgradeHeaders, matching the HTTP path)Test plan
pnpm test3573 passed;pnpm test:drift80 passed; prettier + eslint +tsc --noEmit+ build all clean.Follow-ups (out of scope)
stream-collapse.ts) capture of Anthropicsignature_delta+redacted_thinking, Bedrock-ConversereasoningContent, and Cohere reasoning — so recorded real-provider reasoning round-trips.warnvs HTTPerror; em-dash inconsistency in two pre-existing Ollama webSearches warnings.