feat(virtualmodels): disable_reasoning flag for redirects (Kimi Code K2.6 via virtual models) - #31
Draft
weselben wants to merge 1 commit into
Draft
feat(virtualmodels): disable_reasoning flag for redirects (Kimi Code K2.6 via virtual models)#31weselben wants to merge 1 commit into
weselben wants to merge 1 commit into
Conversation
Lets a redirect strip reasoning controls from the forwarded request and force the provider's thinking toggle off (thinking.type=disabled), so the request is served by the non-thinking variant of the target model — e.g. Kimi Code's K2.6 behind kimi-for-coding. Generic across providers; unknown extra fields are forwarded (Postel's law) so providers without a thinking toggle are unaffected. Round-trips through config.VirtualModelConfig, SQL store (new disable_reasoning column + migration), Mongo store, View, and admin API. resolveRedirectRequestSelector / resolveRedirectRoutableSelector now return the matched redirect source so rewriteChatRequest can consult the flag; batch_preparer updated for the new signature. Refs #27
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This was referenced Aug 26, 2026
Repository owner
locked and limited conversation to collaborators
Aug 26, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Prototype C of 4 for #27 — a virtual-models based approach. Compare: prototype A (provider-level static map +
KIMICODE_MODEL_MAP=offtoggle, PR #30), prototype B (provider-level map, always-on, PR #29), prototype D (alternative architecture).Approach
A new
disable_reasoningflag on virtual model redirects lets an operator make any redirect serve the non-thinking variant of its target:When a request hits a flagged redirect,
rewriteChatRequeststrips the typedReasoningfield and the flatreasoning_effortextra, then setsthinking.type=disabledon the forwarded copy — so Kimi Code routes the request to the K2.6 behavior of the samekimi-for-codingendpoint. Providers without a thinking toggle ignore the unknown extra (Postel's law).What's wired
config.VirtualModelConfig.DisableReasoning bool(yaml + json)virtualmodels.VirtualModel.DisableReasoning bool+View.DisableReasoning boolvirtualmodels.Service.DisableReasoningForSource(source string) bool(lookup by source)virtualmodels.Service.ResolveRedirectForUserPath(returns fullResolutionso request rewrites can consult the matched redirect's flags)rewriteChatRequestapplies the flag; signature of the two internal resolve helpers now returns the matched source too (batch preparer updated for the new signature)disable_reasoningboolean column with a backfill migration (mirrors theslowdownpattern)Viewcarries the flagTrade-offs vs A/B
kimi-k2.6→ thinking off)disable_reasoning: trueredirect tokimicode/kimi-for-coding)Caveat: usage recording
Today
internal/gateway/usage.gorecords the resolved target model (kimicode/kimi-for-coding), not the requested virtual-model source. For the K2.6 case this means usage rows will showkimi-for-codingrather thankimi-k2.6, which is misleading. A small follow-up — adding a precedence slot for the original request model when a virtual-model alias rewrote it — would close this gap. The PR documents the divergence; fixing it is out of scope here so this stays a minimal, reviewable diff.Tests
go build ./...— passgo test ./internal/virtualmodels/... ./config/...— pass (4 new unit tests + carried-over suite):TestRewriteChatRequest_DisableReasoningStripsControls— flag strips Reasoning + reasoning_effort, sets thinking.type=disabled, preserves other extras, does not mutate the caller's requestTestRewriteChatRequest_DisableReasoningUnsetKeepsControls— unflagged redirect leaves reasoning aloneTestService_DisableReasoningForSource— flag lookup by source, missing/empty handledTestConfigModel_MapsDisableReasoning— config → service mapping round-trips the flag and marksManagedRefs #27