---
title: "Bound agent execution and retries"
description: "Set explicit time, turn, or retry budgets so an agent that cannot finish returns control rather than consuming unbounded CI capacity."
url: https://starsling.dev/ci-playbooks/techniques/bounded-agent-execution
canonicalUrl: https://starsling.dev/ci-playbooks/techniques/bounded-agent-execution
---

# Bound agent execution and retries

Set explicit time, turn, or retry budgets so an agent that cannot finish returns control rather than consuming unbounded CI capacity.

## How to choose an approach

Compare the examples by repository setup, prerequisites, and risks before adopting one. Each company implemented this in its own environment; measure each change against your own baseline.

- **[DoorDash](https://starsling.dev/ci-playbooks/doordash#bounded-agent-timeouts)**: Use it when An agent or long-running step inside CI can loop without progress, and only a job-wide timeout stops it. Check before adopting: Set the soft limit from measured run times so normal runs finish untouched, and report a soft-stopped run as partial.
- **[Spotify](https://starsling.dev/ci-playbooks/spotify#agent-session-limits)**: Use it when An agent or bot job can iterate on its own, and a job-wide timeout is the only limit on a run. Check before adopting: Set the limits from your longest successful sessions. A task that needs more turns is a task to split into smaller changes. Adapted for GitHub Actions; compare the original system with yours.
- **[Stripe](https://starsling.dev/ci-playbooks/stripe#bound-agent-ci-rounds)**: Use it when Coding agents push branches and can re-run CI repeatedly while iterating on failures. Check before adopting: A round cap trades completeness for cost; the branch still goes to a human with the remaining failures visible. Adapted for GitHub Actions; compare the original system with yours.

## Apply this technique

````text
Evaluate and apply this CI technique to my repository: Bound agent execution and retries.

Set explicit time, turn, or retry budgets so an agent that cannot finish returns control rather than consuming unbounded CI capacity.

Read the technique and its source-backed company examples: https://starsling.dev/ci-playbooks/techniques/bounded-agent-execution.md

Inspect this repository’s CI workflows, build and test commands, dependencies, and recent run timings. Identify where this technique applies and explain the expected benefit using this repository’s evidence.
Measure a baseline from recent comparable runs: elapsed time, queue time, runner minutes and failures where available. If data is unavailable, say what cannot be measured.
Compare relevant company approaches, checking prerequisites, platform differences and tradeoffs. Rank applicable options by evidence, fit and measurable opportunity; do not present company results as predictions for this repo.
Recommend the smallest safe change, show what checks and fallback paths remain, and ASK ME WHICH CHANGE TO APPROVE BEFORE EDITING ANY FILES.
Only after approval, work on a new feature branch, make one reversible change, and open a reviewable pull request. Never merge or push to a default or protected branch.
Keep required checks, test coverage, deployment and release behavior intact. Validate the change and compare equivalent runs where possible; report limitations and what should be monitored after merge.
````

## How companies used this technique

Read what each company changed and follow the original sources.

### DoorDash: Give every agent in a CI gate a soft and a hard timeout

One early problem in DoorDash's review agent: the same model request could repeat over and over without advancing its turn counter, so max-turn limits never fired, and a single overall timeout still allowed one stuck agent to burn 20 minutes of tokens. DoorDash moved to tighter per-agent timeouts. The soft timeout interrupts the agent and asks it to drop anything speculative and return only verified findings; the hard timeout is the final kill switch. DoorDash's feature-flag cleanup agents each run under a one-hour hard timeout.

Evidence: Documented technique

Use it when: An agent or long-running step inside CI can loop without progress, and only a job-wide timeout stops it.

Before applying it: Set the soft limit from measured run times so normal runs finish untouched, and report a soft-stopped run as partial.

[Read more in the DoorDash playbook](https://starsling.dev/ci-playbooks/doordash#bounded-agent-timeouts)

[Primary source](https://careersatdoordash.com/blog/doordash-built-an-ai-code-reviewer-engineers-actually-listen-to/)

### Spotify: Cap an agent's turns and session retries

**Translated to GitHub Actions**

- What Spotify built: Spotify's Fleet Management loop caps a session at 10 turns and three session retries.
- Your GitHub Actions version: Cap an agent's turns per session and its session retries.

Spotify's first agentic loop for Fleet Management gave the agent a prompt and the files in scope. The agent edited files over a few turns, took in feedback from the build system on each turn, and the task ended once the tests passed or the limits were exceeded: 10 turns per session and three session retries in total. Spotify's prompt guidance for migrations asks for one change at a time, so a session stays within its context window.

Evidence: Documented technique

Use it when: An agent or bot job can iterate on its own, and a job-wide timeout is the only limit on a run.

Before applying it: Set the limits from your longest successful sessions. A task that needs more turns is a task to split into smaller changes.

GitHub Actions adaptation: Compare the source system with your own workflow before applying this translation.

[Read more in the Spotify playbook](https://starsling.dev/ci-playbooks/spotify#agent-session-limits)

[Primary source](https://engineering.atspotify.com/2025/11/context-engineering-background-coding-agents-part-2)

### Stripe: Auto-apply test fixes and cap agent CI rounds

**Translated to GitHub Actions**

- What Stripe built: After a Stripe minion pushes, Stripe runs CI and applies autofixes for failing tests, with one more local attempt before a human takes over.
- Your GitHub Actions version: Auto-apply test fixes after a push and cap an agent's CI rounds at two pushes before the branch goes to a person.

After a minion pushes, Stripe runs CI and automatically applies any autofixes for failing tests. Failures with no autofix go back to the agent for one more local attempt, and after the second push and CI run the branch goes to its human operator.

Evidence: Company-reported result or observation

Stripe gives each minion at most two rounds of CI before the branch returns to its human operator. ([Source](https://stripe.dev/blog/minions-stripes-one-shot-end-to-end-coding-agents-part-2))

Use it when: Coding agents push branches and can re-run CI repeatedly while iterating on failures.

Before applying it: A round cap trades completeness for cost; the branch still goes to a human with the remaining failures visible.

GitHub Actions adaptation: Compare the source system with your own workflow before applying this translation.

[Read more in the Stripe playbook](https://starsling.dev/ci-playbooks/stripe#bound-agent-ci-rounds)

[Primary source](https://stripe.dev/blog/minions-stripes-one-shot-end-to-end-coding-agents-part-2)

## CI optimization is continuous work.

Apply this technique yourself, or use StarSling Runners for faster GitHub Actions and optional agent-driven optimization PRs, which teams on eligible paid plans can turn on.

[Get self-improving CI](https://starsling.dev/products/runners)

## Related techniques

### [Put time limits on jobs that can hang](https://starsling.dev/ci-playbooks/techniques/bound-job-runtime)

Set job timeouts from normal run history so stalled checks release runners and produce a failure that can be investigated.

4 implementations · 4 companies (Anthropic, Mastra, Shopify, Spotify)

### [Cancel superseded pull request runs](https://starsling.dev/ci-playbooks/techniques/cancel-superseded-runs)

Free runner capacity by canceling validation that a newer commit has replaced. Keep required main-branch and release runs intact.

4 implementations · 4 companies (Anthropic, Mastra, Stripe, Uber)

### [Package once, and build full installers after merge](https://starsling.dev/ci-playbooks/techniques/package-once)

Drop the build step that packaging repeats, and build the unpacked app pull requests test.

1 implementation · 1 company (DoorDash)

## Company Playbooks

### [Anthropic](https://starsling.dev/ci-playbooks/anthropic)

Run only affected tests

### [DoorDash](https://starsling.dev/ci-playbooks/doordash)

Run build and test in parallel, sharded across CI agents

### [Linear](https://starsling.dev/ci-playbooks/linear)

Benchmark the same job on faster hardware

### [Mastra](https://starsling.dev/ci-playbooks/mastra)

StarSling runners for the slowest test workflow

### [OpenAI](https://starsling.dev/ci-playbooks/openai)

Rank CI fixes by the minutes they save

### [Ramp](https://starsling.dev/ci-playbooks/ramp)

Move a CPU-bound test suite to a faster CPU

### [Shopify](https://starsling.dev/ci-playbooks/shopify)

Let an agent iterate against one CI metric

### [Spotify](https://starsling.dev/ci-playbooks/spotify)

Build arm64 on native arm64 runners

### [Stripe](https://starsling.dev/ci-playbooks/stripe)

Run only the tests a change can reach

### [Uber](https://starsling.dev/ci-playbooks/uber)

Build the merge-queue speculations most likely to be needed

## Related guides

Implementation guides for this technique.

### [Bound runner jobs with timeouts](https://starsling.dev/best-practices/github-actions/bound-job-timeouts)

Set job and step timeouts using expected durations and failure behavior.

### [Right-size GitHub Actions runners](https://starsling.dev/best-practices/github-actions/right-size-runners)

Match runner resources to the workload and compare equivalent runs.
