Skip to content

feat: deterministic cheap/strong agent routing (off by default) - #16

Open
Shifat7 wants to merge 1 commit into
clutchpbcfo:mainfrom
Shifat7:pr-09-agent-routing
Open

Shifat7 wants to merge 1 commit into
clutchpbcfo:mainfrom
Shifat7:pr-09-agent-routing

Conversation

@Shifat7

@Shifat7 Shifat7 commented Aug 22, 2026

Copy link
Copy Markdown

What changed

Route simple turns to a cheap Hyperagent agent and hard turns to a stronger one:

  • pickAgentRoute(body, tools, config) (src/protocol.mjs) deterministically classifies each request into debug_failurelarge_refactorplanningtool_selectionfinal_answer from the last user message plus forwarded tools.
  • Bridge applies agentRoutes[route] before dispatch when enableAgentRouting: true; targets resolve through the existing model-resolution rules (ID / exact name / slug / alias).
  • Unknown targets log agent_route_fallback and keep the requested model; successful substitutions record route/routeReason/routeTarget on the audit receipt.

Config: enableAgentRouting (false by default), agentRoutes: {}.

Guarantees (test-enforced): deterministic selection with explicit precedence; unknown route falls back; disabled default never substitutes even when maps exist; logs show route + reason.

Why it saves credits

Cheap agents handle tool-selection and final-answer turns; strong/debug agents only pay off on hard turns.

Testing

npm test: 79 pass, 0 fail.

Add pickAgentRoute() classifying each request into debug_failure,
large_refactor, planning, tool_selection, or final_answer, and bridge
support for substituting a configured agentRoutes target before
dispatch when enableAgentRouting is true. Route targets resolve via
the standard model resolution rules; unknown targets log
agent_route_fallback and keep the requested model; selected routes
and reasons are recorded in audit receipts.

Disabled by default: no hidden model substitution.
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