pub struct Runner<A> { /* private fields */ }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.
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.