Expand description
TOON (Token-Oriented Object Notation) encoding support
This module provides utilities for encoding data in TOON format, a compact, human-readable format that reduces token usage when sending structured data to LLMs.
TOON typically provides 30-60% token reduction compared to JSON, making it ideal for LLM prompts and tool descriptions.
See: https://github.com/toon-format/toon
§Example
ⓘ
use agents_core::toon::ToonEncoder;
use serde_json::json;
let encoder = ToonEncoder::default();
let data = json!({
"users": [
{"id": 1, "name": "Alice"},
{"id": 2, "name": "Bob"}
]
});
let toon_str = encoder.encode(&data).unwrap();
// Output:
// users[2]{id,name}:
// 1,Alice
// 2,BobStructs§
- Toon
Encoder - TOON encoder for converting data to token-efficient format
Enums§
- Toon
Encode Error - Error type for TOON encoding
Functions§
- format_
tool_ call_ toon - Format tool call examples in TOON format (fallback to JSON)
- tool_
schema_ to_ toon - Convert a tool schema to TOON format (fallback)