pub struct TypedRun<T> { /* private fields */ }Expand description
A run that deserializes its accepted output as T.
Configure it with the same setters as AgentRunner, then .await it for
a TypedPromptResponse<T>. With a retries budget, a
failed attempt (run error, empty output, unparseable output) is retried
from scratch; usage accumulates across attempts.
Implementations§
Source§impl<T> TypedRun<T>
impl<T> TypedRun<T>
Sourcepub fn retries(self, retries: u64) -> Self
pub fn retries(self, retries: u64) -> Self
Retry a failed attempt up to retries more times. An attempt fails when
the run errors, produces no output, or produces output that does not
parse as T. Usage accumulates across attempts.
Sourcepub fn tool_context(self, context: ToolContext) -> Self
pub fn tool_context(self, context: ToolContext) -> Self
Attach a per-call ToolContext for this run.
Every tool the agent executes during this run can read the
caller-provided values (auth tokens, session IDs, conversation state, …)
through the tool’s ToolContext,
without the model ever seeing them.
Sourcepub fn preamble(self, preamble: impl Into<String>) -> Self
pub fn preamble(self, preamble: impl Into<String>) -> Self
Override the agent preamble for this run.
Sourcepub fn without_preamble(self) -> Self
pub fn without_preamble(self) -> Self
Remove the agent’s configured preamble for this run.
Sourcepub fn document(self, document: Document) -> Self
pub fn document(self, document: Document) -> Self
Append one static context document for this run.
Sourcepub fn documents(self, documents: impl IntoIterator<Item = Document>) -> Self
pub fn documents(self, documents: impl IntoIterator<Item = Document>) -> Self
Append static context documents for this run.
Sourcepub fn temperature(self, temperature: f64) -> Self
pub fn temperature(self, temperature: f64) -> Self
Override the model temperature for this run.
Sourcepub fn without_temperature(self) -> Self
pub fn without_temperature(self) -> Self
Remove the agent’s configured temperature for this run.
Sourcepub fn max_tokens(self, max_tokens: u64) -> Self
pub fn max_tokens(self, max_tokens: u64) -> Self
Override the maximum completion token count for this run.
Sourcepub fn without_max_tokens(self) -> Self
pub fn without_max_tokens(self) -> Self
Remove the agent’s configured maximum token count for this run.
Sourcepub fn merge_additional_params(self, params: Map<String, Value>) -> Self
pub fn merge_additional_params(self, params: Map<String, Value>) -> Self
Shallow-merge object fields into the provider-specific parameters for this run. Later fields win.
Sourcepub fn replace_additional_params(self, params: Value) -> Self
pub fn replace_additional_params(self, params: Value) -> Self
Replace all provider-specific parameters for this run.
Sourcepub fn without_additional_params(self) -> Self
pub fn without_additional_params(self) -> Self
Remove the agent’s configured provider-specific parameters for this run.
Sourcepub fn tool_choice(self, tool_choice: ToolChoice) -> Self
pub fn tool_choice(self, tool_choice: ToolChoice) -> Self
Override the tool-choice policy for this run.
Sourcepub fn without_tool_choice(self) -> Self
pub fn without_tool_choice(self) -> Self
Remove the agent’s configured tool-choice policy for this run.
Sourcepub fn record_content_telemetry(self, enabled: bool) -> Self
pub fn record_content_telemetry(self, enabled: bool) -> Self
Opt in or out of recording sensitive request, response, and tool content on GenAI telemetry spans for this run.
Defaults to the agent’s setting, which defaults to false. Enabling
this can expose prompts, retrieved context, tool results, model
responses, and other sensitive or high-cardinality data through
OpenTelemetry span attributes. Structural metadata and token usage
remain available when disabled.
Sourcepub fn conversation(self, id: impl Into<ConversationId>) -> Self
pub fn conversation(self, id: impl Into<ConversationId>) -> Self
Set the conversation id used to load and persist memory for this run.
Overrides any default conversation id set on the agent. If memory is not configured on the agent, this has no effect.
Sourcepub fn without_memory(self) -> Self
pub fn without_memory(self) -> Self
Disable conversation memory for this run.
History will neither be loaded from nor saved to the agent’s memory backend.
Sourcepub fn max_invalid_tool_call_retries(self, retries: usize) -> Self
pub fn max_invalid_tool_call_retries(self, retries: usize) -> Self
Set the retry budget for invalid tool-call recovery.
Invalid tool-call retries also consume the total model-call budget.
Sourcepub fn using_model(self, model: impl Into<ModelRef>) -> Self
pub fn using_model(self, model: impl Into<ModelRef>) -> Self
Set the default model candidate for this run.
This does not suppress registered model-selection hooks, which may replace this candidate before each model call (including retries).
Sourcepub fn using_model_value(self, model: impl Into<DynModel<Completion>>) -> Self
pub fn using_model_value(self, model: impl Into<DynModel<Completion>>) -> Self
Erase and set a typed default model for this run.
Sourcepub fn max_turns(self, max_turns: usize) -> Self
pub fn max_turns(self, max_turns: usize) -> Self
Set the total model-call budget, including the initial call and every
retry or continuation. Zero emits no model calls; one permits only the
initial call. Exceeding the budget returns a
StructuredOutputError::PromptError wrapping a MaxTurnsError.
Sourcepub fn add_hook<H>(self, hook: H) -> Selfwhere
H: AgentHook + 'static,
pub fn add_hook<H>(self, hook: H) -> Selfwhere
H: AgentHook + 'static,
Append a hook to this run’s hook stack (on top of any the agent
already carries). See the hook module docs.
Sourcepub fn tool_concurrency(self, concurrency: usize) -> Self
pub fn tool_concurrency(self, concurrency: usize) -> Self
Execute up to concurrency of a turn’s tool calls at once. See
AgentRunner::tool_concurrency for ordering guarantees.