Skip to main content

trusty_code/provider/
mod.rs

1//! Provider abstraction and per-agent model routing.
2//!
3//! Why: trusty-code routes each agent to its own model, which may live behind
4//! different backends (OpenRouter today, AWS Bedrock later). The agent loop must
5//! not branch on the backend; it depends on the [`Provider`] trait and asks a
6//! factory for the right implementation given a model slug. This module is that
7//! seam (#1021) and the precedence resolver for which slug to use.
8//! What: Re-exports the [`Provider`] trait and [`ToolChoice`] enum, the two
9//! concrete providers ([`OpenRouterProvider`], [`BedrockProvider`]), the
10//! [`provider_for`] factory, the [`resolve_model`] precedence function plus
11//! its [`DEFAULT_MODEL`] constant, the [`resolve_max_tokens`] precedence
12//! function plus its [`DEFAULT_MAX_TOKENS`] constant, and (#2207) the
13//! [`resolve_deadline_secs`] precedence function plus its
14//! [`DEFAULT_RUN_DEADLINE_SECS`] constant and [`RUN_DEADLINE_ENV_VAR`] name.
15//! Test: submodule `tests` in each file; routing/adapter coverage in
16//! `routing.rs` and `adapter.rs`.
17
18mod adapter;
19mod bedrock;
20mod openrouter;
21mod routing;
22mod traits;
23
24pub use adapter::provider_for;
25pub use bedrock::BedrockProvider;
26pub use openrouter::OpenRouterProvider;
27pub use routing::{
28    DEFAULT_MAX_TOKENS, DEFAULT_MODEL, DEFAULT_RUN_DEADLINE_SECS, RUN_DEADLINE_ENV_VAR,
29    resolve_deadline_secs, resolve_max_tokens, resolve_model,
30};
31pub use traits::{Provider, ToolChoice};