pub struct Runner<A> { /* private fields */ }server only.Expand description
A configured run: the agent, its transformer chain and its cancellation token.
let runner = Runner::new(MyAgent).transformer(FilterToolCalls::deny(["internal_debug"]));
let token = runner.cancellation_token(); // hand this to the transport
let stream = runner.run(RunAgentInput::new("thread-1", "run-1"));Implementations§
Source§impl<A> Runner<A>
impl<A> Runner<A>
Sourcepub fn transformer(self, transformer: impl StreamTransformer + 'static) -> Self
pub fn transformer(self, transformer: impl StreamTransformer + 'static) -> Self
Appends a transformer to the chain. See StreamTransformer.
Sourcepub fn transformers(self, chain: TransformerChain) -> Self
pub fn transformers(self, chain: TransformerChain) -> Self
Replaces the whole transformer chain.
Sourcepub fn cancellation(self, token: CancellationToken) -> Self
pub fn cancellation(self, token: CancellationToken) -> Self
Uses an existing cancellation token instead of the fresh one.
Sourcepub fn cancellation_token(&self) -> CancellationToken
pub fn cancellation_token(&self) -> CancellationToken
A handle on this run’s cancellation, for the transport to trip when the client disconnects.
Sourcepub fn echo_input(self, echo: bool) -> Self
pub fn echo_input(self, echo: bool) -> Self
Echoes the request back on RUN_STARTED, so a recorded stream replays
without the original HTTP body. Off by default — it is the largest
payload in the protocol.
Sourcepub fn event_buffer_capacity(self, capacity: NonZeroUsize) -> Self
pub fn event_buffer_capacity(self, capacity: NonZeroUsize) -> Self
Limits queued events, including lifecycle events, after transformation.
Emission is synchronous, so it cannot wait for a slow consumer. When
full, the sink rejects the next event, appends one reserved RUN_ERROR
with code EVENT_BUFFER_FULL, then closes the stream. Already accepted
events retain their order. This terminal error bypasses transformers.
The default remains unbounded. This bounds event count, not payload bytes or allocations made by an agent/transformer before emission. Applications with durable execution should reconnect from committed state; this transport failure does not decide business success.
Source§impl<A: Agent> Runner<A>
impl<A: Agent> Runner<A>
Sourcepub fn run(
self,
input: RunAgentInput,
) -> impl Stream<Item = Result<Event>> + Send
pub fn run( self, input: RunAgentInput, ) -> impl Stream<Item = Result<Event>> + Send
Starts the run.
The returned stream emits RUN_STARTED first and exactly one of
RUN_FINISHED / RUN_ERROR last — including when the agent body does
nothing, and when it returns Err through a ?.
A panic inside the agent is not caught; it unwinds through whoever is polling the stream, as it would through any other future. Use the transport’s own panic handling if you need a response body for that case.