Skip to content

Gate reasoning emission on the tool-call-only path across providers#257

Merged
jpr5 merged 3 commits into
mainfrom
blitz/toolonly-reasoning/integration
Jun 9, 2026
Merged

Gate reasoning emission on the tool-call-only path across providers#257
jpr5 merged 3 commits into
mainfrom
blitz/toolonly-reasoning/integration

Conversation

@jpr5

@jpr5 jpr5 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

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 reasoning now 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:

  • OpenAI chat (helpers.ts + server.ts) and Responses API (responses.ts, output-index shifted for the leading reasoning item)
  • Cohere (reasoning as leading text block, separate content/tool-call index namespaces)
  • Bedrock invoke + Bedrock Converse (leading reasoning block shifts streaming block indices by one)
  • Ollama (/api/chat content+tool builders, which previously dropped reasoning, + tool-only)
  • WebSocket Responses (gated via defaults.upgradeHeaders, matching the HTTP path)
  • Gemini chat tool-only (new emission) and the Gemini audio companion (now capability-gated, previously ungated)

Test plan

  • Per-provider stream + non-stream tests for the four-state gate (capable emits / non-reasoning strict-OFF warns+emits / strict-ON suppresses / no-reasoning no-op), plus streaming block-index ordering assertions for the leading reasoning block.
  • pnpm test 3573 passed; pnpm test:drift 80 passed; prettier + eslint + tsc --noEmit + build all clean.

Follow-ups (out of scope)

  • PR2 (next): recorder (stream-collapse.ts) capture of Anthropic signature_delta + redacted_thinking, Bedrock-Converse reasoningContent, and Cohere reasoning — so recorded real-provider reasoning round-trips.
  • Pre-existing nits: Responses API zero-token usage; WS strict-no-fixture logs warn vs HTTP error; em-dash inconsistency in two pre-existing Ollama webSearches warnings.

jpr5 added 3 commits June 9, 2026 10:22
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.
@pkg-pr-new

pkg-pr-new Bot commented Jun 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@copilotkit/aimock@257

commit: 984c990

@jpr5 jpr5 merged commit 8e2b994 into main Jun 9, 2026
25 checks passed
@jpr5 jpr5 deleted the blitz/toolonly-reasoning/integration branch June 9, 2026 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant