Skip to main content

Module identity

Module identity 

Source
Expand description

Core traits and types.

Always available regardless of feature flags. Includes:

  • Agent - The fundamental trait for all agents
  • Tool / Toolset - For extending agents with capabilities
  • Session / State - For managing conversation context
  • Event - For streaming agent responses
  • AdkError / Result - Unified error handling Typed identity primitives for app, user, session, and invocation. Typed identity primitives for ADK-Rust.

This module provides strongly-typed wrappers for the identity values used throughout the ADK runtime: application names, user identifiers, session identifiers, and invocation identifiers.

§Identity Layers

ADK distinguishes three identity concerns:

  • Auth identity (RequestContext): who is authenticated and what scopes they hold.
  • Session identity (AdkIdentity): the stable (app, user, session) triple that addresses a conversation session.
  • Execution identity (ExecutionIdentity): session identity plus the per-invocation invocation_id, branch, and agent_name.

§Validation Rules

All leaf identifiers (AppName, UserId, SessionId, InvocationId) enforce the same validation:

  • Must not be empty.
  • Must not contain null bytes (\0).
  • Must not exceed MAX_ID_LEN bytes (512).
  • Characters like :, |, /, and @ are allowed — validation does not couple to any backend’s internal key encoding.

§Examples

use adk_core::identity::{AdkIdentity, AppName, ExecutionIdentity, InvocationId, SessionId, UserId};

let identity = AdkIdentity::new(
    AppName::try_from("weather-app").unwrap(),
    UserId::try_from("tenant:alice@example.com").unwrap(),
    SessionId::generate(),
);

let exec = ExecutionIdentity {
    adk: identity,
    invocation_id: InvocationId::generate(),
    branch: String::new(),
    agent_name: "planner".to_string(),
};

Structs§

AdkIdentity
The stable session-scoped identity triple: application name, user, and session.
AppName
A typed wrapper around the logical application name used in session addressing.
ExecutionIdentity
The per-invocation execution identity, built from a stable AdkIdentity plus invocation-scoped metadata.
InvocationId
A typed wrapper around a single execution or turn identifier.
SessionId
A typed wrapper around a logical session identifier.
UserId
A typed wrapper around a logical user identifier.

Enums§

IdentityError
Error returned when a raw string cannot be converted into a typed identifier.

Constants§

MAX_ID_LEN
Maximum allowed length for any identity value, in bytes.