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

# CI Fixes

> Twill automatically detects and fixes CI failures on pull requests it creates

When a CI check fails on a Twill-created pull request, the agent automatically investigates and pushes a fix.

<Frame>
  <img src="https://mintcdn.com/twill/lDT9bWmueiookMD7/images/auto-fix-ci.jpg?fit=max&auto=format&n=lDT9bWmueiookMD7&q=85&s=3020af2bd0dd5db7530118e9ff7f5e7b" alt="CI fix workflow showing agent detecting and fixing a failed check" width="1852" height="558" data-path="images/auto-fix-ci.jpg" />
</Frame>

## How It Works

1. **GitHub sends a webhook** when a check run completes with a failure
2. **Twill identifies the task** by matching the branch name to an active task
3. **Agent reads the CI logs**, identifies the cause, and pushes a fix
4. **CI runs again** on the new commit

The agent posts a comment on the PR when it starts investigating:

> 🔧 CI check `build` failed. I'm investigating the issue and will push a fix shortly. (Attempt 1/3)

## Loop Prevention

To avoid infinite fix loops, Twill limits itself to **3 fix attempts** per CI failure. The counter resets after 24 hours.

If the agent can't fix the issue after 3 attempts, it stops and leaves the PR for human review.

## Requirements

Auto Fix CI only triggers for:

* Pull requests created by Twill's bot
* Tasks that are still in progress (not completed or cancelled)
* Check runs that completed with a `failure` conclusion
