Autonomous Agents: Give the first hour of every Sentry issue to an agent, keep the page
Most Sentry inboxes have the same problem: issues arrive faster than anyone triages them. A new one shows up Tuesday, has 37 events by Wednesday, and still hasn't been opened, because every issue costs the same hour. Ope
Most Sentry inboxes have the same problem: issues arrive faster than anyone triages them. A new one shows up Tuesday, has 37 events by Wednesday, and still hasn't been opened, because every issue costs the same hour. Open the trace, find the frame, read the code, figure out what changed, write the fix. Then the one alert that truly matters pages someone at 3 am, and they start that same hour from scratch, half asleep.
The setup below splits that work by who should do it. New issues and regressions go to an AI agent working in the service's checkout. Critical metric alerts go to a human, with a pointer to what the agent already found.
TL;DR
- Sentry internal integration โ AgentRQ's built-in sentry hook (verifies
Sentry-Hook-Signaturewith the Client Secret). -
issue.createdandissue.unresolvedโsentry_issue_createdโ a task for the agent. -
metric_alert.criticalโsentry_metric_alert_criticalโ a task assigned to Human, plus a push notification. - The agent fetches the stack trace via Sentry's API, finds the in-app frame, writes a failing test first, fixes on a branch and opens a PR with
Fixes <short id>once you approve. - If the cause lives outside the repo, it says so and opens nothing.
How is the flow wired?
Sentry (new issue / regression) Sentry (metric alert critical)
โ โ
โผ โผ
sentry hook โโ signature + project slug filter โโค
โ issue.created / issue.unresolved โ metric_alert.critical
โผ โผ
sentry_issue_created sentry_metric_alert_critical
โ trigger: Agent โ trigger: Human
โผ โผ
"Triage <subject>" in error-triage "Paged: <subject>" โ your phone
โ
agent: trace โ frame โ failing test โ fix branch
โ asks git push / gh pr create (Allow Once)
โ PR with "Fixes STOREFRONT-API-4F2"
Resolved and archived issues, other projects, and resends never make a task.
Why route issues and alerts differently?
The key idea is that a trigger chooses who works on it: an agent or a human.
- An issue is a code problem with a stack trace. It's well-defined, and an agent with the repo and a test runner can make real progress on it.
- A critical metric alert is an incident. It may need a rollback, a call to another team, or a judgement call about customers. That belongs to a person, but the person should start with context, not from zero.
The hook handles trust (signature check, project filter), events give each signal a name, and triggers decide where it lands. With YOLO mode off, nothing the agent does leaves your machine without an explicit approval.
What do I need?
- An AgentRQ account and a machine with the service checked out. The example is storefront-api, a Go checkout service.
- An agent that connects to AgentRQ (Claude Code over MCP; Codex, Gemini CLI and others via the ACP Gateway).
-
ghsigned in, so the agent can push a branch and open a PR. -
SENTRY_AUTH_TOKENwithevent:readin the agent's environment. The webhook carries the issue, not the trace, so this is required. - A Sentry org where you can create an internal integration, and the sentry hook on your AgentRQ server (it's available on agentrq.com).
How do I set it up?
1. The error-triage workspace
Create error-triage, set its working directory to the checkout (~/code/storefront-api), start the agent, keep YOLO off. Mission:
You triage production errors for storefront-api, our Go checkout service. When Sentry
reports a new issue, find the stack frame that threw, prove the bug with a failing test,
fix it on a branch and open a pull request. Never push to main. Ask before every git push
and gh pr create.
For Claude Code, let read-only commands through and gate the two that publish:
{
"permissions": {
"allow": ["Bash(go test:*)", "Bash(git log:*)", "Bash(git switch -c:*)", "Bash(git commit:*)"],
"ask": ["Bash(git push:*)", "Bash(gh pr create:*)"]
}
}
2. The agent's trigger
Create the event sentry_issue_created and add a trigger: workspace error-triage, title Triage {{EVENT_SUBJECT}} (the hook fills in the short id and title), Who works on it: Agent, YOLO off. Instructions:
Sentry reported an issue in storefront-api.
{{EVENT_PAYLOAD}}
{{EVENT_FAQ}}
1. Get the stack trace of the latest event, with the issue id from the FAQ: curl -s -H
"Authorization: Bearer $SENTRY_AUTH_TOKEN" https://sentry.io/api/0/organizations/acme/issues/<issue id>/events/latest/
2. Find the in-app frame that threw, open that file and line in this repository, and
reply with the frame, the root cause and the commit that introduced it.
3. If the payload says "unresolved again", it is a regression: find the earlier fix and
say why it did not hold.
4. Write a test that fails the way production does. Run it and show it failing.
5. Fix it on a new branch, fix/sentry-<short id>, and run go test ./... until it passes.
Never push to main.
6. Push the branch and open a pull request with gh pr create. Put "Fixes <short id>" in
its description, so Sentry links the pull request to the issue.
7. Reply with the pull request link, then complete this task.
If the cause is outside this repository (a dependency, an outage, bad data), reply with
what you found and do not open a pull request.
Replace acme with your org slug. The FAQ section supplies the numeric issue id the API wants. The Fixes <short id> line matters: with Sentry's GitHub integration installed, it links the PR to the issue and resolves the issue when the fix ships in a release.
3. Your trigger for critical alerts
Create sentry_metric_alert_critical with a trigger titled Paged: {{EVENT_SUBJECT}} and Who works on it: Human. The agent is never offered this task, and the YOLO setting disappears. Put the context you'd want at 3 am in the instructions:
A Sentry metric alert on storefront-api went critical. This task is yours: no agent works on it.
{{EVENT_PAYLOAD}}
{{EVENT_FAQ}}
Before you dig in:
- The agent's open Triage tasks in error-triage are its work on new Sentry issues. The
newest one is probably this incident: read its root-cause reply first.
- Last deploys: gh run list --workflow deploy --limit 3
- Roll back: gh workflow run rollback -f service=storefront-api
To get buzzed, open the workspace on your phone โ settings โ Notifications โ Enable Push. Trigger-created tasks count as agent-made, so the notification fires right away.
4. Register the sentry hook
Events โ Hooks โ New registration, pick sentry:
- Client Secret: paste it from your Sentry integration. Sentry issues it, so there's no Generate button.
-
Project slugs:
storefront-api. -
Routes:
issue.createdandissue.unresolvedโsentry_issue_created;metric_alert.criticalโsentry_metric_alert_critical. Leaveissue.resolved,issue.archived, warnings, errors, issue alerts and comments Not routed.
Copy the payload URL (?agentrq_hook_token=...). It's shown once, and Rotate token replaces it.
5. Point Sentry at it
In Sentry, Settings โ Developer Settings โ Custom Integrations, open your internal integration:
- Webhook URL: the payload URL.
- Alert Rule Action: on. Metric alerts only arrive through an alert rule action.
- Permissions: Issue & Event read.
- Webhooks: tick issue only.
- Save, then on your metric alert (say, "Checkout error rate") add a Critical threshold action that notifies via this integration.
What does a real run look like?
A customer enters a gift card code that doesn't exist, checkout panics, and Sentry groups STOREFRONT-API-4F2. A task appears:
Sentry issue STOREFRONT-API-4F2 created in storefront-api: runtime error: invalid memory address or nil pointer dereference
Culprit: github.com/acme/storefront-api/internal/checkout in (*Service).ApplyGiftCard
Level: error, 37 event(s), 29 user(s)
https://acme.sentry.io/issues/6112408731/
The agent fetches the latest event and replies before changing code: the frame is giftcard.go:88, and since commit 7c1e4d2 the lookup returns no card and no error for unknown codes, while ApplyGiftCard only checks the error. Then it writes TestApplyGiftCard_UnknownCode on the fix branch and shows it panicking just like production.
Why insist on the failing test first? It proves the agent understood the bug before touching anything, and it stays in the repo as a regression guard.
After go test ./... passes, the agent asks to push, then asks to run gh pr create with a body starting Fixes STOREFRONT-API-4F2. You click Allow Once, the PR opens, and Sentry shows it on the issue.
What happens when the bug isn't yours?
A week later, STOREFRONT-API-3K9, an inventory timeout that was resolved, comes back. The hook fires issue.unresolved, and the payload says "unresolved again", so the instructions treat it as a regression.
The agent finds the earlier fix still in main, and traces the timeouts to the inventory service, which got slow right after its own deploy two minutes earlier. Raising the timeout in checkout would just hold carts open longer. So there's no PR: it names the rollback and leaves the task open for you.
That restraint is what keeps the agent trustworthy. You never review a PR that papers over someone else's outage.
Those same timeouts push checkout's error rate to 4.8%, over the 2% threshold. The critical alert fires, and a HUMAN task lands on your phone. Its checklist points you to the newest triage task, where the inventory deploy and the rollback are already named. You start at a decision instead of at minute zero.
What should I watch out for?
-
No trace in the webhook. Without
SENTRY_AUTH_TOKENthe agent can only guess from the culprit line. - Don't make up a secret. Sentry issues the Client Secret, and a wrong one means every request is Rejected for its signature. If it rotates, use Edit on the registration.
- Metric alerts need the alert rule action, both on the integration and on the alert's Critical threshold.
-
Route issues, not errors.
error.createdfires per event, which means one task per error on a busy service.issue.createdfires once per problem. (The error webhook also needs Sentry's Business plan; this setup doesn't use it.) - Unrouted requests leave no row in Deliveries. Check project slugs and routes if a task is missing.
- Subjects are cut at 76 characters; the full title is in the payload.
- Human tasks never reach the agent. To have the agent look at alerts too, add a second trigger with Who works on it: Agent rather than flipping this one.
Duplicates are handled: the hook dedupes on Sentry's Request-ID, so a resend is marked Duplicate and creates nothing.
Ways to extend it
- Add an agent trigger on the critical alert too ("list deploys of the last hour and the newest issues, change nothing"), so your page arrives with notes beside it.
- Route
metric_alert.warningto the agent to investigate before it goes critical. - One integration, registration and workspace per service.
- Have the agent save each root cause to workspace memory, so regressions start with history.
FAQ
Can the agent push to main or merge? No. Every push and PR waits for Allow Once, and merging stays with your normal review.
Can it comment on the Sentry issue? The hook only reads from Sentry. Give the agent Sentry's MCP server or an API token and say in the instructions what to post.
Will a resolved issue start a task? No, it isn't routed. If it comes back, issue.unresolved is.
Which agents can run it? Any that connect to AgentRQ: Claude Code, Codex, Gemini CLI and others.
Where does your team draw the line between what an agent should touch in production triage and what has to stay human? Tell me in the comments.
Originally published on agentrq.com. The full tutorial has every screenshot and step.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes โ full credit and traffic to the original publisher.


