Tracing¶
Lerim uses OpenTelemetry for agent observability via Pydantic Logfire. Stderr logs are kept minimal -- detailed traces (model calls, tool calls, tokens, timing) go through OTel spans.
What gets traced¶
When tracing is enabled, Logfire records spans for work instrumented at startup (see What happens at startup below). The lead runtime uses the OpenAI Agents SDK (Runner.run); built-in OpenAI Agents SDK tracing is disabled in LerimOAIAgent so traces are not exported to OpenAI’s hosted tracing by default.
Typical visibility:
- DSPy LLM calls (via
logfire.instrument_dspy()) - Optional raw HTTP when
include_httpx = true(provider debugging) - Per-run LLM cost from cost tracking (where the provider exposes usage)
Each sync/maintain run also writes agent_trace.json under the run workspace for a full tool/message history (not Logfire-specific).
One-time setup¶
1. Install Logfire¶
2. Authenticate¶
This opens a browser to link your Logfire account and stores a token in
~/.logfire/.
3. Create a project¶
Choose a project name (e.g. lerim). This is where your traces will appear
in the Logfire dashboard.
Free tier
Logfire has a free tier that is sufficient for development and personal use. View your traces at logfire.pydantic.dev.
Enable tracing¶
Configuration options¶
All options live under the [tracing] section in TOML config:
| Key | Type | Default | Description |
|---|---|---|---|
enabled |
bool | false |
Enable OpenTelemetry tracing. Also toggleable via LERIM_TRACING=1 env var. |
include_httpx |
bool | false |
Capture raw HTTP request/response bodies in spans. Useful for debugging provider issues. |
include_content |
bool | true |
Include prompt and completion text in trace spans. Disable to reduce trace size. |
Sensitive data
When include_content = true (the default), prompt and completion text is
sent to Logfire. If your transcripts contain sensitive information, consider
setting include_content = false.
What happens at startup¶
When tracing is enabled, Lerim calls configure_tracing() once before any agent
is constructed. This:
- Configures Logfire with
service_name="lerim"andsend_to_logfire="if-token-present" - Instruments DSPy pipelines (
logfire.instrument_dspy()) - Optionally instruments httpx (
logfire.instrument_httpx()) ifinclude_httpx = true
Viewing traces¶
Open logfire.pydantic.dev and select your project. You'll see:
- Timeline -- DSPy and HTTP-related activity as spans (lead SDK tracing disabled; use
agent_trace.jsonin run folders for full tool turns) - Span tree -- nested spans from DSPy and optional httpx
- Token usage -- per-span token counts
- Timing -- latency for each operation
DSPy visibility
DSPy pipelines run with verbose=False in stderr, but their LLM calls
are visible in Logfire via httpx spans when include_httpx = true.