pub struct TextRunner { /* private fields */ }Expand description
Runs TextAgents with full service wiring (session, memory, artifacts, plugins).
Auto-wires in-memory service implementations by default; override with builder methods for custom persistence.
Implementations§
Source§impl TextRunner
impl TextRunner
Sourcepub fn new(agent: Arc<dyn TextAgent>, app_name: impl Into<String>) -> Self
pub fn new(agent: Arc<dyn TextAgent>, app_name: impl Into<String>) -> Self
Create a new runner with in-memory defaults for all services.
Sourcepub fn session_service(self, svc: Arc<dyn SessionService>) -> Self
pub fn session_service(self, svc: Arc<dyn SessionService>) -> Self
Override the session service.
Sourcepub fn memory_service(self, svc: Arc<dyn MemoryService>) -> Self
pub fn memory_service(self, svc: Arc<dyn MemoryService>) -> Self
Override the memory service.
Sourcepub fn artifact_service(self, svc: Arc<dyn ArtifactService>) -> Self
pub fn artifact_service(self, svc: Arc<dyn ArtifactService>) -> Self
Override the artifact service.
Sourcepub async fn run(
&self,
prompt: &str,
user_id: &str,
session_id: Option<&SessionId>,
) -> Result<String, AgentError>
pub async fn run( &self, prompt: &str, user_id: &str, session_id: Option<&SessionId>, ) -> Result<String, AgentError>
Run with session management. Creates or resumes a session.
- Creates a new session or loads an existing one
- Sets
"input"in state fromprompt - Runs the agent
- Persists the result as an event in the session
- Returns the agent’s text output
This is a thin convenience wrapper over run_stream:
it drains the event stream and returns the final response text (or the
surfaced error). Both methods share the exact same execution path.
Sourcepub fn run_stream<'a>(
&'a self,
prompt: &'a str,
user_id: &'a str,
session_id: Option<&'a SessionId>,
) -> BoxStream<'a, RunEvent>
pub fn run_stream<'a>( &'a self, prompt: &'a str, user_id: &'a str, session_id: Option<&'a SessionId>, ) -> BoxStream<'a, RunEvent>
Run the agent as an event stream, mirroring ADK-Python’s
Runner.run_async() which yields a Stream<Event>.
Yields RunEvent items as they happen, backed by the same
execution path as run:
- a user event carrying the prompt (also persisted to the session),
- zero or more agent events surfacing state deltas produced during the run (one per changed key, so eval harnesses and UIs can observe mutations), and
- a final response event authored by the root agent (also persisted).
Setup failures (session create/load, event persistence) and agent
failures are surfaced as a terminal RunEvent::Error rather than a
Result, so the item type stays a plain event. After an error the
stream ends.
run(prompt, user, session) is equivalent to draining this stream and
returning the last response event’s content.
Sourcepub async fn run_ephemeral(&self, prompt: &str) -> Result<String, AgentError>
pub async fn run_ephemeral(&self, prompt: &str) -> Result<String, AgentError>
Run without persistence (one-shot, ephemeral).
Sourcepub fn session_service_ref(&self) -> &dyn SessionService
pub fn session_service_ref(&self) -> &dyn SessionService
Access the session service.
Auto Trait Implementations§
impl Freeze for TextRunner
impl !RefUnwindSafe for TextRunner
impl Send for TextRunner
impl Sync for TextRunner
impl Unpin for TextRunner
impl !UnwindSafe for TextRunner
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<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].