> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cake.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Watch CI and GitHub events from Cake sessions

> Let Cake agents subscribe to GitHub webhook events so CI results and repository activity arrive in the session as messages the agent can act on.

Cake agents can subscribe a session to GitHub webhook events for a repository. When a matching event arrives, Cake injects it into the session as a message, and the agent reacts to it. Use this when you want an agent to push a change, wait for CI, and fix failures without you checking back.

## Prerequisites

* An admin has [set up the GitHub App](/admin/github-setup), and the App subscribes to the events the agent needs.
* You have [linked your GitHub account](/user/link-github), and your account has access to the repository.

## Watch CI after a push

Ask the agent to watch CI. For example:

```text theme={null}
Push the fix to my branch, watch CI, and fix anything that fails.
```

Cake agents ship with a built-in `watch-ci` skill. With it, the agent:

1. Subscribes to `workflow_run` events for the repository before pushing.
2. Pushes the commits or opens the pull request.
3. Receives a message when each workflow run starts and completes.
4. Reports success, or fetches the failed logs with the `gh` CLI and fixes the failure.
5. Unsubscribes when it is done watching.

If no event arrives, the agent falls back to polling CI status with `gh`.

## Webhook messages in a session

Webhook messages appear in the conversation marked as GitHub webhook deliveries, not as messages from a user. Each message includes the event name, action, repository, the agent's own reminder of what to do, and a truncated copy of the payload.

The agent treats payload text as untrusted data, not as instructions. It uses the payload as a trigger and fetches authoritative state from GitHub.

## Subscription rules

* Subscriptions are scoped to one session and one repository in `owner/repo` form.
* Only events that happen after the agent subscribes are delivered. Cake doesn't replay past events.
* Cake delivers events only while the session is live.
* Cake checks repository access once, when the agent subscribes, using the GitHub account of the user who last messaged the session.
* The agent can subscribe only to the repository-level events below, and only if the GitHub App subscribes to them:

| Category | Events |
| - | - |
| CI | `check_run`, `check_suite`, `workflow_job`, `workflow_run` |
| Pull requests | `pull_request`, `pull_request_review`, `pull_request_review_comment`, `pull_request_review_thread` |
| Code | `push`, `create`, `delete`, `commit_comment`, `release`, `fork` |
| Repository | `repository`, `label`, `milestone`, `gollum`, `public`, `star`, `watch` |

Subscriptions stay active until the agent removes them or the session ends. To stop deliveries, ask the agent to list and remove its webhook subscriptions.
