Skip to main content

Module schema_cache

Module schema_cache 

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 Thread-safe schema cache for tool parameter schemas. Schema normalization cache for LLM provider adapters.

Caches normalized schemas keyed by a content hash of the serialized JSON, avoiding redundant normalization when the same tool schema is encountered across multiple requests.

§Example

use adk_core::{SchemaCache, SchemaAdapter, GenericSchemaAdapter};
use serde_json::json;

let cache = SchemaCache::new();
let adapter = GenericSchemaAdapter;
let schema = json!({"type": "object", "properties": {"name": {"type": "string"}}});

// First call normalizes and caches
let result1 = cache.get_or_normalize(&schema, &adapter);

// Second call returns cached value without re-normalizing
let result2 = cache.get_or_normalize(&schema, &adapter);
assert_eq!(result1, result2);

Structs§

SchemaCache
A thread-safe cache for normalized JSON Schemas.