feat(routing): per-request task-complexity routing seam (§0.1)#3
Merged
Conversation
Replace the boot-fixed AGENT_ADAPTER with a per-request routingProfile -> adapter selection point (§0.1 of the three-plane design). Routing is opt-in: with no `routing` config the server uses a FixedRouter around the boot adapter, so behavior is byte-identical to before. - classifier: keyword/length heuristic → COMPLEX | MID | ROUTINE, plus normalizeProfile for explicit overrides. - router: Router port with FixedRouter (routing off) and ProfileRouter (classify or honour metadata.profile → adapter, with per-profile model override); adapter names validated against the registry at construction. - config: optional zod `routing` block; layered file + env with nested ROUTING__<PROFILE>__<FIELD> delimiter, env overriding individual leaves. - executors: AgentTaskExecutor and McpTaskManager take an optional router (defaults to FixedRouter(adapter) — existing callers unchanged); select the adapter per request. A2A reads metadata.profile; MCP coding_agent_run gains an optional `profile` arg. Default map (overridable): COMPLEX→cursor, MID→cursor, ROUTINE→codex — only existing CLI adapters; HTTP Mistral/Ollama attach to profiles later. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
First increment of the §0.1 "smallest coherent first delivery" — the headline goal from the routing audit. Ships the routing seam with zero behavior change when routing is off.
What
Replaces the boot-fixed
AGENT_ADAPTER(one adapter for every task) with a per-requestroutingProfile → adapterselection point.src/routing/classifier.ts) — keyword/length heuristic →COMPLEX | MID | ROUTINE.src/routing/router.ts) —Routerport;FixedRouter(routing off) +ProfileRouter(classify, or honour an explicitmetadata.profile, → adapter with optional per-profile model). Adapter names validated against the registry at construction (fail fast).routingblock; layered file + env with a nestedROUTING__<PROFILE>__<FIELD>delimiter, env overriding individual leaves (pydantic-settings style).AgentTaskExecutor/McpTaskManagertake an optional router (defaultFixedRouter(adapter)⇒ existing callers & tests unchanged). A2A readsmetadata.profile; MCPcoding_agent_rungains an optionalprofilearg.Default map (overridable): COMPLEX→
cursor, MID→cursor, ROUTINE→codex— existing CLI adapters only; HTTP Mistral/Ollama attach later (paid-backend trigger).Byte-identical when off
No
routingconfig ⇒FixedRouterreturns the boot adapter, model unchanged ⇒ same as before. The 341 pre-existing tests pass untouched.Tests / gates
typecheck✅ ·lint✅ ·test:coverage✅ (356 tests, 100% line+branch) ·build✅. New: classifier, router, routing-config (env-nested + file-merge), executor routing branches.🤖 Generated with Claude Code