Fix: Narrow complex scenario keywords to prevent false-positive routing#111
Merged
Merged
Conversation
hasComplexPattern was routing almost every Claude Code turn to the complex model (GLM-5.1) because tool_result content and ordinary coding messages contain "error", "debug", "build", "bash", etc. Remove these over-broad keywords so that routine coding tasks stay on default (kimi-k2.6) while truly architectural work continues to route to complex. Updated tests: debug/bug no longer trigger complex scenario.
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.
Problem
The scenario router was sending almost every Claude Code turn to the
complexmodel (GLM-5.1) instead ofdefault(Kimi K2.6) orthink(GLM-5.2).Root cause:
hasComplexPatternmatched a broad set of keywords (error,debug,bug,build,create,bash,execute,implement, ...) that appear constantly intool_resultcontent (bash output, file contents, stack traces) and ordinary coding messages. Sincetool_resultblocks haverole=\"user\"in the Anthropic API, the latest-user-message scan matched on them almost every turn.Log evidence (before):
```
scenario=complex model=glm-5.1 tokens=19352 # routine coding turn
scenario=complex model=glm-5.1 tokens=44911 # routine coding turn
scenario=default model=kimi-k2.6 tokens=386 # only "hi"-style greetings hit default
```
Fix
Narrow
hasComplexPatternto genuinely architectural / large-scale keywords only:architect,architecture,refactor,redesign,complex,difficult,challenging,optimize,performance,efficiency,design pattern,best practicebug,debug,error,exception,stack trace,execute,run command,bash,shell,implement,build,create,add feature,write to,edit file,create fileRoutine coding/debugging tasks now stay on
default(Kimi K2.6); reasoning-heavy turns still hitthink(GLM-5.2) viahasThinkingPattern; only true architectural work routes tocomplex(GLM-5.1).Log evidence (after, same workload):
```
scenario=default model=kimi-k2.6 tokens=58588
```
Tests
go build ./...passesgo test ./...passesdebug/bugas complex triggers:TestDetectScenario_DebugWithoutVisualIntentStaysTextComplex→ renamed to...StaysTextDefaultTestRouteForStreaming_VisionComplexKeepsVisionComplexScenarionow usesrefactorto exercise the vision_complex pathBackward compatibility
No config options, public APIs, or SPI contracts changed. Only the internal keyword list for scenario detection was narrowed.