Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 intodebug_failure→large_refactor→planning→tool_selection→final_answerfrom the last user message plus forwarded tools.agentRoutes[route]before dispatch whenenableAgentRouting: true; targets resolve through the existing model-resolution rules (ID / exact name / slug / alias).agent_route_fallbackand keep the requested model; successful substitutions recordroute/routeReason/routeTargeton 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.