Workflow recipe
Triage production errors with an agent
AI error triage with a coding agent: read errors over a read-only Sentry MCP connection, write a triage note, reproduce in a failing test, then fix behind it.
Bookmark
Bookmarks are kept in your free account, so you can find this page again on any device.
Sign in to bookmarkOn this page
For AI error triage, connect your coding agent to your error tracker with read-only access, let it rank the open errors and pull the full evidence for one of them, and have it write a triage note that separates what the data shows from what it guesses. Then ask it to reproduce the error as a failing test in your repository before it changes any code, fix the code until that test passes with the rest of the suite, and keep resolving the issue in the tracker as a person’s job.
An agent with your error tracker and your code side by side is good at the tedious half of triage: reading the stack trace, mapping frames to files, checking which release and browser the error started on. The risks are specific. Error events carry text your users and attackers control (messages, URLs, form values), which then lands in the agent’s context, and an agent with write access can resolve, assign or delete issues on a guess. A fix written without a reproduction often silences the symptom with a try/except. Read-only access, a triage note with evidence, and a failing test first are the three guardrails this recipe adds.
Terminal and SentryAbout 10 min
1. Connect your error tracker with read-only access
Sentry’s MCP server groups its tools into skills you grant when you connect. Inspect Issues & Events is read-only: issues, events, traces, releases and project metadata. Seer starts Sentry’s own AI analysis, Triage Issues can resolve, assign and update issues, and Manage Projects & Teams can change projects and alerts. For this recipe grant Inspect only, and scope the connection to one organisation and project so the agent does not wander.
claude mcp add --transport http sentry https://mcp.sentry.dev/mcp/[ORG SLUG]/[PROJECT SLUG]Run /mcp, select sentry and authenticate. On Sentry’s consent screen, leave only Inspect Issues & Events selected.
codex mcp add sentry --url https://mcp.sentry.dev/mcp/[ORG SLUG]/[PROJECT SLUG]Sign in when prompted and grant only Inspect Issues & Events.
Add the server under Tools & MCP in Cursor Settings:
{ "mcpServers": { "sentry": { "url": "https://mcp.sentry.dev/mcp/[ORG SLUG]/[PROJECT SLUG]" } } }Click Connect and grant only Inspect Issues & Events.
For self-hosted Sentry, or to keep the connection on your machine, Sentry’s CLI runs the same server locally with your CLI login: sentry mcp [ORG]/[PROJECT] --skills=inspect. Whichever way you connect, ask the agent to list its Sentry tools; nothing in the list should resolve, assign, update or delete.
Your agentAbout 10 min
2. Rank the open errors and pick one
Start in your agent’s read-only or plan mode, in the repository at the deployed release. Ask for a ranked shortlist rather than “fix the top error”, so you choose what is worth the next hour.
Prefer an error that is new in the latest release, affects real users and has a stack trace into your own code. An error that only appears in a third-party script or a browser extension is rarely worth an agent’s time.
Your agentAbout 10 min
3. Pull the evidence and write a triage note
Now get everything about one issue and write it down, before anyone forms an opinion about the fix.
Read the note against the issue page in Sentry. Check the release and the counts yourself, and check that each hypothesis’s evidence is something you can see. A hypothesis with no evidence against it usually has not been tested; keep it, but do not fix on it yet.
Your agent and terminalAbout 25 min
4. Reproduce the error as a failing test
Switch the agent to edit mode and ask for a test, not a fix.
Run the test yourself and compare its failure with the stack trace in Sentry: same exception, same function, same line or close to it. A test that fails for a different reason proves nothing. If the agent cannot reproduce the error, that is a result: go back to the hypotheses and the tags (the error may need a particular browser, data shape or timing).
Your agentAbout 20 min
5. Fix it behind the test
Commit the failing test on its own, then ask for the smallest fix.
Review the diff for the shortcuts the rules forbid: new catch-all handlers, None or empty defaults that hide missing data, a changed assertion in the new test, or a fix in a different file from the one in the stack trace. Revert the fix once and check the new test fails again; if it does not, it is not testing the fix.
GitHub and SentryAbout 15 min
6. Merge through review, then resolve the issue yourself
Open the pull request with the triage note attached and get it reviewed like any other change. After it ships, resolve the issue in Sentry yourself (for example, as resolved in the next release, so it reopens if the error comes back) and check it a day later. Keeping resolution as a person’s job is the point of the read-only connection: the agent proposes, the release proves, and a human closes.
Add a line to your team’s runbook or AGENTS.md if the triage taught you something general, such as which tag usually explains your errors or which service’s errors are noise.
Check it worked
Verification checklist
0 of 7 done
When it goes wrong
If an error message contains text like “ignore previous instructions” or a link the agent wants to open, someone has put instructions into data your agent reads. This is indirect prompt injection. The read-only connection limits the damage; also keep the agent’s other tools narrow while it reads error data, and never let it run commands copied from an event.
If the agent’s fix wraps the failing line in a try/except and the test passes, the test was written to the fix rather than to the error. Go back to step 4, make the test assert the behaviour users need (a clear validation error, a correct result), and fix again.
If the stack trace points only at minified code or library internals, the agent cannot map it to your files. Upload source maps or debug symbols to Sentry for the release, or start from the tags: the endpoint, browser or customer that covers most events is often a better lead than the trace.
If the agent cannot see an issue you can see, check the connection’s organisation and project scope in the URL, and that your Sentry account has access to that project.
Variations
For a bug you can already reproduce, skip the tracker and use debug a bug with an AI agent, which starts from the reproduction. For failures in CI rather than production, see fix failing CI with an agent.
Other error and observability tools follow the same pattern if they offer an MCP server or an API: grant read-only scopes, write the triage note, reproduce, then fix. Datadog users can look at the Datadog APM skill. During an active incident, the Incident response skill structures the communication around the fix.
Related guides
Connect MCP servers to your agent covers adding, scoping and checking servers in each client, and MCP security risks explains why read-only access matters when an agent reads data other people wrote. The Systematic debugging skill keeps the agent to hypothesis, evidence and test.
Outcome and tools
- Outcome
- A triage note for one production error with its evidence, a test that reproduces it, and a pull request whose fix makes that test pass, with the agent kept read-only.
- For
- Developers
- Variants for
- Claude Code, Codex, Cursor
Related
- Debug a bug with an AI agent: reproduce it, then fix it
Write the bug report, have the agent reproduce it as a failing test, find the root cause, apply a small fix and prove it.
- Fix a failing CI run with a coding agent
It reads the GitHub Actions logs, explains the cause and fixes it, with stop rules so it never loops or weakens tests.
- Connect MCP servers to Claude Code, Codex and Cursor
Add local and remote MCP servers to Claude Code, Codex and Cursor, choose the right scope, sign in with OAuth and check which tools actually loaded.
- Indirect prompt injection
Prompt injection delivered through content the model reads, such as a web page, email or tool output, not typed by the user.
- Least privilege
Granting an agent or tool only the permissions and data access its task requires, and nothing more, so a mistake does less damage.