Skip to main content
Send agent events to any destination - HTTP endpoints, databases, cloud services, or your own systems.
PraisonAI uses a protocol-driven design. Implement 3 methods and your sink works with any agent.

Quick Start

1

Create Your Sink

Implement 3 methods: emit(), flush(), close()
2

Connect to Agent

Use trace_context() to capture all agent events

How It Works

The Protocol

Your sink must implement 3 methods. That’s it!
ContextTraceSink is a backward-compatible alias for ContextTraceSinkProtocol.

Example Sinks

Send events to a remote HTTP endpoint with batching.
Store events in SQLite database for later analysis.
Print events to console for debugging.

Event Types

EventDescription
session_startSession begins
session_endSession ends
agent_startAgent starts
agent_endAgent finishes
agent_handoffAgent hands off
message_addedMessage added
tool_call_startTool starts
tool_call_endTool finishes
llm_requestLLM request sent
llm_responseLLM response received
memory_storeMemory stored
memory_searchMemory searched
knowledge_addKnowledge added
knowledge_searchKnowledge searched

Event Data

Architecture

Best Practices

Buffer Events

Batch events before sending to reduce network calls

Handle Errors

Sink errors are caught silently - tracing never crashes agents

Use trace_context

Automatic cleanup even if exceptions occur

Thread Safety

Use locks if your sink is accessed from multiple threads

Zero Overhead

When tracing is disabled, there’s zero performance impact:

API Reference

ContextTraceEmitter

trace_context

Built-in Sinks

SinkPurpose
ContextNoOpSinkDoes nothing (zero overhead)
ContextListSinkCollects events in memory (testing)
ContextTraceWriterWrites to JSONL files (in praisonai)

CLI Commands

Use the CLI to manage traces:

Context Replay

Debug agent execution step-by-step

Observability

20+ provider integrations

Observability Hooks — Third-party sink plugins

Register sinks via the praisonai.observability_sinks entry-point group