# Fix a bug from an alert

Returns: A PR with checks. Starts: on an event.

Your alerting posts to a webhook trigger; an agent reproduces the failure, fixes it and opens a pull request with the checks passing.

## Best for

- On-call teams with alerts that point at code
- Failures a test can reproduce

## Uses

- A connected GitHub repository
- A Project
- An automation with a webhook trigger

## The automation

Prompt: An alert fired; its payload follows. Reproduce the failure with a test, fix it, and open a pull request. If you cannot reproduce it, say what you tried.

Trigger:

```json
{
  "kind": "webhook"
}
```

## While it works

Live stream events (`GET /o/{org}/sessions/{session}/events`):

- `thinking`: The stack trace points at retry.ts:88.
- `tool_use`: edit · retry.test.ts (reproduces it)
- `tool_result`: 1 failed
- `tool_use`: edit · retry.ts
- `tool_result`: 12 passed
- `message`: Opened a pull request with the fix and the test.

## What comes back

- `status`: completed
- `branch`: rush/fix-retry-timeout
- `pr_url`: github.com/acme/api/pull/…
- `total_cost_usd`: 0.88

## Steps

1. **Add a webhook trigger.** Create an automation with the prompt above and a `webhook` trigger. Rush shows its URL and signing secret once.
2. **Point your alerting at it.** Send the alert's payload to the trigger URL. The payload reaches the agent as untrusted data after your prompt, never as instructions.
3. **Fire a test alert.** A run starts per alert. Duplicate deliveries are deduplicated, and a busy or rate-limited automation reports why it skipped.
4. **Review the pull request.** The run opens one pull request on its own branch. When the checks do not pass, the run ends `needs_review`, never a false done.

Field names are the API's; the values are an example.
