Skip to content

Fix: Narrow complex scenario keywords to prevent false-positive routing#111

Merged
samueltuyizere merged 1 commit into
routatic:mainfrom
hllqkb:fix/narrow-complex-keywords
Jul 6, 2026
Merged

Fix: Narrow complex scenario keywords to prevent false-positive routing#111
samueltuyizere merged 1 commit into
routatic:mainfrom
hllqkb:fix/narrow-complex-keywords

Conversation

@hllqkb

@hllqkb hllqkb commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Problem

The scenario router was sending almost every Claude Code turn to the complex model (GLM-5.1) instead of default (Kimi K2.6) or think (GLM-5.2).

Root cause: hasComplexPattern matched a broad set of keywords (error, debug, bug, build, create, bash, execute, implement, ...) that appear constantly in tool_result content (bash output, file contents, stack traces) and ordinary coding messages. Since tool_result blocks have role=\"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 hasComplexPattern to genuinely architectural / large-scale keywords only:

  • Kept: architect, architecture, refactor, redesign, complex, difficult, challenging, optimize, performance, efficiency, design pattern, best practice
  • Removed: bug, debug, error, exception, stack trace, execute, run command, bash, shell, implement, build, create, add feature, write to, edit file, create file

Routine coding/debugging tasks now stay on default (Kimi K2.6); reasoning-heavy turns still hit think (GLM-5.2) via hasThinkingPattern; only true architectural work routes to complex (GLM-5.1).

Log evidence (after, same workload):
```
scenario=default model=kimi-k2.6 tokens=58588
```

Tests

  • go build ./... passes
  • go test ./... passes
  • Updated two tests whose assertions relied on debug/bug as complex triggers:
    • TestDetectScenario_DebugWithoutVisualIntentStaysTextComplex → renamed to ...StaysTextDefault
    • TestRouteForStreaming_VisionComplexKeepsVisionComplexScenario now uses refactor to exercise the vision_complex path

Backward compatibility

No config options, public APIs, or SPI contracts changed. Only the internal keyword list for scenario detection was narrowed.

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.
@samueltuyizere samueltuyizere merged commit 889a758 into routatic:main Jul 6, 2026
3 checks passed
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.

2 participants