Anthropic Open-Sources sentry-autofix, Using AI Agents to Reproduce and Fix Sentry Issues
Anthropic has open-sourced sentry-autofix in claude-quickstarts. It can launch a Managed Agents session for each new Sentry issue, enabling an AI agent to inspect the stack trace, write a failing test that reproduces the issue, implement a minimal fix, and push a branch. The host opens a PR and immediately revokes push access afterward. The project also mitigates prompt-injection and privilege-escalation risks through ruleset validation, credential proxying, and deny-by-default network egress restrictions. By default, it processes up to three fixes concurrently, with a budget cap of $10 per session.
Why read this
SelectedAI score 83
The project demonstrates how autonomous remediation agents can use PRs as security checkpoints while mitigating risks through permission revocation, credential isolation, and egress restrictions.
Topics
Body · AI translation
Anthropic open-sources sentry-autofix: an Agent reproduces and fixes new Sentry issues, while the host writes the repository, base branch, and Fixes link into the PR and revokes push access immediately after opening it
When a new error appears in Sentry, sentry-autofix from Anthropic’s open-source claude-quickstarts project opens a Managed Agents session for it. The Agent reads the stack trace through the Sentry MCP service and, when available, consults Seer’s root-cause analysis. It then reproduces the issue with a failing test in the mounted repository, makes a minimal fix, and pushes it to a branch. The host opens the PR: the repository, base branch, and the “Fixes SHOP-1A” line linking the request to the issue all come from the configuration and the current delivery, rather than being selected by the session. After a human reviews and merges it, Sentry marks the issue as resolved in the next release containing that merge commit.
The host does not maintain a separate database: session metadata records the corresponding issue, while the event log records how far the repair has progressed. Webhook retries do not start another repair; after the host restarts, the next delivery or npm run fix can also resume the original session. https://github.com/anthropics/claude-quickstarts/tree/main/managed-agents/sentry-autofix
# How an issue enters a session
A Sentry internal integration sends signed issue events to /webhooks/sentry. The host verifies the HMAC signature against the raw bytes, accepts only newly created issues, optionally filters by project, and immediately returns 202. The same issue is deduplicated using its short ID, so no additional session is opened if one is already running or has already finished.
AUTOFIX_MAX_ACTIVE defaults to no more than 3 concurrent repairs. Excess issues are logged and skipped, and Sentry does not redeliver them. AUTOFIX_MAX_USD defaults to $10 at list prices, and the session pauses once the limit is reached. You can also run npm run fix -- SHOP-1A directly, which follows the same path as the webhook.
# How the Agent makes repairs
The Agent completes the seven prompted steps on its own, with no human confirming each command:
1. Read the issue. Use get_sentry_resource to obtain the exception type, stack trace, recent events, and the numbers of affected events and users.
2. Ask Seer once. Treat its root cause as a hypothesis and compare it with the evidence already gathered. Seer is a paid add-on; do not retry if it errors or times out—simply note this in the PR. It is also not allowed to write code or change the issue’s status.
3. Reproduce before fixing. First run the existing tests to establish a baseline, then write a failing test that throws the same exception.
4. Make the minimal fix. Change only what the evidence requires, prioritizing correction of the faulty assumption.
5. Verify the result. Both the new test and the full test suite must pass, and any available checkers must also be run.
6. Push the branch. Create autofix/<short ID> and push it to origin; do not push to any other branch or force-push. The commit message and title must avoid verbs such as fix, close, and resolve that would close the issue.
7. Call open_pull_request once. It may be called only after the tests pass and the branch has been pushed; no more pushes are allowed after the PR is opened. The host writes the keyword that closes the issue.
If the issue cannot be reproduced, its cause lies outside the repository, it requires a product decision, or the change would be too broad, the Agent should stop and explain why rather than forcing a PR.
# The PR is the checkpoint
Sessions launched overnight by webhooks are unattended, so shell commands are automatically approved, while the sandbox can read error text that anyone may have written. The example uses four boundaries to contain injected instructions:
1. The base branch must have an active ruleset. Changes must go through a PR before being merged. Classic branch protection exempts repository administrators by default, and the token used is usually an administrator token, so it does not count. The service exits on startup if no qualifying ruleset exists.
2. The host opens the PR. The custom tool uses the host’s own GitHub token, while the repository, base branch, and Fixes line come from the configuration and webhook. Phrases that would close other issues are broken apart; branches whose commit messages contain such references, or that modify .github/, are rejected so workflows cannot run before review. A repair branch may contain at most 20 commits. Once the PR is opened, the host immediately replaces the session’s repository token, revoking push access. It checks again when the session ends; if later commits no longer qualify, or if it cannot read the branch three consecutive times, it closes the PR.
3. Credentials do not enter the sandbox. The GitHub token is injected by a git proxy, and the Sentry token by an MCP proxy; code in the session can use them but cannot read them.
4. Egress is denied by default. The environment permits access only to GitHub, package repositories, and Sentry’s MCP service; web search and scraping are disabled. On the Sentry side, only read access and Seer are exposed, so the Agent cannot mark an issue as resolved or reassign it on its own.
AI Trends