Expand description
Provider abstraction and per-agent model routing.
Why: Each agent routes to its own model, possibly behind a different backend
(OpenRouter today, AWS Bedrock later). The agent loop depends on the
Provider trait rather than branching on the backend, and a factory maps a
model slug to the right implementation.
What: Provider, ToolChoice, OpenRouterProvider, BedrockProvider,
provider_for, resolve_model, DEFAULT_MODEL.
Test: provider::* submodule tests.
Provider abstraction and per-agent model routing.
Why: trusty-code routes each agent to its own model, which may live behind
different backends (OpenRouter today, AWS Bedrock later). The agent loop must
not branch on the backend; it depends on the [Provider] trait and asks a
factory for the right implementation given a model slug. This module is that
seam (#1021) and the precedence resolver for which slug to use.
What: Re-exports the [Provider] trait and [ToolChoice] enum, the two
concrete providers ([OpenRouterProvider], [BedrockProvider]), the
[provider_for] factory, the [resolve_model] precedence function plus
its [DEFAULT_MODEL] constant, the [resolve_max_tokens] precedence
function plus its [DEFAULT_MAX_TOKENS] constant, and (#2207) the
[resolve_deadline_secs] precedence function plus its
[DEFAULT_RUN_DEADLINE_SECS] constant and [RUN_DEADLINE_ENV_VAR] name.
Test: submodule tests in each file; routing/adapter coverage in
routing.rs and adapter.rs.
Structs§
- Bedrock
Provider - Provider for AWS Bedrock-hosted models (
bedrock/*slugs), backed by the Converse API. - Open
Router Provider - The default OpenRouter-backed provider.
Enums§
- Tool
Choice - Provider-neutral tool-choice policy.
Constants§
- DEFAULT_
MAX_ TOKENS - Default per-turn completion token cap when
[llm].max_tokensis unset. - DEFAULT_
MODEL - Default model slug when nothing else is specified.
- DEFAULT_
RUN_ DEADLINE_ SECS - Generous default wall-clock deadline for a
run-taskinvocation, in seconds, when neither a CLI override norRUN_DEADLINE_ENV_VARis set. - RUN_
DEADLINE_ ENV_ VAR - Environment variable overriding the
run-taskwall-clock deadline (#2207).
Traits§
- Provider
- A backend that normalises tool-choice and usage for one family of models.
Functions§
- provider_
for - Select the provider implementation for a model slug.
- resolve_
deadline_ secs - Resolve the wall-clock deadline (in seconds) for a
run-taskinvocation. - resolve_
max_ tokens - Resolve the per-turn completion-token cap for an invocation.
- resolve_
model - Resolve the model slug for an invocation.