Overview
Renderers transform context fragments into different output formats suitable for various LLM prompt styles. All renderers implement the same base interface and support common options like fragment grouping.Available Renderers
XmlRenderer
Hierarchical XML with proper nesting and escaping
MarkdownRenderer
Human-readable markdown with bullet points
TomlRenderer
TOML-like configuration format
ToonRenderer
Token-efficient format with CSV-style tables
XmlRenderer
Renders fragments as XML with proper nesting and escaping.Basic Usage
Output
Handling Complex Data
- Arrays
- Nested Objects
- Multiline Text
XML Escaping
The renderer automatically escapes special XML characters:MarkdownRenderer
Renders fragments as human-readable Markdown with bullet points.Basic Usage
Output
Nested Structures
TomlRenderer
Renders fragments as TOML-like configuration format.Basic Usage
Output
Arrays and Objects
ToonRenderer
Token-Oriented Object Notation (TOON) is a compact, token-efficient format designed for LLM prompts.Key Features
- YAML-like indentation for hierarchy
- CSV-style tables for uniform object arrays
- Minimal delimiters to reduce token usage
- Automatic table detection for efficient array encoding
Basic Usage
Output
Tabular Arrays
TOON automatically detects uniform object arrays and renders them as compact tables:The header
products[3]{id,name,price}: indicates:products- array name[3]- array length{id,name,price}- field names (CSV header)
Primitive Arrays
Mixed Arrays
When arrays contain non-uniform data, TOON uses list syntax:Renderer Options
All renderers support thegroupFragments option:
Example: Fragment Grouping
Choosing a Renderer
Use XmlRenderer
When working with models that prefer structured XML (e.g., Claude with Anthropic’s prompt style)
Custom Rendering
You can create custom renderers by extending the baseContextRenderer class:
Next Steps
Domain Knowledge
Add business logic with domain fragments
User Context
Capture user-specific information
Messages
Work with conversation messages
API Reference
Complete renderer API documentation