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: GovernanceControlKill 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: SessionActivityThe 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
impl ServerConfig
pub fn new( agent_loader: Arc<dyn AgentLoader>, session_service: Arc<dyn SessionService>, ) -> Self
Sourcepub fn with_session_activity(self, activity: SessionActivity) -> Self
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()?;Sourcepub fn with_governance(self, control: GovernanceControl) -> Self
pub fn with_governance(self, control: GovernanceControl) -> Self
pub fn with_artifact_service( self, artifact_service: Arc<dyn ArtifactService>, ) -> Self
pub fn with_artifact_service_opt( self, artifact_service: Option<Arc<dyn ArtifactService>>, ) -> Self
Sourcepub fn with_memory_service(self, memory_service: Arc<dyn Memory>) -> Self
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().
Sourcepub fn with_compaction(self, compaction_config: EventsCompactionConfig) -> Self
pub fn with_compaction(self, compaction_config: EventsCompactionConfig) -> Self
Configure automatic context compaction for long-running sessions.
Sourcepub fn with_context_cache(
self,
context_cache_config: ContextCacheConfig,
cache_capable: Arc<dyn CacheCapable>,
) -> Self
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.
pub fn with_backend_url(self, backend_url: impl Into<String>) -> Self
pub fn with_security(self, security: SecurityConfig) -> Self
pub fn with_span_exporter(self, span_exporter: Arc<AdkSpanExporter>) -> Self
Sourcepub fn with_allowed_origins(self, origins: Vec<String>) -> Self
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.
Sourcepub fn with_allowed_hosts<I, S>(self, hosts: I) -> Self
pub fn with_allowed_hosts<I, S>(self, hosts: I) -> Self
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"]);Sourcepub fn with_max_body_size(self, size: usize) -> Self
pub fn with_max_body_size(self, size: usize) -> Self
Configure maximum request body size
Sourcepub fn with_request_timeout(self, timeout: Duration) -> Self
pub fn with_request_timeout(self, timeout: Duration) -> Self
Configure request timeout
Sourcepub fn with_run_timeout(self, timeout: Duration) -> Self
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));Sourcepub fn with_error_details(self, expose: bool) -> Self
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);Sourcepub fn with_request_context(
self,
extractor: Arc<dyn RequestContextExtractor>,
) -> Self
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().
Sourcepub fn with_interceptor_chain(self, chain: Arc<InterceptorChain>) -> Self
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));Sourcepub fn with_yaml_agent_dirs(self, dirs: Vec<PathBuf>) -> Self
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.
Sourcepub fn with_yaml_agent_dir(self, dir: impl Into<PathBuf>) -> Self
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§
Auto Trait Implementations§
impl !RefUnwindSafe for ServerConfig
impl !UnwindSafe for ServerConfig
impl Forget for ServerConfig
impl Freeze for ServerConfigwhere
*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 ServerConfigwhere
Arc<dyn AgentLoader>: Send,
Arc<dyn SessionService>: Send,
Arc<dyn ArtifactService>: Send,
Arc<dyn Memory>: Send,
Arc<dyn BaseEventsSummarizer>: Send,
Arc<dyn CacheCapable>: Send,
Arc<AdkSpanExporter>: Send,
RawVecInner: Send,
Arc<dyn RequestContextExtractor>: Send,
Arc<InterceptorChain>: Send,
Arc<ControlState>: Send,
Arc<Mutex<HashMap<AdkIdentity, usize>>>: Send,
impl Sync for ServerConfigwhere
Arc<dyn AgentLoader>: Sync,
Arc<dyn SessionService>: Sync,
Arc<dyn ArtifactService>: Sync,
Arc<dyn Memory>: Sync,
Arc<dyn BaseEventsSummarizer>: Sync,
Arc<dyn CacheCapable>: Sync,
Arc<AdkSpanExporter>: Sync,
RawVecInner: Sync,
Arc<dyn RequestContextExtractor>: Sync,
Arc<InterceptorChain>: Sync,
Arc<ControlState>: Sync,
Arc<Mutex<HashMap<AdkIdentity, usize>>>: Sync,
impl Unpin for ServerConfigwhere
Arc<dyn AgentLoader>: Unpin,
Arc<dyn SessionService>: Unpin,
Arc<dyn ArtifactService>: Unpin,
Arc<dyn Memory>: Unpin,
Arc<dyn BaseEventsSummarizer>: Unpin,
Arc<dyn CacheCapable>: Unpin,
Arc<AdkSpanExporter>: Unpin,
*const u8 is !null: Unpin,
Arc<dyn RequestContextExtractor>: Unpin,
Arc<InterceptorChain>: Unpin,
Arc<ControlState>: Unpin,
Arc<Mutex<HashMap<AdkIdentity, usize>>>: Unpin,
impl UnsafeUnpin for ServerConfigwhere
*const ArcInner<dyn AgentLoader> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn AgentLoader>>: UnsafeUnpin,
*const ArcInner<dyn SessionService> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn SessionService>>: UnsafeUnpin,
*const ArcInner<dyn ArtifactService> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn ArtifactService>>: UnsafeUnpin,
*const ArcInner<dyn Memory> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Memory>>: UnsafeUnpin,
*const ArcInner<dyn BaseEventsSummarizer> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn BaseEventsSummarizer>>: UnsafeUnpin,
*const ArcInner<dyn CacheCapable> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn CacheCapable>>: UnsafeUnpin,
*const ArcInner<AdkSpanExporter> is !null: UnsafeUnpin,
PhantomData<ArcInner<AdkSpanExporter>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
*const ArcInner<dyn RequestContextExtractor> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn RequestContextExtractor>>: UnsafeUnpin,
*const ArcInner<InterceptorChain> is !null: UnsafeUnpin,
PhantomData<ArcInner<InterceptorChain>>: UnsafeUnpin,
PhantomData<PathBuf>: UnsafeUnpin,
*const ArcInner<ControlState> is !null: UnsafeUnpin,
PhantomData<ArcInner<ControlState>>: UnsafeUnpin,
*const ArcInner<Mutex<HashMap<AdkIdentity, usize>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Mutex<HashMap<AdkIdentity, usize>>>>: UnsafeUnpin,
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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