Skip to content

feat(routing): per-request task-complexity routing seam (§0.1)#3

Merged
casabre merged 1 commit into
mainfrom
feat/routing-seam
Jul 3, 2026
Merged

feat(routing): per-request task-complexity routing seam (§0.1)#3
casabre merged 1 commit into
mainfrom
feat/routing-seam

Conversation

@casabre

@casabre casabre commented Jul 3, 2026

Copy link
Copy Markdown
Owner

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-request routingProfile → adapter selection point.

  • classifier (src/routing/classifier.ts) — keyword/length heuristic → COMPLEX | MID | ROUTINE.
  • router (src/routing/router.ts) — Router port; FixedRouter (routing off) + ProfileRouter (classify, or honour an explicit metadata.profile, → adapter with optional per-profile model). Adapter names validated against the registry at construction (fail fast).
  • config — optional zod routing block; layered file + env with a nested ROUTING__<PROFILE>__<FIELD> delimiter, env overriding individual leaves (pydantic-settings style).
  • executorsAgentTaskExecutor / McpTaskManager take an optional router (default FixedRouter(adapter) ⇒ existing callers & tests unchanged). A2A reads metadata.profile; MCP coding_agent_run gains an optional profile arg.

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 routing config ⇒ FixedRouter returns 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

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>
@casabre casabre merged commit 1aca339 into main Jul 3, 2026
10 checks passed
@casabre casabre deleted the feat/routing-seam branch July 3, 2026 19:01
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