Skip to content

fix(routing): route short greetings to simple tier when tools attached#1561

Merged
brunobuddy merged 1 commit intomainfrom
fix/short-greeting-with-tools
Apr 13, 2026
Merged

fix(routing): route short greetings to simple tier when tools attached#1561
brunobuddy merged 1 commit intomainfrom
fix/short-greeting-with-tools

Conversation

@brunobuddy
Copy link
Copy Markdown
Member

@brunobuddy brunobuddy commented Apr 13, 2026

Summary

  • The scorer's short-message fast path was gated on !hasTools, so personal AI agents like OpenClaw (which always send a tools array) skipped it entirely and fell into full scoring.
  • Full scoring returns a tiny raw score for a one-word prompt, but applyMomentum assigns a very high weight to very short messages (~0.56 for a 4-char prompt), so any session that recently saw complex traffic pulled hi / hola up to complex.
  • Dropping the !hasTools gate lets short, non-technical prompts short-circuit to simple before momentum can inflate them. The hasComplexSignal check added in routing: short non-tool prompts under 50 chars bypass scoring and always route simple #1172 still forces full scoring for short technical prompts like Debug this function.

Test plan

  • npx jest src/scoring — 268 passed
  • npx jest (full backend unit suite) — 3535 passed
  • npx tsc --noEmit (backend) — clean
  • npm run test:e2e --workspace=packages/backend — 107 passed (updated routing-flow.e2e-spec.ts tools-floor case to use a long message so it still exercises applyTierFloors)
  • npm test --workspace=packages/frontend — 2110 passed
  • npx tsc --noEmit (frontend) — clean
  • scoring/index.ts stays at 100% line and branch coverage
  • Manual: send hola through OpenClaw in cloud mode, confirm the message log shows simple / short_message instead of complex / momentum

Notes

  • packages/backend/src/routing/resolve.service.spec.ts and packages/backend/test/routing-flow.e2e-spec.ts had tests that explicitly asserted tools force non-simple on a short message. Both were switched to a long message so they still exercise the applyTierFloors tools-floor branch instead of the fast path.
  • Non-English greetings (hola, bonjour, etc.) are intentionally not added to simpleIndicators — the fix here is in the fast-path gate, not the keyword list.
  • Broad codeGeneration / technicalTerms keyword lists are untouched.

Summary by cubic

Route short greetings to the simple tier even when tools are attached, preventing momentum from promoting one‑word prompts to complex. Short technical prompts still go through full scoring via the existing complex‑signal check.

  • Bug Fixes
    • Removed the !hasTools gate from the short-message fast path in scoreRequest, so non-technical short prompts short-circuit to simple.
    • Updated unit/e2e tests to cover the new behavior and use longer messages when testing the tools-floor path.

Written for commit 43590ad. Summary will update on new commits.

The scorer's short-message fast path was gated on `!hasTools`, so personal
AI agents like OpenClaw (which always send a tools array) skipped it
entirely and fell into full scoring. Session momentum could then pull a
one-word "hi" up to the complex tier.

Drop the gate so short prompts without complex keywords short-circuit to
simple regardless of tool presence. Short technical prompts like "Debug
this function" still fall through to full scoring thanks to the existing
complex-signal check added in #1172.
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.94%. Comparing base (bd60731) to head (43590ad).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1561   +/-   ##
=======================================
  Coverage   97.94%   97.94%           
=======================================
  Files         118      118           
  Lines        8614     8614           
  Branches     3240     3240           
=======================================
  Hits         8437     8437           
  Misses        175      175           
  Partials        2        2           
Flag Coverage Δ
frontend 97.93% <ø> (ø)
shared 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 6 files

@brunobuddy brunobuddy merged commit 6e28f0d into main Apr 13, 2026
15 checks passed
@brunobuddy brunobuddy deleted the fix/short-greeting-with-tools branch April 13, 2026 21: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.

1 participant