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

Event Data

  • agent_end events carry event.data["status"]: "completed", "failed", or "cancelled".
  • event.agent_name is None for an unnamed agent; fall back to event.node_id ("agent:Agent") when grouping events by agent.
  • llm_request / llm_response arrive from async runs (astart/achat) as well as sync runs (start/chat).

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

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