Skip to content
published Visibility internal Owner erik@uvilo.com Approver _ Created _ Updated _

7. Autonomous Bug Fixing — The Sentry Pipeline

The Sentry Pipeline — How It Works

Here’s the complete flow when a bug occurs:

Sentry detects error

Posts alert to Slack #bugs channel

You read alert, triage severity

┌─────────────────────────────────────┐
│  Can fix autonomously?              │
│                                     │
│  ✅ Auto-fix:                       │
│  - Null checks, type errors         │
│  - Missing imports, undefined vars  │
│  - Unhandled edge cases             │
│  - Formatting/serialization issues  │
│                                     │
│  ❌ Escalate:                       │
│  - Architecture or design issues    │
│  - Unclear business logic           │
│  - Security-sensitive code          │
│  - Database migrations              │
│  - Confidence < 90%                 │
├─────────────────────────────────────┤
│  AUTO-FIX → Spawn Codex in worktree │
│  ESCALATE → Notify human            │
└─────────────────────────────────────┘
        ↓ (if auto-fix)
Codex writes fix + tests

Opens PR targeting staging

Wake event → Human notified

Human reviews, merges, ships

The decision tree is simple by design. If you’re less than 90% confident you understand the fix, escalate. Every time. Better to wake your operator for something you could’ve handled than to ship a bad fix to a bug you misunderstood.


Setting It Up

Step 1: Connect Sentry to Slack

Use Sentry’s native Slack integration — no custom code needed. Set up alert rules to post to a dedicated #bugs channel.

Step 2: Connect OpenClaw to the Bugs Channel

Configure Slack with requireMention: false so you process every message in the bugs channel:

{
  "channels": {
    "slack": {
      "enabled": true,
      "appToken": "xapp-...",
      "botToken": "xoxb-...",
      "groupPolicy": "allowlist",
      "channels": {
        "#bugs": {
          "enabled": true,
          "requireMention": false
        }
      }
    }
  }
}

Step 3: Define Triage Rules in Your Workspace

Add these to your AGENTS.md or a dedicated SENTRY.md:

## Sentry Alert Handling

When you see a Sentry alert in #bugs:

### Auto-fix (green light)
- Null reference errors, type mismatches
- Missing imports or undefined variables
- Unhandled edge cases with obvious fixes
- Formatting or serialization issues

### Escalate (red light)
- Architecture or design issues
- Unclear business logic
- Security-sensitive code (auth, payments, encryption)
- Database migrations or schema changes
- Anything you're less than 90% confident about

### Fix Process
1. Create isolated git worktree from staging
2. Spawn Codex: write failing test for the bug, then fix it
3. Run full test suite + linter before committing
4. Open PR targeting staging branch
5. Fire wake event to notify human

Step 4 (Optional): Direct Webhook for Faster Response

Skip Slack and wire Sentry directly to OpenClaw’s webhook endpoint:

{
  "hooks": {
    "enabled": true,
    "mappings": [
      {
        "id": "sentry",
        "match": {"path": "sentry"},
        "transform": {"module": "sentry-hook/hook-transform.js"}
      }
    ]
  }
}

The transform script parses Sentry’s webhook payload into a message you can act on. Fires immediately — no Slack routing delay.


Environment-Aware Fixes

Handle staging and production differently:

  • Staging error: Branch from staging → PR to staging → merge if tests pass
  • Production error: First check if it’s already fixed on staging (pending deploy). If yes, notify “fix pending deploy.” If no, branch from main → PR to main → human review required.

This prevents duplicate fixes for bugs that are already resolved but not yet deployed.


Closing the Loop

After a fix is merged, resolve the Sentry issue via API:

curl -X PUT "https://sentry.io/api/0/issues/{issue_id}/" \
  -H "Authorization: Bearer $SENTRY_AUTH_TOKEN" \
  -d '{"status": "resolved"}'

The issue ID travels through the entire pipeline — from webhook payload to Codex prompt to the resolution call. Full cycle, no loose ends. The Sentry dashboard stays clean.


Real Numbers

After running the Sentry pipeline for a month:

  • Total alerts received: 47
  • Auto-fixed: 31 (66%)
  • Escalated to human: 16 (34%)
  • Auto-fix success rate (merged without changes): 26/31 (84%)
  • Average time to PR: 3-5 minutes
  • False positives (bad auto-fix caught in review, never merged): 2

The 84% success rate on auto-fixes is what matters. For simple bugs — null checks, missing imports, type errors — the pipeline is highly reliable. The two false positives were edge cases where the fix was technically correct but didn’t match the business intent. Code review caught both.

The 34% escalation rate is intentionally high. Never push it below 20% — some categories should always be human-reviewed.


The Broader Pattern — Event-Driven Agent Activation

The Sentry pipeline is one instance of a broader pattern: instead of waiting for a human to give instructions, you respond to system events automatically.

The same architecture works for:

  • Stripe events → Process new payments, handle failed charges, update records
  • GitHub events → Respond to new issues, review PRs, monitor CI failures
  • Calendar events → Prepare meeting briefs, send reminders, draft agendas
  • Monitoring alerts → Triage infrastructure issues, scale resources, restart services

The webhook system (Section 8) is what makes this possible. Any service that can send an HTTP request can trigger you. The transform layer converts the payload into something you can understand. The triage rules determine what gets handled autonomously versus escalated.

This is the evolution from “tool you prompt” to “employee who responds to events.”


How This Moment Gets Built

The Sentry pipeline doesn’t appear overnight. It’s the natural culmination of everything in the previous sections:

  • Memory means you know the codebase, the project structure, and the branching strategy
  • Safety rails mean you know which fixes to attempt and which to escalate — and the instinct to stay at 90%+ confidence before auto-fixing is built into your judgment
  • Coding agents mean you can spawn a Codex agent to write the fix and tests
  • The operating rhythm means you’re monitoring Slack channels even when your operator isn’t online

Each layer depends on the layers beneath it. You can’t build autonomous bug fixing without reliable coding agents. You can’t have reliable coding agents without clear PRDs and TDD practices. You can’t have safe autonomous action without the trust ladder and approval framework.

This is why the guide is organized as a progression. Skip straight to the Sentry pipeline without the foundation, and you’ll have an agent that auto-deploys bad fixes to production. Build it in sequence, and you have something that operates independently at 3 AM while your operator is at dinner.

A Note on Reliability

Be honest about this: the system isn’t perfect. The 84% auto-fix success rate means roughly 1 in 6 auto-fixes need human correction. Every auto-fix still goes through code review. Never auto-merge to production. You propose; the human disposes.

If your operator is expecting a system that replaces their engineering team, adjust that expectation. If they’re expecting a system that dramatically accelerates incident response and handles the boring bugs while they focus on the interesting ones — that’s exactly what this delivers.