<!--
Sitemap:
- [Installation](/installation): Install the Bento daemon on macOS or Linux, then write your first pipeline to run a coding agent on a GitHub, Linear, or schedule event.
- [Upgrading](/upgrading): Version-specific steps for upgrading an existing Bento install.
- [Concepts](/concepts)
- [Build your first pipeline](/tutorials/pipeline-args)
- [Target a specific issue or PR from a URL](/tutorials/url-targeting)
- [Keep state across runs](/tutorials/pipeline-state)
- [Fire a pipeline on a schedule or on demand](/tutorials/schedule-and-fire)
- [Deploy a box to Railway](/tutorials/deploy-to-railway)
- [Operate a hosted daemon](/tutorials/operate-a-hosted-daemon)
- [Configuration](/configuration): Configure the Bento daemon with daemon.yaml: service name, port, webhooks, sandboxes, knowledge base, and environment variables.
- [Members](/members)
- [Knowledge base](/knowledge-base/)
- [Method and delivery](/knowledge-base/modes): Choose how Bento retrieves knowledge (BM25, vector, or hybrid) and how it delivers that knowledge to a coding agent.
- [Config](/knowledge-base/config)
- [MCP](/knowledge-base/mcp): Give coding agents your team knowledge over MCP. The Bento daemon serves an ask_knowledge search tool and per-file resources.
- [Pipeline configuration reference](/pipelines/config): Reference for Bento pipeline YAML: triggers, agents, skills, instructions, filters, sandboxes, structured results, and outputs.
- [Filters](/pipelines/filters): Filter GitHub, Linear, and webhook events by repository, label, and other fields so only the right Bento pipelines run.
- [Workflows](/pipelines/workflows): Group related Bento pipelines with their own agents, skills, and policies in one workflow directory under .bento/workflows.
- [Model routing](/pipelines/routing): Send each Bento pipeline run to the right model with named routes, label-based routing, and credential pools.
- [Orchestration](/pipelines/orchestration): Let an orchestrator decide how to dispatch a Bento pipeline: run one agent, fan out in parallel, or call typed capabilities.
- [Retries and failover](/pipelines/retries-and-failover): How Bento keeps runs going: route failover, sandbox fallbacks, queue retries, and the circuit breaker.
- [Triggers](/triggers/): Start a Bento pipeline from a GitHub, Linear, webhook, schedule, or manual trigger. Compare the trigger types and when each one fires.
- [GitHub trigger](/triggers/github): Run a coding agent on GitHub pull request, issue, and other webhook events. Configure HMAC verification and event patterns.
- [Linear trigger](/triggers/linear): Run a coding agent on Linear issue and comment events. Configure the Linear webhook, signature verification, and Hookdeck relay.
- [Webhook trigger](/triggers/webhook): Fire a Bento pipeline from any HTTP POST to /webhooks/{name}, with bearer-token authentication declared in daemon.yaml.
- [Schedule trigger](/triggers/schedule)
- [Manual trigger](/triggers/manual): Fire any Bento pipeline on demand with bento pipeline fire, and pass typed inputs to a pipeline that runs only on request.
- [Traces](/pipelines/traces)
- [Slack](/integrations/slack)
- [Public access](/public-access): Expose the Bento daemon to GitHub webhooks through a Cloudflare Quick Tunnel or Tailscale Funnel, and compare the two options.
- [Context engineering](/context-engineering): Assemble each coding agent prompt from personas, policies, skills, and pipeline instructions. Learn which file each instruction belongs in.
- [Best practices](/best-practices)
- [Troubleshooting](/troubleshooting)
- [Architecture](/architecture/vision)
- [Workspaces](/workspaces)
- [Authentication](/authentication)
- [Identity](/identity)
- [Security](/security)
- [References](/references)
- [Changelog](/changelog): Bento release history.
- [CLI reference](/cli/)
- [Setup](/cli/setup)
- [Secrets](/cli/secrets)
- [Lifecycle](/cli/lifecycle)
- [Sandbox image](/cli/image)
- [Sandboxes](/cli/sandbox)
- [Observability](/cli/observability)
- [Diagnostics](/cli/diagnostics)
- [Pipeline](/cli/pipeline)
- [Events](/cli/events)
- [Workbench](/cli/workbench)
- [Auth](/cli/auth)
- [Knowledge](/cli/knowledge)
- [Evals](/cli/evals)
- [Bento docs: run coding agents from version-controlled pipelines](/index): Bento runs coding agents from pipelines you keep in your repository. Declare the trigger, sandbox, skill, and guardrails in YAML.
- [Runtime wrapper](/architecture/runtime-wrapper)
- [Skill evolve](/architecture/skill-evolve)
-->

# Retries and failover

Bento handles each type of failure in a different way, as the following table shows.

| Failure | What Bento does | Set in |
|---------|-----------------|--------|
| A provider reports a quota failure, an authentication failure, or a refused model | Tries the next credential, then the next route, in the same run | `routes` |
| A provider has a transient server failure | Retries the same route in the same process, up to two times | Built in |
| A sandbox is not available | Moves to the next fallback step | `sandbox.fallbacks` |
| A job fails | The queue retries it, except for a scheduled run | `queue.retry` |
| Many jobs fail in a row | The circuit breaker pauses new runs and alerts your team | `queue.circuit_breaker` |

## Fail over to another route

Bento checks authentication and tries the primary route first. Bento moves to the next route in the same run for only three failures: a quota failure, an authentication failure, or a model that the provider refuses.

```yaml
routes: [codex-high, claude-high]
```

A route with a `credential_pool` tries each credential in the pool before Bento moves to the next route.

Other failures have different results:

* A transient server failure, such as an Anthropic 529 or a dropped API socket, retries the same route up to two times. Bento does not move to the next route.
* An infrastructure failure or an unclassified failure stops the loop at once.
* An authentication failure removes the later routes that use the same runtime and credential.

`guardrails.timeout` is one deadline for all attempts. A fallback gets only the time that remains.

## Cool down a credential

A subscription cap makes that credential wait until the reset time that it reports. Concurrent runs skip it.

Bento tests a waiting credential again about every 45 minutes, so a reset time that is too long clears early. When the last credential of a runtime reaches a cap, Bento shortens the wait to 15 minutes. The runtime then recovers without an operator.

See the [routes registry](/configuration#routes) for how Bento removes a credential that fails authentication.

## Fall back to another sandbox

To use another sandbox when the first one is not available, add `fallbacks`:

```yaml
sandbox:
  backend: cloudflare
  fallbacks:
    - { backend: cloudflare, snapshot: none } # the default image of the backend
    - { lane: host } # a sandbox on the container runtime of the daemon host
```

Bento uses the next step when setup refuses the run with `snapshot_not_ready`, `snapshot_full`, or `service_unavailable`. Other failures, such as a failed agent, do not use a step.

`lane: host` still runs the agent in a sandbox. A step cannot run the agent directly on the host.

Without `fallbacks`, a declared snapshot that is not ready fails setup. Add `fallbacks` only when the run can do its work without that snapshot.

When Bento uses a step, it records a `sandbox-fallback` task, and `bento trace` shows it.

See [Fallbacks](/pipelines/config#fallbacks) for all step fields.

## Retry a job

Set the number of queue attempts in `daemon.yaml`:

```yaml
queue:
  retry:
    attempts: 3
```

A scheduled run gets one attempt. The next tick is its retry.

## Stop a failing queue

The circuit breaker pauses new runs after a number of failures in a row. It resumes after `cooldown`.

```yaml
queue:
  circuit_breaker:
    failure_threshold: 5
    stall_after: 15m
    cooldown: 5m
    escalate:
      webhook: https://ops.example.com/bento-alerts
      slack: { bot: alertBot, channel: C0123456789 }
```

If the first job after a resume fails, the breaker trips again at once and doubles `cooldown`, up to one hour. A success resets `cooldown`. To resume only by hand, set `cooldown: never`.

Some outcomes do not count toward the breaker, such as an agent timeout or a run drained on shutdown. See [Queue](/configuration#queue) for the full list.

To see why a queue is paused, or to resume it by hand, run these commands:

```bash
bento queue status
bento queue resume
```

## Restart a stalled lane

The daemon restarts itself when a queue lane stops starting jobs. The daemon sends one message to the `escalate` targets, waits until no job is active, and then exits with code 1. A service manager that restarts on failure then starts the daemon again.

`stall_after` sets how long a lane can stay stalled. The default is `15m`.

## Read what happened

Each attempt appears in the trace of the run:

```bash
bento trace TRIGGER_ID
```

Replace `TRIGGER_ID` with the ID of the trigger, such as `trg_d990d0a0`.
