Repository navigation
Route each dispatch to a provider by repo size and mode - #267
Merged
Merged
Conversation
Optional provider routing (docs/rfcs/provider-routing.md). With no routing.json, nothing changes. With one, run_agent profiles the repo's clone into a size tier, picks the cheapest provider trusted with that mode and tier (a subscription, a self-hosted model behind a Claude Code wrapper, a command harness), and escalates down the list on blocked, timeout, EX_TEMPFAIL or error. local_only repos never leave local providers; with no eligible provider the run is refused, never sent to a default. Runs record provider and escalated_from (additive columns, hub fields, status column, alert line); a free provider's run records no cost. overnight batches respect per-provider concurrency, and gardener route explains a decision. gardener/routing/ is ports and adapters: model, a pure core, one protocol per file in ports/, one implementation per file in adapters/, and RoutingService as the composition root. Safety checks stay in dispatch.py; two adapters only delegate to check_harness_ready and run_agent. Architecture tests keep the core from importing adapters. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LYNeujxeMjcjdhUF7mg3s3
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.
Adds optional provider routing: each run can go to a different agent provider depending on the repo's size and the mode. The design, motivation and evidence are in
docs/rfcs/provider-routing.md.Behaviour
routing.json, no change. The single-harness path is untouched; this is tested to give identical argv and results.run_agentprofiles the clone into tier S, M or L and takes the first matching rule's providers. It drops any provider that isn't trusted with the mode, is below the tier, isn't local for alocal_onlyrepo, is too small for the repo, can't run here, or fails its health check. Blocked, timed-out, exit-75 or failed runs escalate to the next provider.local_onlyrepo is never sent to a cloud provider.providerandescalated_fromcolumns (an additive migration), with optional hub fields, a status column and aprovider:line in alerts. Afreeprovider's run records no cost, because Claude Code prices every run as if a Claude model served it.overnightrespects per-provider concurrency, both while planning batches and through process-wide slots.gardener route --repo owner/name [--mode …]explains a decision.Structure
gardener/routing/is laid out as ports and adapters:model.pyholds the domain values;core.pyholds the pure policy (parse, route, escalate).ports/has eight protocols, one per file.adapters/has eleven implementations, one per file.RoutingServiceis the composition root.dispatch.py:DispatchReadinessandDispatchRunneronly callcheck_harness_readyandrun_agent.Verification
tests/test_routing.pytests the core with one fake per port and no patching. It also checks each adapter against its port and has architecture tests:model,coreandportsnever import adapters, and each port or adapter file holds one class.costis now rejected, and a health reply that isn't a JSON object counts as unreachable.align, then an escalation). The RFC lists its steps; it should run before routing is relied on.drafted by Claude on behalf of Daniel Stephenson
🤖 Generated with Claude Code
https://claude.ai/code/session_01LYNeujxeMjcjdhUF7mg3s3