Skip to main content

Module llm

Module llm 

Source
Expand description

Resolve agent -> model -> provider; build Rig agent.

Modules§

retry
Transient-error retry wrapper around a CompletionModel.

Structs§

MistralrsWeights
Weight-source spec for a mistralrs-backed model. Lifted off [models.<name>] at resolve time. Only one of model_id / model_path is meaningful in any given instance; validation enforces that, but mistralrs::load is also defensive.
OutrigPromptHook
Per-request hook that traces every tool call to stderr and stops the agent loop after max calls. Cloned by rig per request; shared atomics keep a single turn’s calls counting against the same max.
ResolvedAgent
Fully-resolved view of one agent: every knob the agent loop needs to build a Rig client and run a turn.

Enums§

LlmResolveError
Failures that surface while walking agents -> models -> providers or constructing the Rig client. Wrapped into crate::error::OutrigError at the top level via #[from].
ResolvedProvider
Runtime-shaped provider view – mirrors the config LlmProvider enum, but with the env-var-backed ApiKeyRef already resolved to a plain String for the OpenAi variant. Variants are kept in sync with LlmProvider’s.
RigAgent
Runtime-dispatched Rig agent. The OpenAi-backed and mistralrs-backed CompletionModel impls produce concretely different Agent<M> types (Rig’s trait carries associated types, so a single concrete RigAgent can’t carry both). Callers (the agent loop) match on the variant.

Constants§

DEFAULT_REQUEST_TIMEOUT_SECS
Default per-request HTTP timeout for OpenAi-style providers when request-timeout-secs is unset (see doc/reference/config.md). Generous enough not to truncate long reasoning completions, and above typical proxy timeouts so a client-side timeout never races a still-in-flight server request.
DEFAULT_TOOL_RESULT_MAX_BYTES
Default byte ceiling applied to each individual MCP tool result before it is handed to Rig and appended to model-visible chat history.
MAX_TOOL_CALLS
Hard max on tool calls per turn. The hook below trips this; rig’s own max_turns is set to the same value as a defense in depth, so whichever fires first surfaces a controllable message.

Functions§

build_agent
Build a Rig Agent ready to receive a turn. Preamble, sampling params, and the dynamic-tool list come from resolved plus the caller-supplied MCP-backed adapters. The cache_root argument is the directory into which the mistralrs HF-download path stages model files; it’s ignored for OpenAi providers.
resolve_agent
Walk cfg.agents -> models -> providers to resolve every knob the agent loop needs. Bails with a descriptive error if a reference is dangling or the api-key env var is unset.
resolve_agent_with_device_override
resolve_agent_with_overrides