Make reasoning-channel emission model-capability-aware (#254)#255
Merged
Conversation
commit: |
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
force-pushed
the
blitz/aimock-254-reasoning/integration
branch
from
June 8, 2026 22:14
4d352ab to
174c243
Compare
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
Fixes #254. aimock synthesized a reasoning channel (chat-completions
reasoning_content/ Responsesreasoning_summary_text/ Anthropicthinking/ etc.) from a fixture'sreasoningfield 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-opentrue.AIMOCK_REASONING_MODELS/AIMOCK_NONREASONING_MODELSenv 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.effectiveStrictcomputed fresh per site; WS resolves strict fromupgradeHeaders).Test plan
isReasoningModel(families, date-suffix + Bedrock-prefix normalization, env-override precedence incl. provider-prefixed entries, fail-open) andresolveReasoningForModel(4-way matrix).gpt-4.1repro on/v1/chat/completionsand Anthropic content+toolCalls.tsc --noEmit+ build all clean.Follow-ups (out of scope for this PR)
/api/chatcontent+toolCalls path does not emit reasoning at all (pre-existing — those builders never accepted areasoningparam); capability gating is moot there until emission is added.gemini.ts:523) is not gated (spec §6 deferred audio fixtures).warnwhile HTTP handlers logerror(pre-existing strict-logging consistency).