Expand description
Thread-safe schema cache for tool parameter schemas. Schema normalization cache for LLM provider adapters.
Binds one adapter to each cache and stores normalized schemas by content hash,
avoiding redundant normalization without allowing one adapter’s result to be
returned for another adapter. The hash ignores the order object keys were
written in, so when serde_json/preserve_order is enabled — where insertion
order would otherwise change the key — one schema built two different ways is
one entry.
§Example
use adk_core::{GenericSchemaAdapter, SchemaCache};
use serde_json::json;
use std::sync::Arc;
let cache = SchemaCache::for_adapter(Arc::new(GenericSchemaAdapter));
let schema = json!({"type": "object", "properties": {"name": {"type": "string"}}});
// First call normalizes and caches
let result1 = cache.normalize(&schema);
// Second call returns cached value without re-normalizing
let result2 = cache.normalize(&schema);
assert_eq!(result1, result2);Structs§
- Schema
Cache - A thread-safe cache for normalized JSON Schemas.