adk-core
Core traits and types for ADK-Rust agents, tools, sessions, and events.
Overview
adk-core provides the foundational abstractions for ADK-Rust. It defines the core traits and types that all other ADK crates build upon:
- Agent trait - The fundamental abstraction for all agents
- Tool / Toolset traits - For extending agents with custom capabilities
- Llm trait - For LLM provider integrations
- Context hierarchy - ReadonlyContext → CallbackContext → ToolContext/InvocationContext
- Content / Part - Message content structures
- Event system - For streaming agent responses
- Session / State - For managing conversation context
- Error types - Unified error handling
This crate is model-agnostic and contains no LLM-specific code.
Installation
[]
= "0.1"
Or use the meta-crate:
[]
= "0.1"
Core Traits
Agent
Tool
Toolset
Llm
Key Types
Content & Part
// Message content with role and parts
let content = new
.with_text
.with_inline_data
.with_file_uri;
// Part variants
Event
// Events stream from agent execution
let event = new;
event.content // Access response content
event.actions // State changes, transfers, escalation
EventActions
Context Hierarchy
ReadonlyContext (read-only access)
├── invocation_id, agent_name, user_id, app_name, session_id
└── user_content()
CallbackContext (extends ReadonlyContext)
└── artifacts()
ToolContext (extends CallbackContext)
├── function_call_id()
├── actions() / set_actions()
└── search_memory()
InvocationContext (extends CallbackContext)
├── agent(), memory(), session()
├── run_config()
└── end_invocation() / ended()
State Management
State uses typed prefixes for organization:
| Prefix | Scope | Persistence |
|---|---|---|
user: |
User preferences | Across sessions |
app: |
Application state | Application-wide |
temp: |
Temporary data | Cleared each turn |
// Access state via session
let value = session.state.get;
session.state.set;
Callbacks
// Callback type aliases
pub type BeforeAgentCallback = .. + Send + Sync>;
pub type AfterAgentCallback = .. + Send + Sync>;
pub type BeforeModelCallback = .. + Send + Sync>;
pub type AfterModelCallback = .. + Send + Sync>;
pub type BeforeToolCallback = .. + Send + Sync>;
pub type AfterToolCallback = .. + Send + Sync>;
// Instruction providers
pub type InstructionProvider = .. + Send + Sync>;
pub type GlobalInstructionProvider = .. + Send + Sync>;
Streaming Modes
Related Crates
- adk-rust - Meta-crate with all components
- adk-agent - Agent implementations
- adk-model - LLM integrations
- adk-tool - Tool implementations
License
Apache-2.0
Part of ADK-Rust
This crate is part of the ADK-Rust framework for building AI agents in Rust.