pub struct StreamingPromptRequest<M>where
M: CompletionModel,{ /* private fields */ }Expand description
A builder for creating prompt requests with customizable options. Uses generics to track which options have been set during the build process.
When the agent has no configured default_max_turns, the implicit budget is
one model call. Use .max_turns() to override the agent’s
configured or implicit budget; a tool call followed by a model-authored final
answer generally requires at least two model calls.
Implementations§
Source§impl<M> StreamingPromptRequest<M>where
M: CompletionModel + 'static,
<M as CompletionModel>::StreamingResponse: WasmCompatSend + GetTokenUsage,
impl<M> StreamingPromptRequest<M>where
M: CompletionModel + 'static,
<M as CompletionModel>::StreamingResponse: WasmCompatSend + GetTokenUsage,
Sourcepub fn new(
agent: Arc<Agent<M>>,
prompt: impl Into<Message>,
) -> StreamingPromptRequest<M>
pub fn new( agent: Arc<Agent<M>>, prompt: impl Into<Message>, ) -> StreamingPromptRequest<M>
Create a new StreamingPromptRequest from an agent WITHOUT the agent’s
default hooks. Use from_agent to include them.
Sourcepub fn from_agent(
agent: &Agent<M>,
prompt: impl Into<Message>,
) -> StreamingPromptRequest<M>
pub fn from_agent( agent: &Agent<M>, prompt: impl Into<Message>, ) -> StreamingPromptRequest<M>
Create a new StreamingPromptRequest from an agent, cloning the agent’s data and default hook stack.
Sourcepub fn max_turns(self, turns: usize) -> Self
pub fn max_turns(self, 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.
Named to match the blocking
PromptRequest::max_turns and
TypedPromptRequest::max_turns
builders so the same call reads identically on either surface.
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 (1 by default,
i.e. sequential). See AgentRunner::tool_concurrency: at any
concurrency the stream emits the model’s ToolCall items (call order),
then — atomically, after the whole tool batch settles successfully — the
per-tool ToolExecutionStart + ToolResult items in call order (not
completion order). The streamed message history is unchanged at any
concurrency.
Sourcepub fn add_hook<H>(self, hook: H) -> Selfwhere
H: AgentHook<M> + 'static,
pub fn add_hook<H>(self, hook: H) -> Selfwhere
H: AgentHook<M> + 'static,
Append a hook to this request’s hook stack (on top of any the agent
already carries). Hooks run in registration order; how their results
compose is event-dependent (CompletionCall request patches accumulate
and merge, ToolCall/ToolResult rewrites chain, and only
observe-only/recovery events use first-non-Continue-wins). See the
hook module docs.
Sourcepub fn tool_extensions(self, extensions: ToolCallExtensions) -> Self
pub fn tool_extensions(self, extensions: ToolCallExtensions) -> Self
Attach a per-call ToolCallExtensions for this request.
Every tool the agent executes during this request can read the
caller-provided values (auth tokens, session IDs, conversation state, …)
via Tool::call_with_extensions,
without the model ever seeing them.
Sourcepub fn conversation(self, id: impl Into<String>) -> Self
pub fn conversation(self, id: impl Into<String>) -> Self
Set the conversation id used to load and persist memory for this request.
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 request.
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.
Trait Implementations§
Source§impl<M> IntoFuture for StreamingPromptRequest<M>
impl<M> IntoFuture for StreamingPromptRequest<M>
Source§type Output = Pin<Box<dyn Stream<Item = Result<MultiTurnStreamItem<<M as CompletionModel>::StreamingResponse>, StreamingError>> + Send>>
type Output = Pin<Box<dyn Stream<Item = Result<MultiTurnStreamItem<<M as CompletionModel>::StreamingResponse>, StreamingError>> + Send>>
Source§type IntoFuture = Pin<Box<dyn Future<Output = <StreamingPromptRequest<M> as IntoFuture>::Output> + Send>>
type IntoFuture = Pin<Box<dyn Future<Output = <StreamingPromptRequest<M> as IntoFuture>::Output> + Send>>
Source§fn into_future(self) -> Self::IntoFuture
fn into_future(self) -> Self::IntoFuture
Auto Trait Implementations§
impl<M> !RefUnwindSafe for StreamingPromptRequest<M>
impl<M> !UnwindSafe for StreamingPromptRequest<M>
impl<M> Freeze for StreamingPromptRequest<M>
impl<M> Send for StreamingPromptRequest<M>
impl<M> Sync for StreamingPromptRequest<M>
impl<M> Unpin for StreamingPromptRequest<M>
impl<M> UnsafeUnpin for StreamingPromptRequest<M>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more