Monitor your pi coding agent sessions with Sentry
Add the official @sentry/pi extension to get full visibility into tool calls, token usage, and model costs across every pi session.
Before you start
SDKs & packages
- pi 0.87.0 or later installed and configured
- Node.js 22.19+ installed
Accounts & access
- Sentry account with a Node.js project created
Knowledge
- Basic familiarity with pi's
settings.json
1 Create a Sentry project
In Sentry, create a new project for your pi monitoring data. Go to Settings → Projects and click Create Project. Select Node.js as the platform, give it a name like pi, and copy the DSN from the project settings — you'll need it in step 3.
2 Install the extension
Install @sentry/pi with the pi install command. It's installed globally, so it covers every pi session on your machine.
Terminalpi install npm:@sentry/pi 3 Configure your DSN
Add a sentry object to pi's global settings at ~/.pi/agent/settings.json with your DSN. Set org to your organization slug to get a link to the current conversation in pi's status bar. You can also set any option with an environment variable, like SENTRY_PI_DSN, which takes priority over settings.json.
~/.pi/agent/settings.json{
"sentry": {
"dsn": "https://<your-dsn>@o<org>.ingest.sentry.io/<project-id>",
"org": "my-org",
"environment": "local"
}
}
4 Verify the setup
Start pi and run the /sentry command. It shows whether tracing is enabled and where each setting comes from, so you can confirm your DSN was picked up.
5 Explore traces in Sentry
Send a few prompts and then head to Explore > Agents in Sentry and open the Traces tab. Each prompt appears as an invoke_agent root span, and all prompts in a pi session are grouped into one conversation. Expand any trace to see chat spans for each model request, including token usage and cost, and execute_tool spans for every tool call.
That's it.
Every tool call, tracked.
You get a complete picture of how pi uses models and tools across your sessions — including token usage and costs — so you can tune it, debug it, and understand exactly what it's doing.
- Installed the @sentry/pi extension into pi
- Connected pi sessions to Sentry AI Observability
- Tracked tool calls, LLM calls, token usage, and costs per prompt
- Explored per-session conversations and traces in Sentry
Pro tips
- 💡 Set
orgin your settings to get a "Go to conversation" link in pi's status bar that opens the current session in Sentry. - 💡 Use
environmentto separate sessions, for exampleworkandpersonal. A trusted project can also set its ownenvironmentin.pi/settings.json.
Common pitfalls
- ⚠️ Putting the DSN in a project's
.pi/settings.json— it's ignored. A project can only setenvironmentand turn data collection off, so the DSN must live in~/.pi/agent/settings.jsonorSENTRY_PI_DSN. - ⚠️ Without a DSN the extension does nothing — run
/sentryin pi to confirm tracing is enabled.
Frequently asked questions
dataCollection.genAI.inputs to false to leave out prompts, system prompts, and tool arguments, and dataCollection.genAI.outputs to false to leave out responses, summaries, and tool results. You still get timings, token usage, and costs.environment to filter sessions per developer or team.What's next?
Fix it, don't observe it.
Get started with the only application monitoring platform that empowers developers to fix application problems without compromising on velocity.