Skip to main content

ServerConfig

Struct ServerConfig 

Source
pub struct ServerConfig {
Show 15 fields pub agent_loader: Arc<dyn AgentLoader>, pub session_service: Arc<dyn SessionService>, pub artifact_service: Option<Arc<dyn ArtifactService>>, pub memory_service: Option<Arc<dyn Memory>>, pub compaction_config: Option<EventsCompactionConfig>, pub context_cache_config: Option<ContextCacheConfig>, pub cache_capable: Option<Arc<dyn CacheCapable>>, pub span_exporter: Option<Arc<AdkSpanExporter>>, pub backend_url: Option<String>, pub security: SecurityConfig, pub request_context_extractor: Option<Arc<dyn RequestContextExtractor>>, pub interceptor_chain: Option<Arc<InterceptorChain>>, pub yaml_agent_dirs: Vec<PathBuf>, pub governance: GovernanceControl, pub session_activity: SessionActivity,
}
Expand description

Configuration for the ADK server.

Fields§

§agent_loader: Arc<dyn AgentLoader>§session_service: Arc<dyn SessionService>§artifact_service: Option<Arc<dyn ArtifactService>>§memory_service: Option<Arc<dyn Memory>>§compaction_config: Option<EventsCompactionConfig>§context_cache_config: Option<ContextCacheConfig>§cache_capable: Option<Arc<dyn CacheCapable>>§span_exporter: Option<Arc<AdkSpanExporter>>§backend_url: Option<String>§security: SecurityConfig§request_context_extractor: Option<Arc<dyn RequestContextExtractor>>§interceptor_chain: Option<Arc<InterceptorChain>>

Optional interceptor chain for A2A request/response middleware.

When set, the chain is invoked before and after A2A executor processing.

§yaml_agent_dirs: Vec<PathBuf>

Directories containing YAML agent definitions to watch for hot reload. Only used when the yaml-agent feature is enabled.

§governance: GovernanceControl

Kill switch shared by every runner the server builds.

Freezing it — directly or through POST /api/admin/freeze when ServerBuilder::enable_governance_endpoints is set — fails new runs and stops running ones before their next model or tool call.

§session_activity: SessionActivity

The sessions with a turn in flight, shared by every runner the server builds and by the session history routes, which refuse to fork, rewind, or edit a session while a turn runs on it.

Implementations§

Source§

impl ServerConfig

Source

pub fn new( agent_loader: Arc<dyn AgentLoader>, session_service: Arc<dyn SessionService>, ) -> Self

Source

pub fn with_session_activity(self, activity: SessionActivity) -> Self

Shares activity with every runner the server builds, so the session history routes also see the runs of runners built outside the server, such as a background worker’s.

§Example
ⓘ
let activity = adk_runner::SessionActivity::new();
let config = ServerConfig::new(loader, sessions).with_session_activity(activity.clone());
let worker_runner = Runner::builder()
    .app_name("ops")
    .agent(agent)
    .session_service(sessions)
    .session_activity(activity)
    .build()?;
Source

pub fn with_governance(self, control: GovernanceControl) -> Self

Shares control with every runner the server builds.

§Example
ⓘ
let control = adk_core::GovernanceControl::new();
let config = ServerConfig::new(loader, sessions).with_governance(control.clone());
control.freeze("incident 4012");
Source

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

Source

pub fn with_artifact_service_opt( self, artifact_service: Option<Arc<dyn ArtifactService>>, ) -> Self

Source

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

Configure a memory service for semantic search across sessions.

When set, the runner injects memory into the invocation context, allowing agents to search previous conversation content via ToolContext::search_memory().

Source

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

Configure automatic context compaction for long-running sessions.

Source

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

Configure automatic prompt-cache lifecycle management for cache-capable models.

Source

pub fn with_backend_url(self, backend_url: impl Into<String>) -> Self

Source

pub fn with_security(self, security: SecurityConfig) -> Self

Source

pub fn with_span_exporter(self, span_exporter: Arc<AdkSpanExporter>) -> Self

Source

pub fn with_allowed_origins(self, origins: Vec<String>) -> Self

Sets the browser origins allowed to call the server cross-origin; see SecurityConfig::allowed_origins.

Source

pub fn with_allowed_hosts<I, S>(self, hosts: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Sets the host names the server answers besides loopback names and IP addresses, replacing any list set before, including one in a SecurityConfig passed to with_security; see SecurityConfig::allowed_hosts.

SecurityConfig::with_allowed_hosts sets the same list the same way.

§Example
ⓘ
let config = ServerConfig::new(loader, sessions)
    .with_allowed_hosts(["agents.example.com", "api.example.com"]);
Source

pub fn with_max_body_size(self, size: usize) -> Self

Configure maximum request body size

Source

pub fn with_request_timeout(self, timeout: Duration) -> Self

Configure request timeout

Source

pub fn with_run_timeout(self, timeout: Duration) -> Self

Sets how long a request that runs an agent may take; see SecurityConfig::run_timeout.

§Example
ⓘ
let config = ServerConfig::new(agent_loader, session_service)
    .with_run_timeout(std::time::Duration::from_secs(30 * 60));
Source

pub fn with_error_details(self, expose: bool) -> Self

Sets whether error responses carry every error’s own message; see SecurityConfig::expose_error_details. Enable it for development only: an upstream or store message can name hosts, tables, accounts, or request content.

§Example
ⓘ
let config = ServerConfig::new(agent_loader, session_service).with_error_details(true);
Source

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

Configure a request context extractor for auth middleware bridging.

When set, the server invokes the extractor on each incoming request to extract authenticated identity (user_id, scopes, metadata) from HTTP headers. The extracted context flows into InvocationContext, making scopes available via ToolContext::user_scopes().

Source

pub fn with_interceptor_chain(self, chain: Arc<InterceptorChain>) -> Self

Configure an interceptor chain for A2A request/response middleware.

When set, the chain’s run_before is called before the A2A executor processes a request, and run_after is called after it completes. Interceptors can reject, short-circuit, or modify requests and responses.

§Example
ⓘ
use adk_server::a2a::interceptor::InterceptorChain;
use std::sync::Arc;

let chain = InterceptorChain::new()
    .add(my_auth_interceptor)
    .add(my_rate_limiter);

let config = ServerConfig::new(loader, session)
    .with_interceptor_chain(Arc::new(chain));
Source

pub fn with_yaml_agent_dirs(self, dirs: Vec<PathBuf>) -> Self

Configure directories containing YAML agent definitions to watch.

When the yaml-agent feature is enabled and directories are configured, the server starts a HotReloadWatcher for each directory at startup, automatically loading and hot-reloading YAML-defined agents.

Source

pub fn with_yaml_agent_dir(self, dir: impl Into<PathBuf>) -> Self

Add a single YAML agent directory to watch.

Convenience method that appends one directory to the list.

Trait Implementations§

Source§

impl Clone for ServerConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for ServerConfig

§

impl !UnwindSafe for ServerConfig

§

impl Forget for ServerConfig

§

impl Freeze for ServerConfig
where *const ArcInner<dyn AgentLoader> is !null: Freeze, PhantomData<ArcInner<dyn AgentLoader>>: Freeze, *const ArcInner<dyn SessionService> is !null: Freeze, PhantomData<ArcInner<dyn SessionService>>: Freeze, *const ArcInner<dyn ArtifactService> is !null: Freeze, PhantomData<ArcInner<dyn ArtifactService>>: Freeze, *const ArcInner<dyn Memory> is !null: Freeze, PhantomData<ArcInner<dyn Memory>>: Freeze, *const ArcInner<dyn BaseEventsSummarizer> is !null: Freeze, PhantomData<ArcInner<dyn BaseEventsSummarizer>>: Freeze, *const ArcInner<dyn CacheCapable> is !null: Freeze, PhantomData<ArcInner<dyn CacheCapable>>: Freeze, *const ArcInner<AdkSpanExporter> is !null: Freeze, PhantomData<ArcInner<AdkSpanExporter>>: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze, PhantomData<String>: Freeze, *const ArcInner<dyn RequestContextExtractor> is !null: Freeze, PhantomData<ArcInner<dyn RequestContextExtractor>>: Freeze, *const ArcInner<InterceptorChain> is !null: Freeze, PhantomData<ArcInner<InterceptorChain>>: Freeze, PhantomData<PathBuf>: Freeze, *const ArcInner<ControlState> is !null: Freeze, PhantomData<ArcInner<ControlState>>: Freeze, *const ArcInner<Mutex<HashMap<AdkIdentity, usize>>> is !null: Freeze, PhantomData<ArcInner<Mutex<HashMap<AdkIdentity, usize>>>>: Freeze,

§

impl Move for ServerConfig

§

impl Send for ServerConfig

§

impl Sync for ServerConfig

§

impl Unpin for ServerConfig

§

impl UnsafeUnpin for ServerConfig

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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: Sized + 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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