Skip to main content

Installation

Or from source (monorepo):

Configuration

Set environment variables before starting your app:

Initialize tracing

Call initTracing() once at the top of your application:
That’s it. Traces are exported to Cascade in the background.

Basic instrumentation

1. Wrap your entry point with traceRun

Wrap your agent’s main execution in traceRun so every span is part of the same trace:

2. Wrap LLM clients

Wrap your OpenAI or Anthropic client for automatic LLM span tracing:

3. Wrap tools with tool

Decorate functions that the LLM calls as tools:

Multi-turn sessions

For chat-like agents, group traces under a session:
Or use traceSession as a context:

Sub-agents with traceAgent

Use traceAgent to name sub-agents within a run:

Auto-evaluation

Pass scorer names to initTracing for automatic evaluation on every trace:
For multi-turn sessions, add sessionEvals to run when the session ends:

Quick reference