Pydantic Logfire

Mirror completed Claude Code, Codex, and Cursor turns as nested OpenTelemetry traces.

thirdeye is local-first, but it can optionally mirror each captured Claude Code, Codex, or Cursor session to Pydantic Logfire. Export is live once enabled; there is no separate batch-export step.

Enable export

If you installed thirdeye with Homebrew, Logfire support is already included. Save the gateway key for your project:

thirdeye logfire enable
# Logfire write token (gateway key): [hidden input]
thirdeye logfire status

For a Python installation, install the optional dependency first:

pip install 'thrdi[logfire]'
thirdeye logfire enable
# Logfire write token (gateway key): [hidden input]
thirdeye logfire status

thirdeye logfire enable securely prompts for the token; it does not accept the token as a command-line option, so the value is not exposed in shell history. You can also enable it as part of the interactive thirdeye setup wizard or from Settings in thirdeye ui. All three paths persist the same settings in ~/.thirdeye/config.yaml. The gateway key selects the Logfire destination.

To stop exporting while keeping the saved key:

thirdeye logfire disable

Query and visualize your traces

Logfire export is only the first half of the workflow. Connect your coding agent to Logfire's hosted MCP server to ask questions about captured sessions or maintain dashboards without copying telemetry into the prompt by hand:

  • Query Logfire with MCP — connect Claude Code, Codex, or Cursor and investigate sessions with natural-language questions backed by SQL.
  • Build coding-agent dashboards — turn validated MCP queries into reusable Logfire dashboards for cost, throughput, outcomes, and tool behavior.

The Logfire write token saved by thirdeye and the MCP connection are separate credentials. MCP normally uses browser OAuth; never reuse the saved write token as an MCP credential.

Trace shape

Each thirdeye session becomes one Logfire trace, searchable by gen_ai.conversation.id and separated by claude, codex, or cursor service name.

  • session is a stable root shared by turns exported from separate hook processes.
  • agent-turn spans carry the user prompt, final response, turn status, and real timestamps.
  • chat <model> spans carry OpenTelemetry GenAI message, provider, model, and token-usage attributes.
  • Tool spans nest under the specific model call that requested them, with paired start/end times.
  • Permission requests sit directly under their turn as point-in-time spans.
  • Subagent turns nest recursively and preserve their own model and tool-call trees.

Claude Code can produce multiple model-call spans within one turn. Codex reconstructs its model calls and tool children from the completed rollout, deduplicating cumulative token reports before calculating usage. Cursor reconstructs generations from IDE or CLI hooks, pairing shell and MCP callbacks while recording file operations, generic tools, and completed subagents.

Runtime behavior

The hook never waits for Logfire. It writes a small local job and starts a detached worker, which builds and flushes the span tree in the background. A slow or unreachable endpoint therefore does not add network latency to agent tool calls.

Each turn is claimed atomically so duplicate or replayed hooks do not export the same tree twice. Failed exports release the claim so a later retry can recover. Logfire errors are written to thirdeye's capture error log and are never emitted as hook output.

Privacy and scrubbing

Enabling Logfire sends captured prompts, responses, tool inputs/results, and span attributes to the Logfire project the gateway key belongs to. Leave it disabled if traces must remain exclusively local.

Logfire's default secret scrubbing remains active. thirdeye exempts only the default match for the literal word session, because that word commonly appears in legitimate agent content and paths.

Troubleshooting

  • package installed : False. Python installs need pip install 'thrdi[logfire]' in the same environment that provides thirdeye. Homebrew installs already include it.
  • active : False. Export is active only when the package is installed, export is enabled, and a token is saved.
  • A turn does not appear immediately. Export begins after a turn is completed or interrupted, and the detached worker may take a moment to flush.
  • Export failures. Run thirdeye usage errors to inspect the capture audit log without exposing failures to the agent hook.