Skip to content

fix: tighten router switch_project keywords to stop false positives#61

Merged
quick-sort merged 1 commit into
mainfrom
fix/router-switch-keywords
Jun 18, 2026
Merged

fix: tighten router switch_project keywords to stop false positives#61
quick-sort merged 1 commit into
mainfrom
fix/router-switch-keywords

Conversation

@hilr

@hilr hilr commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fixes Bug: router 常把正常工作指令误判为切换项目 #60. The router (claude-haiku) frequently misclassified normal work instructions as switch_project because the prompt's switch examples used generic verbs (用/use, 打开/open, 换/change). E.g. 用 pandas 处理数据 or 打开这个文件 would trigger a project switch.
  • Restricted the switch_project positive examples to explicit switch words only (switch to / change project to / 切换到 / 切到 / 切换项目到), added an inline disambiguation rule (bare 用/打开/换 + noun is NOT a switch), and added three FORWARD counter-examples with those trigger verbs in work context.

Test Plan

  • Extended test_fast_classify_no_match with the boundary phrases (deterministic guard)
  • Added a parametrized live test (test_router_live_prompt_classification) exercising the real haiku classifier — skipped without ANTHROPIC_API_KEY
  • Live results: 5/5 FORWARD cases correct, 4/4 switch cases correct
  • uv run pytest tests/test_router.py — 37 passed, ruff clean

Closes #60

The router's switch_project prompt examples used generic Chinese verbs
(用/use, 打开/open, 换/change), so normal work instructions like
"用 pandas 处理数据" or "打开这个文件" were misclassified as project
switches. Restrict positive examples to explicit switch words only, add
an inline disambiguation rule and FORWARD counter-examples, and cover the
behavior with deterministic fast-path cases plus a live haiku test.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@quick-sort quick-sort merged commit b33dce9 into main Jun 18, 2026
1 check passed
@quick-sort quick-sort deleted the fix/router-switch-keywords branch June 18, 2026 02:04
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.

Bug: router 常把正常工作指令误判为切换项目

2 participants