Skip to content

feat: intent-based routing with effort tiers and escalation#4

Merged
DaveZheng merged 1 commit intomainfrom
feat/intent-based-routing
Feb 8, 2026
Merged

feat: intent-based routing with effort tiers and escalation#4
DaveZheng merged 1 commit intomainfrom
feat/intent-based-routing

Conversation

@DaveZheng
Copy link
Copy Markdown
Owner

Summary

  • Classifies each request by complexity (chit_chat, simple_code, hard_question, try_again) using the already-loaded local MLX model
  • Routes to the appropriate model tier: local MLX for simple tasks, Claude Sonnet 4.5 for medium, Claude Opus 4.6 for complex
  • Smart defaults based on local model capability — Qwen3-Coder-Next (64GB+) defaults medium tier to local since it benchmarks near Sonnet
  • "Try again" / "you're wrong" escalates through tiers: local → sonnet → opus
  • mallex --setup to reconfigure routing at any time
  • Falls back to local MLX on any Claude API error (auth, rate limit, overload)

New files

File Purpose
src/router.ts Intent classification, fuzzy category parsing, tier escalation
src/claude-client.ts Zero-dependency Anthropic API client (node:https) with streaming pipe-through
src/setup-router.ts Interactive setup questionnaire with DI for testability
src/*test.ts (×3) 48 new tests (171 total, all passing)

Modified files

File Changes
src/config.ts TierModel, RoutingConfig types, defaultTierModels() smart defaults
src/proxy.ts Routing decision between parse and translate, Claude API forwarding with model override
src/index.ts --setup flag, first-run routing setup
README.md Routing docs, updated diagram, config example, refreshed model table

Test plan

  • npm run build && npm test — 171 tests pass, 0 failures
  • Run mallex --setup — verify questionnaire displays tiers with model names
  • Run mallex fresh (delete ~/.mallex/config.json) — verify first-run includes routing setup
  • With hard_question → Tier 3, send a complex request and verify it routes to Claude API
  • With all tiers set to local, verify classification is skipped entirely
  • Send a request, then say "that's wrong, try again" — verify tier escalation
  • Set an invalid Claude API key — verify fallback to local with warning

🤖 Generated with Claude Code

Classify requests by complexity using the local MLX model and route
to the appropriate model tier (local MLX, Claude Sonnet, or Claude
Opus). Smart defaults based on local model capability — Qwen3-Coder-Next
users get local for medium tasks since it benchmarks near Sonnet.

"Try again" escalates through tiers: local → sonnet → opus.

New files: router, claude-client, setup-router (with tests).
Modified: config (tier types), proxy (routing logic), index (--setup flag).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@DaveZheng DaveZheng merged commit 5fbeea5 into main Feb 8, 2026
@DaveZheng DaveZheng deleted the feat/intent-based-routing branch February 8, 2026 19:41
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