Advanced

Advanced examples covering caching, compression, concurrency, events, retries, debugging, serialization, and migration notices.

ExampleDescription
01 Create Cultural KnowledgeMigration notice for removed cultural-knowledge APIs.
04 Manually Add CultureMigration notice for removed manual-culture APIs.
Advanced CompressionSet a context token based limit for tool call compression.
Agent SerializationSerialize and deserialize agents using to_dict/from_dict and save/load with a database.
Background ExecutionBackground execution allows you to start an agent run that returns immediately.
Background Execution StructuredCombines background execution (non-blocking, async) with Pydantic output_schema.
Basic Agent EventsStream agent events including run lifecycle, tool calls, and content output.
Cache Model ResponseExample showing how to cache model responses to avoid redundant API calls.
Cancel RunExample demonstrating how to cancel a running agent execution.
Compression EventsTest script to verify compression events are working correctly.
Concurrent ExecutionConcurrent Agent Execution with asyncio.gather.
Custom Cancellation ManagerShows how to extend BaseRunCancellationManager to implement your own.
Custom LoggingExample showing how to use a custom logger with Agno.
DebugYou can set the debug mode on the agent for all runs to have more verbose output.
Multi-Model MetricsTrack per-model token usage with memory model breakdown in metrics.details.
Culture MetricsMigration notice for removed Culture metrics; links to current agent metrics.
Session MetricsAccumulate metrics across multiple runs within a session using SessionMetrics.
Session Summary MetricsTrack session summary model token usage under the session_summary_model detail key.
Streaming MetricsCapture metrics from streaming responses using yield_run_output=True.
Tool Call MetricsTrack tool execution timing with ToolCallMetrics on each ToolExecution.
Background Execution MetricsTrack metrics for background (async) agent runs with full token and model details.
Reasoning Agent EventsCapture reasoning lifecycle and ReasoningContentDelta events from a separate reasoning stage.
RetriesExample demonstrating how to set up retries with an Agent.
Tool Call CompressionCompress tool call history to reduce context size.
Learning MachineCreate agents that learn and improve from interactions over time.
Memory ManagerUse a MemoryManager to give agents persistent memory across sessions.
Basic ReasoningAdd chain-of-thought reasoning capabilities to agents.
Reasoning With ModelUse a separate reasoning model with configurable step limits.
Basic SkillsLoad skills from a local directory with LocalSkills and use them in a code review agent.
Check StyleCheck Python code for style issues.
Commit MessageValidate or generate conventional commit messages.
SSE ReconnectionReconnect to a background agent stream after disconnection using the /resume endpoint.
Cancel Run PersistenceCancel an agent run mid-stream and verify that partial content and messages are preserved in the database.
Combined MetricsMigration notice for the removed combined-metrics recipe; links to current agent metrics.
Interchange Model: All 5 ProvidersCycles through OpenAI Chat, OpenAI Responses, Claude, Gemini, and AWS Claude.
Claude GeminiSwitch a single agent between Claude and Gemini mid-conversation with shared Postgres history.
OpenAI Chat ResponsesAlternate one agent between OpenAIChat and OpenAIResponses mid-session over shared Postgres history.
OpenAI ClaudeSwap a single agent between gpt-5.6-luna and Claude mid-session with tool-call history stored in Postgres.
OpenAI GeminiMove one conversation between gpt-5.6-luna and Gemini across turns with history persisted in Postgres.
MetricsInspect per-message, run, and session metrics after a YFinance tool call on a Postgres-backed agent.
Background Execution ConcurrencyExample demonstrating the concurrency limit for background runs.
Background Streaming ResumeExample demonstrating background streaming with disconnect and resume.
Redis Event Stream ResumeExample demonstrating cross-process streaming resume with RedisEventStream.