Fix a failing CI build
Let an agent fix code and retry until your test command passes.
Download all files. Extract into a dedicated directory, run npm install, then adapt outpost.config.ts using Installation. The commands below identify the scripts to run.
Write the script
Section titled “Write the script”Save the files shown in the tabs next to the configuration from Installation. The entry script keeps one sandbox open so the agent’s edits and your test command use the same files.
The repository needs a failing npm test and a lockfile for npm ci.
Allocation and cleanup stay with the entry point. The loop keeps the attempt and its check together so their sequence is visible.
Run the script
Section titled “Run the script”Run the verification loop, then inspect the commits on its branch. The script prints the status, the number of rounds and token usage, and exits with an error if the workflow fails.
Understand the steps
Section titled “Understand the steps”perform(context) ties the agent’s usage and cancellation to the workflow, so its tokens count against budget. timeoutMs bounds each round.
| Outcome | result.status | result.errors | Exit code |
|---|---|---|---|
| A check accepts the round | "done" | Empty | 0 |
| The fourth check rejects | "failed" | LoopTaskExhausted, with feedback | 1 |
| Tokens or attempts run out | "failed" | WorkflowBudgetExceeded | 1 |
| The agent or a command throws | "failed" | The thrown error | 1 |
result.unwrap() throws a WorkflowFailure for every row but the first. A token limit also stops the agent that is running.
Adapt the example
Section titled “Adapt the example”| Variation | Change |
|---|---|
| Another agent | Pass a fallback agent as agent: createFallbackAgent([claude, codex], { on: ["quota", "unavailable"] }) switches on a usage limit or an outage. |
| Run it in CI | Use an unattended credential, name the branch per run (`outpost/fix-ci-${process.env.GITHUB_RUN_ID}`), then git push origin that branch. |
| Stricter check | Add npm run lint or a typecheck after the tests, or ask a reviewer agent from check (Verification loops). |
| Cloud sandbox | Replace sandboxProvider with a Vercel or Daytona provider. Commits come back to the branch on the host. |
API: createSandbox · defineLoopTask · defineAgentTask · WorkflowBudget · LoopTaskExhausted · WorkflowFailure.

