Triage Sentry Production Errors with an AI Agent
Sentry fills up faster than anyone reads it. A new issue lands on Tuesday, gets 37 events by Wednesday, and nobody opens it, because every issue needs the same hour: open the stack trace, find the frame, read the code, work out what changed, write the fix. Meanwhile the one alert that really matters pages someone at 3 am, and they start the same hour from zero, half awake.
This tutorial gives that hour to an agent and keeps the page for you. When Sentry groups a new issue in your service, or a resolved one comes back, an agent working in the service's checkout gets a task. It pulls the stack trace from Sentry, finds the frame that threw, proves the bug with a failing test, fixes it on a branch and opens a pull request once you approve. When the cause is outside the repository, it says so and opens nothing. When a metric alert goes critical, the task goes to you instead, with the alert and a pointer to what the agent has already found, and your phone buzzes.
There is no polling and no glue code: one hook, two events, two triggers. The screenshots come from the AgentRQ app on November 30, 2026, fed with webhooks in Sentry's own format, signed with the integration's Client Secret, the same requests the hook checks in production.
What You Build
| Piece | Setting | What it does |
|---|---|---|
| error-triage workspace | Working directory: the service's checkout. YOLO mode off | The agent that reads stack traces, fixes code and asks before it pushes |
| sentry_issue_created event | A trigger for the agent: "Triage {{EVENT_SUBJECT}}" | One task for every new issue and every regression |
| sentry_metric_alert_critical event | A trigger for a human: "Paged: {{EVENT_SUBJECT}}" | One task for you when a metric alert goes critical |
| sentry hook registration | Project slugs: storefront-api. Three routes | Checks Sentry's signature and turns its webhooks into your events |
| Sentry internal integration | Webhook URL, issue webhooks, Alert Rule Action | Sends Sentry's issues and alerts to AgentRQ |
Three ideas make it work:
- → A hook brings Sentry in. A hook checks the Sentry-Hook-Signature on every request and turns a Sentry webhook into one of your events. The built-in sentry hook does this with no code.
- → Each event gives the work to the right one. An event is a name for something that happened, and its trigger creates a task in a workspace every time it fires. A trigger picks Who works on it: the agent, or a human. New issues go to the agent. Critical alerts go to you.
- → You stay in charge of what leaves your machine. With YOLO mode off, every command the agent runs waits for your answer, so a push or a pull request never happens without you.
Before You Start
- → An AgentRQ account, and a computer where the agent will run, with a checkout of the service on it. Here that is storefront-api, a Go checkout service. See machines and the connect agents guidelines.
- → An agent that connects to AgentRQ: Claude Code over MCP, or Codex, Gemini CLI and others through the ACP Gateway.
- → The GitHub CLI on that computer, signed in with gh auth login, so the agent can push a branch and open a pull request.
- → A Sentry auth token with event:read, as SENTRY_AUTH_TOKEN in the agent's environment, so it can read an issue's stack trace. The webhook carries the issue, not the trace.
- → A Sentry organization where you can create an internal integration, and the sentry hook on your AgentRQ server. On agentrq.com it is there. Turn Sentry issues and alerts into agent tasks covers the Sentry side click by click, and what to do when the hook is not installed.
Step 1: Make the error-triage Workspace
Create a workspace named error-triage. Its mission tells the agent what it is for, every time it starts:
In its settings, set the Working Directory to the service's checkout, ~/code/storefront-api here, and start its agent. Leave YOLO mode off.
For Claude Code, the repository's .claude/settings.json can allow the commands that only read and keep asking for the two that matter:
Step 2: The Agent's Trigger for New Issues
Open Events, click + New Event, and name it sentry_issue_created. In its payload guidelines, say what it carries: "Sent by the sentry hook when Sentry groups a new issue in storefront-api, or a resolved issue comes back: the short id, title, culprit, level, counts and the Sentry link. The FAQ carries the numeric issue id."
On the event's page, click + Add Trigger. 1. error-triage gets the task. 2. Its title is "Triage {{EVENT_SUBJECT}}". The sentry hook fills {{EVENT_SUBJECT}} with the issue's short id and title, such as "Sentry STOREFRONT-API-4F2: runtime error: invalid memory address or nil pointer dereference". 3. Its instructions bring in {{EVENT_PAYLOAD}} and {{EVENT_FAQ}}, what Sentry sent.
The instructions are the agent's playbook for an error. This run used:
Put your organization's slug where this says acme. The FAQ under the payload gives the agent the numeric issue id the API needs.
Further down, 1. "Fixes
in its description", and Who works on it set to Agent with YOLO mode OFF" class="w-full">
Step 3: Your Trigger for Critical Alerts
Make a second event, sentry_metric_alert_critical: "Sent by the sentry hook when a Sentry metric alert on storefront-api goes critical: the alert, what crossed the threshold and the link to it."
Add a trigger to it for the same workspace. 1. Its title is "Paged: {{EVENT_SUBJECT}}", which becomes "Paged: Sentry metric alert critical: Checkout error rate". 2. Its instructions carry the alert and the context you want first, at 3 am, before you open a laptop:
3. Who works on it: Human. The task is created for you and waits for you. The agent is not offered it, and the YOLO setting disappears, because no agent runs anything for it.
To be told on your phone, open the error-triage workspace on the phone, then its settings, Notifications, and Enable Push. A task a trigger creates counts as made by an agent, so the phone shows "New task: Paged: Sentry metric alert critical: …" the moment Sentry fires. Notifications settings has the details.
Step 4: Register the sentry Hook
Open Events, then Hooks, and click New registration. Name it "Sentry storefront-api".
1. The built-in sentry hook. 2. The Client Secret of your Sentry internal integration, pasted. Sentry makes this secret, so there is no Generate button: copy it from the integration's page in Sentry. 3. Project slugs: storefront-api, so this registration only takes your service's issues. 4. Route issue.created and issue.unresolved to sentry_issue_created: a new issue and a regression both deserve the agent.
Further down, 1. leave issue.resolved and issue.archived Not routed. An issue someone closed is not work. 2. Route metric_alert.critical to sentry_metric_alert_critical, its own event, so it reaches you and not the agent. Leave the warning and resolved alerts, errors, issue alerts and comments Not routed for now, and 3. create the registration.
1. Copy the payload URL, which ends in ?agentrq_hook_token=. It is shown only this once. If you lose it, Rotate token makes a new one, and the old URL stops working. 2. The three routes are listed on the registration.
Step 5: Point Sentry at It
In Sentry, open the internal integration (Settings, Developer Settings, Custom Integrations) and:
- Webhook URL: the payload URL, token included.
- Alert Rule Action: on. Metric alerts reach the hook only through an alert rule's action.
- Permissions: Issue & Event, read.
- Webhooks: tick issue. Leave error and comment unticked: nothing is routed for them.
- Save Changes.
- Open your metric alert, such as "Checkout error rate", and add an action for the Critical threshold that sends a notification via the integration.
The Sentry hook guide walks through each of these screens, and what to check when no delivery arrives.
Step 6: A New Issue Becomes a Task
In this run, a customer typed a gift card code that doesn't exist, checkout panicked, and Sentry grouped a new issue, STOREFRONT-API-4F2. Sentry sent an issue webhook with the action created. The sentry hook checked the signature, saw a project it watches, and fired issue.created, which the registration routes to sentry_issue_created. The trigger did the rest.
1. One task per new issue, named after it. 2. What Sentry sent: the short id, the title, the culprit, the level, how many events and users, and the link, then a short FAQ with the project, the link and the numeric issue id.
The payload looks like this, the same lines in every issue task:
Step 7: The Agent Finds the Root Cause
The agent picked the task up, fetched the latest event from Sentry's API and replied before it touched any code. 1. The frame that threw: giftcard.go, line 88, in ApplyGiftCard. 2. Root cause, and the commit: since 7c1e4d2, the lookup returns no card and no error for an unknown code, and ApplyGiftCard only checks the error. 3. A test that fails first, on the fix branch, panicking the same way production did.
The failing test is the important part. It proves the agent understood the bug before it changed anything, and it stays in the repository so the same panic cannot come back unnoticed.
Step 8: You Approve the Pull Request
The agent fixed the code, ran go test ./... until it passed, then asked to push the branch, and waited for you. After that, it asked to open the pull request. 1. It asks before gh pr create, and shows the exact command, "Fixes STOREFRONT-API-4F2" included. 2. You say yes with Allow Once. The card also reaches your phone through notifications.
1. The pull request, with what it changes. 2. Sentry links it to the issue, because its description says "Fixes STOREFRONT-API-4F2". 3. Done, by the agent: the task moved to Recently Completed.
Step 9: A Regression the Agent Doesn't Fix
Later, STOREFRONT-API-3K9, an inventory timeout someone had resolved the week before, came back. Sentry sent issue with the action unresolved, the hook fired issue.unresolved, and the same trigger gave error-triage a second task. Its payload says "unresolved again", which the instructions treat as a regression.
1. The frame: the inventory client's Reserve call. The agent found the earlier fix still in main, and the timeouts coming from the inventory service, slow since its own deploy two minutes before. 2. Not this repository, so no pull request: a longer timeout here would only hold checkouts open longer. It named the rollback and left the task open for you.
This is the decision that keeps the agent useful. A bug in your code gets a fix. A problem somewhere else gets a diagnosis and stops there, so you never review a pull request that papers over someone else's outage.
Step 10: A Critical Alert Pages You
Those timeouts pushed checkout's error rate to 4.8%, over the alert's 2% threshold. Sentry fired the metric alert's critical action, the hook fired metric_alert.critical, and sentry_metric_alert_critical created the task you set up in Step 3.
1. Assigned to you, not the agent: it is marked HUMAN, the agent was never offered it, and with push on, your phone shows it as a new task. 2. The alert, from Sentry: what crossed the threshold, the filter, the project and the link to the alert.
You open the task, and the "Before you dig in" list sends you to the newest triage task, where the agent has already named the inventory deploy and the rollback. That is the difference between starting at minute zero and starting at a decision.
Step 11: Check Every Delivery
The registration lists what Sentry sent and what became of it, newest first. 1. A new issue: a task. 2. The critical alert: your task. 3. The same request sent again: Sentry's Request-ID was the same, so it is marked Duplicate and fires nothing. 4. A wrong secret: a request signed with another key is Rejected with "Sentry-Hook-Signature does not match the client secret". 5. The regression: a task.
What is not there matters as much. In this run Sentry also reported an issue resolved, one archived and a new issue in another project, web-storefront. None of them made a task, and none of them left a row: a request that fires no routed event is accepted and dropped.
Traps to Avoid
- → The webhook has no stack trace. Sentry's issue webhook carries the title, culprit, level, counts and link, not the frames. Without an auth token the agent can only guess from the culprit. Give it SENTRY_AUTH_TOKEN with event:read, and the issue id from the FAQ does the rest.
- → Don't generate the secret. Sentry issues the Client Secret; AgentRQ only checks it. A made-up secret means every request is Rejected for its signature. If the integration's secret changes, paste the new one with Edit on the registration.
- → Metric alerts need the alert rule action. Ticking webhooks is not enough: turn on Alert Rule Action on the integration, then add the integration as an action on the alert's Critical threshold. Without that, metric_alert.critical never fires.
- → Route issues, not errors. error.created fires for every single event, so a busy service would file a task per error. issue.created fires once per problem.
- → Unrouted requests leave no row. A resolved or archived issue, another project's issue, or a comment you did not route is dropped without a row in Deliveries. If you expected a task and see nothing, check Project slugs and the routes, then the integration's webhook settings in Sentry.
- → Long titles are cut. An event's subject stops at 76 characters with "…", so "Triage " plus a long Sentry title gets shortened in the task list. The full title is in the payload.
- → A Human task never reaches the agent. If you later want the agent to look at alerts too, add a second trigger on the same event with Who works on it: Agent, rather than switching this one.
Make It Yours
- → Let the agent pre-read the alert. Add an agent trigger on sentry_metric_alert_critical as well, with instructions such as "list the deploys of the last hour and the newest Sentry issues, reply with what changed, change nothing". Two tasks fire at once: yours, and the agent's notes next to it.
- → Route warnings to the agent. Route metric_alert.warning to an event whose trigger asks the agent to investigate before it becomes critical, and keep critical for you.
- → One workspace per service. Make one Sentry internal integration and one registration per service, each with its own Project slugs and payload URL, and point each at the workspace that holds that code.
- → Remember what broke. Ask the agent to save each root cause to workspace memory. The next regression starts with the history.
- → Fix red builds too. The same agent can take GitHub's failed CI runs: see fix a red main build with an AI agent.
FAQ
Can the agent push to main or merge? Not while it has to ask. The instructions say never, and with YOLO mode off every git push and gh pr create waits for Allow Once. Merging is your normal review.
How does the pull request show up in Sentry? Through Sentry's GitHub integration. A pull request whose description says "Fixes STOREFRONT-API-4F2" is linked to that issue, and the issue is resolved when the commit ships in a release. The sentry hook itself only reads from Sentry.
Can the agent comment on the Sentry issue instead? The hook doesn't write to Sentry, so the agent needs its own way in, such as Sentry's MCP server or the Sentry API with a token. Add a line to the instructions saying what to post.
Will a resolved issue start a task? No. issue.resolved and issue.archived are Not routed, so they fire nothing. If the issue comes back, Sentry sends unresolved, and that one is routed.
What if Sentry sends the same webhook twice? The hook uses Sentry's Request-ID header as the dedup key, so the second request is marked Duplicate and makes no second task.
Do I need a paid Sentry plan? Not for issue webhooks or alerts. Only the error webhook needs Sentry's Business plan, and this setup doesn't use it.
Which agents can run error-triage? Any that connects to AgentRQ: Claude Code, or Codex, Gemini CLI and others through the ACP Gateway.