feat(model-routing): add ModelRouter core and candidate resolution#8
Closed
JackYPCOnline wants to merge 6 commits into
Closed
feat(model-routing): add ModelRouter core and candidate resolution#8JackYPCOnline wants to merge 6 commits into
JackYPCOnline wants to merge 6 commits into
Conversation
…nds-agents#3463) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…trands-agents#3462) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: opieter-aws <opieter@amazon.com>
…trands-agents#3434) Co-authored-by: mehtarac <mehtarac@amazon.com>
…s#3465) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Add the strands.models.routing package aligned with design 0016: RoutingCandidate (model plus optional name/description), ModelRouter (a reusable, immutable Plugin over an ordered candidate sequence), the RoutingStrategy protocol (select -> RoutingCandidate), and RoutingContext. The router normalizes model/string/nested-router/RoutingCandidate inputs, exposes the first candidate resolved to a concrete model as the default, and recursively rejects stateful candidates. Agent now accepts model=ModelRouter(...): it exposes the router's default as agent.model and registers the router as a plugin. Per-call selection middleware lands in a follow-up, so routing is inert (uses the first candidate) for now and single-model usage is unchanged. Includes an end-to-end integration test (real Bedrock) covering the Agent -> router -> InvokeModelStage -> concrete model path. Refs strands-agents#364
JackYPCOnline
force-pushed
the
feature/model-routing-core
branch
from
July 24, 2026 18:43
c78b099 to
8d45480
Compare
JackYPCOnline
had a problem deploying
to
manual-approval
July 24, 2026 18:44 — with
GitHub Actions
Failure
Owner
Author
|
Superseded by the upstream Phase B PR against strands-agents/harness-sdk (rebased onto main after Phase A merged). |
Documentation Preview FailedThe documentation deployment encountered an error. Please check the deployment logs for more details. |
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.
Description
Phase B of model routing (design
team/designs/0016-model-routing.md): theModelRoutercore. Stacked on the Phase A per-call-model seam (base branchfeature/model-routing), so this PR's diff is Phase B only.Adds the
strands.models.routingpackage and teachesAgentto accept a router throughmodel=. Per-call selection middleware lands in a follow-up, so routing is inert here: an agent with a router uses the router's first (default) candidate, and single-model usage is unchanged.Public API (provisional, pre bar-raising)
ModelRouteris a reusable, immutablePluginover an ordered candidate sequence; the same router can back multiple agents.Model, a model-id string (resolved toBedrockModel), a nestedModelRouter, or aRoutingCandidate.RoutingStrategyisasync select(context) -> RoutingCandidate;RoutingContextcarries the request data and normalized candidates.agent.modelresolves to the first candidate as a concrete model.Related Issues
Refs strands-agents#364
Type of Change
New feature
Testing
How have you tested the change? Verify that the changes do not break functionality or introduce new warnings.
hatch run prepare18 unit tests cover normalization, first-candidate default, nested resolution, stateful/duplicate/type guards, and Agent integration. Added
tests_integ/models/test_model_routing.py(real Bedrock) exercising theAgent -> router -> InvokeModelStage -> concrete modelpath end to end. Full unit suite passes; ruff + mypy clean.Checklist