Skip to main content

Launcher

Struct Launcher 

Source
pub struct Launcher { /* private fields */ }
Expand description

Launcher for running ADK agents with CLI support.

Provides console and web server modes out of the box.

§Console mode

Uses a rustyline REPL with history, Ctrl+C handling, and streaming output that renders <think> blocks, tool calls, and inline data.

§Serve mode

Starts an Axum HTTP server with the ADK web UI.

§Note on with_streaming_mode

with_streaming_mode currently only affects console mode. ServerConfig does not accept a RunConfig, so the setting is not forwarded to the server. This will be addressed when ServerConfig gains that field.

Implementations§

Source§

impl Launcher

Source

pub fn new(agent: Arc<dyn Agent>) -> Self

Create a new launcher with the given agent.

Source

pub fn app_name(self, name: impl Into<String>) -> Self

Set a custom application name (defaults to agent name).

Source

pub fn with_artifact_service(self, service: Arc<dyn ArtifactService>) -> Self

Set a custom artifact service.

Source

pub fn with_session_service(self, service: Arc<dyn SessionService>) -> Self

Set a custom session service.

Source

pub fn with_memory_service(self, service: Arc<dyn Memory>) -> Self

Set a custom memory service.

Source

pub fn with_compaction(self, config: EventsCompactionConfig) -> Self

Enable runner-level context compaction in serve mode.

Source

pub fn with_context_cache( self, config: ContextCacheConfig, cache_capable: Arc<dyn CacheCapable>, ) -> Self

Enable automatic prompt cache lifecycle management in serve mode.

Source

pub fn with_security_config(self, config: SecurityConfig) -> Self

Set custom server security settings.

Source

pub fn with_request_context_extractor( self, extractor: Arc<dyn RequestContextExtractor>, ) -> Self

Set a request context extractor for authenticated deployments.

Source

pub fn with_a2a_base_url(self, base_url: impl Into<String>) -> Self

Enable A2A routes when building or serving the HTTP app.

Source

pub fn with_telemetry(self, config: TelemetryConfig) -> Self

Configure how serve mode initializes telemetry.

Source

pub fn with_shutdown_grace_period(self, grace_period: Duration) -> Self

Set the maximum graceful shutdown window for the web server.

Source

pub fn with_streaming_mode(self, mode: StreamingMode) -> Self

Set streaming mode for console mode.

Note: this currently only affects console mode. The server does not yet accept a RunConfig.

Source

pub fn with_thinking_mode(self, mode: ThinkingDisplayMode) -> Self

Control how emitted thinking content is rendered in console mode.

Source

pub async fn run(self) -> Result<()>

Run the launcher, parsing CLI arguments.

  • No arguments or chat: Interactive console
  • serve [--port PORT]: Web server with UI
Source

pub async fn run_console_directly(self) -> Result<()>

Run in interactive console mode without parsing CLI arguments.

Use this when you already know you want console mode (e.g. from your own CLI parser). run calls this internally.

Source

pub fn build_app(self) -> Result<Router>

Build the Axum application without serving it.

This is the production escape hatch for adding custom routes, middleware, metrics, or owning the serve loop yourself.

Source

pub fn build_app_with_a2a(self, base_url: impl Into<String>) -> Result<Router>

Build the Axum application with A2A routes enabled.

Source

pub async fn run_serve_directly(self, port: u16) -> Result<()>

Run web server without parsing CLI arguments.

Use this when you already know you want serve mode (e.g. from your own CLI parser). run calls this internally.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more