Expand description
Runtime errors for the classic agent runtime, plus the portable completion contracts.
use rig_agent::completion::StructuredOutputError;
let error = StructuredOutputError::EmptyResponse;
assert!(error.provider_response_body().is_none());Re-exports§
pub use crate::run::response::PromptError;
Modules§
- handle
- Serializable model labels resolved to live handles by a runtime.
- history
- Shaping a conversation for the model it is sent to.
adaptis the one place history meets its target: a turn the same model produced keeps its provider items, any other turn replays from its canonical fields, failed turns are skipped, and every tool call gets an answer. - message
- options
- Portable generation options: provider-neutral knobs a request sets once
and every completion wire maps to its own JSON, or refuses. They hold only
what
CompletionRequesthas no field for, sotemperature,max_tokens,tool_choiceandoutput_schemastay on the request. - prompt
- A system prompt as data: a role and named sections, rendered into one system message only when the request is sent, so a layer in between can read, change or move a section by its tag.
- provider_
options - Typed per-provider request options and reply extras. A provider’s
ProviderExtensionmarker names its key, its serialize-onlyOptionsand itsExtrasview of a reply.ProviderOptionsholds entries for several providers at once, and each wire reads only the entry named by its own provider. - request
- Completion requests, normalized responses, and provider model contracts.
Structs§
- Accepts
- What a model reads, as replay sees it.
- Assistant
Message - One assistant turn.
- Completion
Request - A completion request to any provider’s model.
- Completion
Response - Assistant content and normalized completion metadata. The choice may be
empty, including for truncated or filtered turns. Provider-specific data is
available through
Self::rawwithout retaining a concrete model type. - Context
Use - The context a conversation’s next request sends, against the model’s input limit.
- Cost
- What one or more turns cost, in USD.
totalis what was charged, or whenSelf::is_completeisfalse, a lower bound of it. - Document
- A document sent with a request as context, rendered before the chat history.
- Generation
Options - Provider-neutral generation knobs for one request. An unset field leaves
the provider’s default. A field the wire or model cannot honour is
reported through
Self::unsupported_policy, never silently dropped. - Model
Ref - Model label serialized as a string. Equality compares labels without provider interpretation; resolving a label to a live handle is the runtime’s responsibility.
- Provider
Capabilities - Model capabilities used by runtimes when preparing requests.
Defaults are conservative; construct through
Self::newand setters. - Provider
Options - Typed options for several providers, one entry per provider key. Each wire reads only the entry named by its own provider. Equality and the serialized form are the entries’ sections. A deserialized entry has no typed options behind it, so its fields are sent as written: inserting the typed options again restores their refusal check.
- Provider
Tool Definition - Provider-native tool definition.
- Response
Identity - Distinct response and transport identifiers for one model call.
Unreported identifiers remain
None. - Section
- A named part of a
SystemPrompt. - System
Prompt - A system prompt in parts: the role, then each non-empty section between
<tag>and</tag>, sent as one system message. - Tool
Annotations - What calling a tool does to the world, as the Model Context Protocol’s
tool annotations state it, and spelled as they are on its wire
(
readOnlyHint, …), so an MCP tool’s annotations read straight into one. Each is a hint a tool’s author gives: a host’s policies read them (approval, plan mode, which calls run side by side), never trusting a tool it does not trust for them. A hint left unset takes the protocol’s default, which the accessors apply: not read-only, destructive, not idempotent, open world. - Tool
Definition - A tool the model may call: its name, description and argument schema,
sent to the model, and what the tool does to the world
(
ToolAnnotations), which stays with the host. - Unsupported
Option - An option the wire or model cannot honour. Carried by
ProviderError::UnsupportedOption. - Usage
- The token usage a provider reported for one completion.
- Usage
Totals - Many calls’
Usagesummed for a running account: the token counters, the known cost, and how many calls the sum holds and how many of them were not fully priced.
Enums§
- Assistant
Content - One block of an assistant turn: one provider output item.
Deserialization requires the lowercase
typetag. - Cache
Point - A point in a
CompletionRequestthat ends a stable prefix, forCompletionRequest::cache_points. Prefixes run in the order a request is sent: tools, then the system prompt, then the messages. - Cache
Retention - How long the provider keeps the prompt prefix cached.
- Check
Error - Why a dry run of a completion request failed: what
DynModel::checkreturns. - Effort
- A portable reasoning effort level, lowest first.
- Finish
Reason - Normalized generation ending. Unmapped provider values remain in
Self::Other. Failure statuses may accompany parseable output; callers must decide whether such output is usable rather than treating every response as successful. - Later
System - Where a target takes the system messages that come after the
conversation begins (
ReplayTarget::later_system). - Media
- One media part, as
ReplayTarget::encodessees it. Raw bytes are already base64, and an inline image already has the media type its bytes name. - Message
- A provider-agnostic chat message.
- OnUnsupported
- What happens to an option the wire or model cannot honour.
- Options
Error - Why a provider’s options cannot be stored.
- Pairing
- Which side of a hosted-tool pair an opaque item is.
- Place
- Where an image sits in a history.
- Reasoning
- How much the model reasons before answering.
- Replay
- What an encoder sends for one assistant block.
- Service
Tier - The processing tier a request asks for.
- Structured
Output Error - Why a typed run produced no value.
- Verbosity
- How long the answer should be.
Constants§
- SHARED
- The section every route of a provider reads.
Traits§
- Extension
Options - A provider’s request options. Serialize-only: the body keys they write
are their only output. They are plain data,
Send + Syncon every target, since a request carrying them may be held in shared host state, and unwind safe, so a request holding them stays unwind safe. - Provider
Extension - A provider’s typed request options and reply extras.
- Replay
Target - The model a request is sent to, as replay sees it. Every completion wire implements it.
- Reply
Extras - A typed view of a reply’s provider document.
Functions§
- adapt
historyshaped fortarget.- tokens_
label - A token count in at most four characters plus a unit:
999,1.2k,45k,1.2M.