pub struct ServerConfig {Show 13 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 governance: GovernanceControl,
pub session_activity: SessionActivity,
}server only.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>>§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>, ) -> ServerConfig
Sourcepub fn with_session_activity(self, activity: SessionActivity) -> ServerConfig
pub fn with_session_activity(self, activity: SessionActivity) -> ServerConfig
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) -> ServerConfig
pub fn with_governance(self, control: GovernanceControl) -> ServerConfig
pub fn with_artifact_service( self, artifact_service: Arc<dyn ArtifactService>, ) -> ServerConfig
pub fn with_artifact_service_opt( self, artifact_service: Option<Arc<dyn ArtifactService>>, ) -> ServerConfig
Sourcepub fn with_memory_service(
self,
memory_service: Arc<dyn Memory>,
) -> ServerConfig
pub fn with_memory_service( self, memory_service: Arc<dyn Memory>, ) -> ServerConfig
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,
) -> ServerConfig
pub fn with_compaction( self, compaction_config: EventsCompactionConfig, ) -> ServerConfig
Configure automatic context compaction for long-running sessions.
Sourcepub fn with_context_cache(
self,
context_cache_config: ContextCacheConfig,
cache_capable: Arc<dyn CacheCapable>,
) -> ServerConfig
pub fn with_context_cache( self, context_cache_config: ContextCacheConfig, cache_capable: Arc<dyn CacheCapable>, ) -> ServerConfig
Configure automatic prompt-cache lifecycle management for cache-capable models.
pub fn with_backend_url(self, backend_url: impl Into<String>) -> ServerConfig
pub fn with_security(self, security: SecurityConfig) -> ServerConfig
pub fn with_span_exporter( self, span_exporter: Arc<AdkSpanExporter>, ) -> ServerConfig
Sourcepub fn with_allowed_origins(self, origins: Vec<String>) -> ServerConfig
pub fn with_allowed_origins(self, origins: Vec<String>) -> ServerConfig
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) -> ServerConfig
pub fn with_allowed_hosts<I, S>(self, hosts: I) -> ServerConfig
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) -> ServerConfig
pub fn with_max_body_size(self, size: usize) -> ServerConfig
Configure maximum request body size
Sourcepub fn with_request_timeout(self, timeout: Duration) -> ServerConfig
pub fn with_request_timeout(self, timeout: Duration) -> ServerConfig
Configure request timeout
Sourcepub fn with_run_timeout(self, timeout: Duration) -> ServerConfig
pub fn with_run_timeout(self, timeout: Duration) -> ServerConfig
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) -> ServerConfig
pub fn with_error_details(self, expose: bool) -> ServerConfig
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>,
) -> ServerConfig
pub fn with_request_context( self, extractor: Arc<dyn RequestContextExtractor>, ) -> ServerConfig
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().
Trait Implementations§
Source§impl Clone for ServerConfig
impl Clone for ServerConfig
Source§fn clone(&self) -> ServerConfig
fn clone(&self) -> ServerConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto 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<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<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<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<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<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<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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 moreimpl<T> MaybeSend for Twhere
T: Send,
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.