Skip to main content

Module provider

Module provider 

Source
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§

BedrockProvider
Provider for AWS Bedrock-hosted models (bedrock/* slugs), backed by the Converse API.
OpenRouterProvider
The default OpenRouter-backed provider.

Enums§

ToolChoice
Provider-neutral tool-choice policy.

Constants§

DEFAULT_MAX_TOKENS
Default per-turn completion token cap when [llm].max_tokens is unset.
DEFAULT_MODEL
Default model slug when nothing else is specified.
DEFAULT_RUN_DEADLINE_SECS
Generous default wall-clock deadline for a run-task invocation, in seconds, when neither a CLI override nor RUN_DEADLINE_ENV_VAR is set.
RUN_DEADLINE_ENV_VAR
Environment variable overriding the run-task wall-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-task invocation.
resolve_max_tokens
Resolve the per-turn completion-token cap for an invocation.
resolve_model
Resolve the model slug for an invocation.