Skip to content

Make reasoning-channel emission model-capability-aware (#254)#255

Merged
jpr5 merged 4 commits into
mainfrom
blitz/aimock-254-reasoning/integration
Jun 8, 2026
Merged

Make reasoning-channel emission model-capability-aware (#254)#255
jpr5 merged 4 commits into
mainfrom
blitz/aimock-254-reasoning/integration

Conversation

@jpr5

@jpr5 jpr5 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #254. aimock synthesized a reasoning channel (chat-completions reasoning_content / Responses reasoning_summary_text / Anthropic thinking / etc.) from a fixture's reasoning field regardless of the requested model — so a backend wired to a non-reasoning model (e.g. gpt-4.1) still "emitted" reasoning under replay, a false green (this masked a real llamaindex showcase mis-wire).

This makes reasoning emission model-capability-aware, gated through the existing strict-mode toggle.

What changed

  • isReasoningModel(model) (model-utils.ts): classifies whether a model id would emit reasoning against the real provider. Conservative non-reasoning denylist (gpt-4.1/gpt-4o/gpt-3.5/gemini-1.5/claude-3-5…), reasoning families (o-series, gpt-5, deepseek-r1, Claude 4 thinking…), unknown → fail-open true. AIMOCK_REASONING_MODELS / AIMOCK_NONREASONING_MODELS env overrides (normalized identically to incoming ids — date-suffix + provider-prefix stripped).
  • resolveReasoningForModel(reasoning, model, strict, logger) (helpers.ts): no reasoning → no-op; capable → emit unchanged; non-capable + strict OFF → warn + emit (preserves current behavior); non-capable + strict ON → suppress.
  • Gating wired at every provider dispatch point: OpenAI chat + Responses, Anthropic Messages, Ollama, Gemini, Cohere, Bedrock invoke + Converse, WebSocket Responses (effectiveStrict computed fresh per site; WS resolves strict from upgradeHeaders).

Test plan

  • Unit: isReasoningModel (families, date-suffix + Bedrock-prefix normalization, env-override precedence incl. provider-prefixed entries, fail-open) and resolveReasoningForModel (4-way matrix).
  • Per-provider integration: suppress-under-strict / warn-and-emit / capable-emit / no-op, stream + non-stream — including the canonical gpt-4.1 repro on /v1/chat/completions and Anthropic content+toolCalls.
  • Full suite: 3444 passed / 37 skipped; prettier + eslint + tsc --noEmit + build all clean.

Follow-ups (out of scope for this PR)

  • Ollama /api/chat content+toolCalls path does not emit reasoning at all (pre-existing — those builders never accepted a reasoning param); capability gating is moot there until emission is added.
  • Gemini audio companion reasoning (gemini.ts:523) is not gated (spec §6 deferred audio fixtures).
  • WS strict-no-fixture logs at warn while HTTP handlers log error (pre-existing strict-logging consistency).

@pkg-pr-new

pkg-pr-new Bot commented Jun 8, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 44b08a5

jpr5 added 3 commits June 8, 2026 15:13
Add isReasoningModel (model-utils.ts) to classify whether a model id would emit a
reasoning channel against the real provider, and resolveReasoningForModel (helpers.ts)
to gate a fixture's reasoning value on that classification: suppress under strict mode,
warn-and-emit otherwise. Conservative non-reasoning denylist with fail-open default for
unknown ids; AIMOCK_REASONING_MODELS / AIMOCK_NONREASONING_MODELS env overrides,
normalized identically to incoming model ids (date-suffix + provider-prefix stripped).
Route synthesized reasoning through resolveReasoningForModel at every provider dispatch
point (OpenAI chat + Responses, Anthropic Messages, Ollama, Gemini, Cohere, Bedrock
invoke + Converse, WebSocket Responses), computing effectiveStrict fresh at each site.
The WS path resolves strict from upgradeHeaders. Stops aimock replaying a reasoning
channel for models the real provider would not emit it for.
Unit tests for isReasoningModel (incl. provider-prefixed env overrides) and
resolveReasoningForModel, plus per-provider integration tests asserting
suppress-under-strict / warn-and-emit / capable-emit / no-op. Align existing
cross-provider reasoning tests to reasoning-capable model ids.
@jpr5
jpr5 force-pushed the blitz/aimock-254-reasoning/integration branch from 4d352ab to 174c243 Compare June 8, 2026 22:14
@jpr5
jpr5 merged commit 546bad9 into main Jun 8, 2026
23 checks passed
@jpr5
jpr5 deleted the blitz/aimock-254-reasoning/integration branch June 8, 2026 23:34
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.

Make reasoning-channel emission model-capability-aware

1 participant