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 JSON Schema utility functions.
§Schema Utilities
Shared utility functions for normalizing JSON Schema documents across
multiple LLM provider adapters. Each function operates on serde_json::Value
via mutable references for in-place transformation and recurses into nested
schemas (properties, items, additionalProperties, allOf, anyOf, oneOf, etc.).
These utilities are independently unit-testable and composable — each adapter selects which transforms to apply and in what order.
§Example
use serde_json::json;
use adk_core::schema_utils;
let mut schema = json!({
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"name": { "type": "string" }
}
});
schema_utils::strip_schema_keyword(&mut schema);
assert!(schema.get("$schema").is_none());Functions§
- add_
implicit_ object_ type - Adds
"type": "object"whenpropertiesexists without atypefield. - collapse_
combiners - Collapses
anyOf/oneOfarrays to the first non-null sub-schema. - collapse_
type_ arrays - Collapses type arrays to the first non-null type string.
- convert_
const_ to_ enum - Converts
constvalues to single-elementenumarrays. - enforce_
nesting_ depth - Enforces a maximum nesting depth for object schemas.
- merge_
all_ of - Merges
allOfarrays by combining all sub-schemas into a single schema. - resolve_
refs - Resolves
$refreferences by inlining the referenced sub-schema from a definitions map. - strip_
conditional_ keywords - Removes conditional keywords (
if,then,else) from the schema and all nested sub-schemas. - strip_
null_ from_ enum - Removes JSON
nullvalues fromenumarrays in the schema and all nested sub-schemas. - strip_
schema_ keyword - Removes the
$schemakeyword from the schema and all nested sub-schemas. - strip_
unsupported_ formats - Removes
formatvalues not in theallowedlist from the schema and all nested sub-schemas. - truncate_
tool_ name - Truncates a tool name to at most
max_bytesbytes, preserving valid UTF-8.