langwatch pistarts pi and sets up the connection on the first run. Use it on a machine you work on.langwatch instrument piwrites the same setup and exits. Use it on a machine where people start pi from a terminal, or when the telemetry must go to a team project.
Before you start
- Install pi:
npm install -g @earendil-works/pi-coding-agent - Install the LangWatch command-line tool:
npm install -g langwatch - Create an account at app.langwatch.ai, or run your own instance with
npx @langwatch/server.
Run pi through the wrapper
~/.pi/agent/extensions/langwatch-pi-telemetry.ts and says so in the terminal. Later runs find it in place and leave it alone. Everything else is unchanged: langwatch pi accepts the same flags as pi and returns the same exit code.
PI_CODING_AGENT_DIR is set, the extension goes to the extensions folder inside that
directory instead, which is where pi looks for it.Set up a machine without starting pi
langwatch instrument pi writes the connection and exits. A plain pi run on that machine then sends its telemetry to LangWatch. This is the setup for a shared machine where people start pi from a terminal, for a machine image, or for a configuration management run.
- A
pifunction in your shell start file, which applies the LangWatch settings topiruns and to no other command. The file is~/.zshrc,~/.bashrc, or~/.config/fish/config.fish. - The telemetry extension in pi’s extension folder,
~/.pi/agent/extensions/. It reads the endpoint and the key from the function’s environment, since pi has no configuration file that holds either.
pi without it gets no LangWatch settings and sends no telemetry. For those, set the variables from Manual setup in that process’s environment.
langwatch pi each time
instead.Choose where the telemetry goes
Pass one scope flag, and one only:langwatch pi --project acme-app pins the project and then starts pi. --project and --personal are LangWatch flags; LangWatch removes them from the command line before pi reads it.
Remove the setup
What you get in LangWatch
Open your personal page at/me, or open the project you pinned pi to.
- Sessions: one row per pi session, with the repository, branch and worktree it ran in.
- Traces: one trace per run, with each model call and each tool call in order.
- Cost: the amount per session and per turn, from the cost pi reports for each model call.

pi sessions in the sessions list. Each row shows the repository and branch the session ran in, the context it carried and its cost.

One pi run in the trace view. Each turn holds its model calls, with the cost of each, and its tool calls, such as bash, read and edit.
Content and privacy
The extension exports what pi’s own span tree describes: model, provider, token counts, cost, timing, and the name and outcome of each tool call. It sends no prompt text, no model response and no tool arguments or results. To control who can open a stored session, see Privacy.Troubleshooting
No telemetry arrives in LangWatch
No telemetry arrives in LangWatch
pi function is read from the shell start file when a shell begins, so a terminal that was already open does not have it.Then check that the extension exists at ~/.pi/agent/extensions/langwatch-pi-telemetry.ts, or in the extensions folder inside PI_CODING_AGENT_DIR when that is set. Run langwatch pi or langwatch instrument pi once to write it again.The wrapper reports that the extension file is not a LangWatch file
The wrapper reports that the extension file is not a LangWatch file
langwatch-pi-telemetry.ts already sits in pi’s extension folder: ~/.pi/agent/extensions/, or extensions inside PI_CODING_AGENT_DIR when that is set. LangWatch never overwrites it, and pi sessions send no telemetry while it is there. Rename or remove your file, then run langwatch pi again.The command reports that it could not write the shell start file
The command reports that it could not write the shell start file
langwatch pi each time, which needs no start
file.The telemetry goes to the wrong workspace
The telemetry goes to the wrong workspace
langwatch instrument pi --project <id-or-slug> to move it to a team project, or langwatch instrument pi --personal to move it back to your own.Authentication errors
Authentication errors
Authorization=Bearer <key>. An ingest key can write traces and no other requests, so a key that works for ingestion still fails on other endpoints.On a machine with a login, run langwatch login --device again to refresh the session.Manual setup
The extension is required: pi exports no telemetry without it. Runlangwatch instrument pi --key <ingest-key> once to write it with no login (it writes the shell function too), or langwatch ingest install pi_cli on a machine where you are signed in. Then set the variables below before you start pi. They are the ones the shell function sets.
ik-lw-…), which can create traces and no other requests. Keep a full project API key (sk-lw-…) out of the configuration of a coding agent: it can read and change your project data, and a coding agent has no use for that.
For a self-hosted instance, replace the endpoint with the address of your instance followed by /api/otel.