Pi coding agent telemetry
Stream pi coding agent sessions into Latitude as traces with the first-party@latitude-data/pi-telemetry extension.
After setup, pi prompts appear in your Latitude project’s Traces view with model calls, prompts, responses, token usage, tool calls, and tool results.
Prerequisites
- A Latitude account with a project
- A Latitude API key from Settings → API Keys
- Your Latitude project slug from the project sidebar
piinstalled locally- Node.js available on your
PATH
Install
Run the installer:~/.pi/agent/settings.json, and writes Latitude config to ~/.pi/agent/latitude-telemetry.json.
You can also pass values directly:
Restart and verify
Restart pi so it can install and load the package. Send a prompt that uses the model or a tool, then open your Latitude project and go to Traces. The new trace should appear within a few seconds. A trace includes:- an
interactionroot span for the pi prompt llm_requestspans for model callstool_call:<name>spans for tool executionsgen_ai.input.messagesandgen_ai.output.messagesfor prompt/response reconstructiongen_ai.tool.call.argumentsandgen_ai.tool.call.resultfor tool I/O
Structural-only telemetry
By default, Latitude receives the content needed to reconstruct pi runs, including prompts, assistant responses, system instructions when available, tool arguments, and tool results. If you want trace structure without conversation or tool content, install with:Disable or uninstall
Disable the extension for one pi process:Advanced configuration
The installer stores config in~/.pi/agent/latitude-telemetry.json. Environment variables override file values:
| Variable | Description |
|---|---|
LATITUDE_API_KEY | API key used to upload traces |
LATITUDE_PROJECT or LATITUDE_PROJECT_SLUG | Project slug for X-Latitude-Project |
LATITUDE_BASE_URL | Ingest base URL, default https://ingest.latitude.so |
LATITUDE_DEBUG=1 | Print upload diagnostics |
LATITUDE_PI_NO_CONTENT=1 | Disable prompt/response/tool content capture |
LATITUDE_PI_USER_ID | Override user.id |
LATITUDE_PI_USER_EMAIL | Override user email |
LATITUDE_PI_USER_NAME | Override user display name |
LATITUDE_REDACT_ATTRIBUTES | JSON array or comma-separated custom attribute patterns to mask before export |
LATITUDE_REDACT_MASK | Mask value for custom redaction, default ****** |
--staging, --dev, or --base-url=<url> during install to target a non-production Latitude ingest endpoint.
Captured data and privacy
Full-content mode sends prompts, responses, system instructions when available, tool inputs, and tool outputs. Use--no-content for structural-only telemetry or configure custom redaction as described below.
Disable telemetry before working with sensitive material you do not want sent to Latitude. Even --no-content mode still sends structural metadata such as cwd/session identifiers, model names, tool names, timing, token usage, and user/host identity.
Custom redaction
If you want to keep content capture enabled but mask specific span attributes before they leave your machine, useredact in ~/.pi/agent/latitude-telemetry.json or the LATITUDE_REDACT_ATTRIBUTES environment variable. Redaction happens locally, after the content gate and before the OTLP export.
redact.attributes (or LATITUDE_REDACT_ATTRIBUTES) accepts an array of patterns. Each pattern can be:
- An exact attribute name —
"gen_ai.tool.call.arguments" - A regex source string —
"^gen_ai\\.(input|output)\\.messages$"(anchored match) - A
/pattern/flagsstring —"/^gen_ai\\.tool\\.call\\.(arguments|result)$/i"
redact.mask (or LATITUDE_REDACT_MASK) sets the replacement value (default: ******). Set it to "[]" to replace message arrays with an empty array instead of a string.
Via config file
Add aredact block to ~/.pi/agent/latitude-telemetry.json:
Via environment variable
Troubleshooting
No traces appear. Restart pi or run/reload, then send a new prompt. Confirm the API key and project slug are correct.
HTTP 401. The API key is missing or invalid. Re-run the installer with a valid key.
HTTP 400 about X-Latitude-Project. The project slug is missing. Re-run the installer with --project=your-project-slug.
Traces show timing but no prompt/response content. Structural-only mode is enabled. Reinstall without --no-content, or set LATITUDE_PI_NO_CONTENT=0 and reload pi.
Need diagnostics. Run LATITUDE_DEBUG=1 pi and trigger another prompt.