pub trait IdentitySource:
Debug
+ Send
+ Sync {
// Required method
fn current<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<AgentPrincipal, AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
// Provided methods
fn principal_for<'life0, 'life1, 'async_trait>(
&'life0 self,
agent_name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<AgentPrincipal>, AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait { ... }
fn credential<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<AgentCredential, AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
}Expand description
Core traits and types.
Always available regardless of feature flags. Includes:
Agent- The fundamental trait for all agentsTool/Toolset- For extending agents with capabilitiesSession/State- For managing conversation contextEvent- For streaming agent responsesAdkError/Result- Unified error handling Says who the running agents are, and proves it.
The runner reads the source at the start of every run, so a source backed by a
rotating workload identity (SPIFFE Workload API, a cloud metadata server) is read
fresh each time. The root agent acts as principal_for its
name, falling back to current; every other agent in the tree acts
as principal_for its name, falling back to
AgentPrincipal::derived. A principal’s
AgentId must stay the same across redeploys; the deployment belongs in
AgentPrincipal::instance.
§Example
use adk_core::{AgentId, AgentPrincipal, IdentitySource, StaticIdentitySource};
let source = StaticIdentitySource::new(
AgentPrincipal::new(AgentId::new("urn:adk:agent:billing")?).with_tenant("acme"),
);
assert_eq!(source.current().await?.id.as_str(), "urn:adk:agent:billing");
assert!(source.credential().await.is_err());Required Methods§
Sourcefn current<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<AgentPrincipal, AdkError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn current<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<AgentPrincipal, AdkError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
The principal the workload runs as; the root agent’s unless
principal_for maps it.
Provided Methods§
Sourcefn principal_for<'life0, 'life1, 'async_trait>(
&'life0 self,
agent_name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<AgentPrincipal>, AdkError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn principal_for<'life0, 'life1, 'async_trait>(
&'life0 self,
agent_name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<AgentPrincipal>, AdkError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
The principal of the agent named agent_name, when the source maps it.
The default maps no agent, so only the root agent acts as
current.
Sourcefn credential<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<AgentCredential, AdkError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn credential<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<AgentCredential, AdkError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
A credential proving the principal’s identity.
§Errors
The default returns identity.credential.unavailable.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".