diff --git a/docs/agent-relay/claude-code.md b/docs/agent-relay/claude-code.md index 28324ada322..7581b7e6cbe 100644 --- a/docs/agent-relay/claude-code.md +++ b/docs/agent-relay/claude-code.md @@ -162,6 +162,9 @@ pools: # Optional: release a session after this long without a user message. # Default 1h; 0 never releases. # idle_release_timeout: 1h + # Optional: how long the build can take from work order issue. + # Default 5m, between 10s and 15m. + # dispatch_deadline: 5m secretEnv: - name: CLAUDE_ENVIRONMENT_SECRET @@ -188,6 +191,9 @@ claudeCodeRunnerPools: # Optional: release a session after this long without a user message. # Default 1h; 0 never releases. # idle_release_timeout: 1h + # Optional: how long the build can take from work order issue. + # Default 5m, between 10s and 15m. + # dispatch_deadline: 5m ``` Pass `CLAUDE_ENVIRONMENT_SECRET` to the container alongside `CODER_AGENT_RELAY_CODERD_SESSION_TOKEN`, as shown in [Install with Docker](./setup.md#docker). @@ -203,10 +209,17 @@ When the pool is configured, return to [Install Agent Relay](./setup.md#step-5-i ## Build budget -Agent Relay gives each Claude Code workspace a fixed 300-second spawn budget. -The budget starts when Anthropic issues the session's work order, so time in Anthropic's queue and time waiting for a provisioner both count. -When a build misses the budget, Agent Relay returns the session to Anthropic as retryable and deletes the workspace. -The budget isn't configurable. +Each pool's `dispatch_deadline` sets the spawn budget: how long a Claude Code workspace build can take. + +- The default is `5m`, the minimum is `10s`, and the maximum is `15m`. + The value must be whole seconds. +- You can't turn off the budget, because Anthropic requires one. +- Agent Relay sends the budget to Anthropic on every poll. + If no runner starts within the budget, Anthropic offers the session again. +- The budget starts when Anthropic issues the session's work order, so time in Anthropic's queue and time waiting for a provisioner both count. +- When a build misses the budget, Agent Relay reports the failure to Anthropic, cancels the build if it's still running, and deletes the workspace. + +For templates where the image pull and build regularly take longer than 5 minutes, raise `dispatch_deadline`. To fit inside the budget: @@ -226,7 +239,7 @@ For example, a template that builds in 60 seconds needs about 12 provisione > [!WARNING] > Provisioner shortages feed themselves. -> A build that misses the budget is returned to Anthropic and its workspace is deleted, and Anthropic then sends the session again. +> A build that misses the budget fails, Agent Relay deletes its workspace, and Anthropic sends the session again. > Each late build adds a delete and a rebuild to the same provisioners. ## Network requirements diff --git a/docs/agent-relay/configuration.md b/docs/agent-relay/configuration.md index 4d3c53cba0f..69c9c2e5fd3 100644 --- a/docs/agent-relay/configuration.md +++ b/docs/agent-relay/configuration.md @@ -131,9 +131,10 @@ Use `secret_env` to keep the secret out of configuration files and Helm values. ### Claude Code pool fields -| Field | Required | Description | -|---------------------------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `claude_tag_channel_user` | No | The Coder user who owns workspaces for Claude Tag channel sessions. Set `me` for the Agent Relay service account, or the UUID of a user in the pool's organization. When it's unset, Agent Relay rejects channel sessions. Refer to [Configure Slack for Agent Relay](./slack.md). | +| Field | Required | Description | +|---------------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `claude_tag_channel_user` | No | The Coder user who owns workspaces for Claude Tag channel sessions. Set `me` for the Agent Relay service account, or the UUID of a user in the pool's organization. When it's unset, Agent Relay rejects channel sessions. Refer to [Configure Slack for Agent Relay](./slack.md). | +| `dispatch_deadline` | No | The spawn budget, from when Anthropic issues the work order to a successful build, as a duration in whole seconds such as `5m`. Defaults to `5m`, with a minimum of `10s` and a maximum of `15m`. You can't turn it off. Agent Relay also sends it to Anthropic as the time to wait for a runner. Refer to [Build budget](./claude-code.md#build-budget). | ### Cursor pool fields diff --git a/docs/agent-relay/monitoring/siem.md b/docs/agent-relay/monitoring/siem.md index 1794fa6be02..c8b8188e3ab 100644 --- a/docs/agent-relay/monitoring/siem.md +++ b/docs/agent-relay/monitoring/siem.md @@ -224,7 +224,7 @@ Some conditions, such as a stranded Cursor claim, appear only in logs. | Rate threshold | `nacked spawn hint` | Claude Code | `pool`, `retryable` | Sessions handed back to Anthropic. `retryable: false` ends the session and needs an administrator. | | Rate threshold | `failed the claim upstream, the user sees the message` | Cursor | `pool`, `retryable`, `stage` | Users saw a failure. `retryable: false` needs an administrator. `retryable: true` usually means a transient or capacity problem. | | Rate threshold | `workspace build failed, reporting retryable and deleting` | Both | `job_error` | A template or infrastructure failure, such as exhausted quota. Agent Relay deletes the workspace right away, so `job_error` might be the only record of why. | -| Rate threshold | `workspace build passed the session deadline, reporting retryable and deleting` | Both | `pool` | Builds take longer than the 300-second Claude Code budget or the Cursor pool's `dispatch_deadline`. | +| Rate threshold | `workspace build passed the session deadline, reporting retryable and deleting` | Both | `pool` | Builds take longer than the pool's `dispatch_deadline`. | | Rate threshold | `session did not finish cleanly, reporting and deleting` (`reaper`) | Both | `reason` | Runners that exited non-zero, couldn't start, stopped unexpectedly, or never started. | | Ticket | `session owner is unresolvable, nacking non-retryable` | Claude Code | `org_service_name` | A Claude user has no active Coder account in the pool's organization, or a Claude Tag channel session arrived without `claude_tag_channel_user`. | | Ticket | `request owner cannot be served, refusing the request` | Cursor | `reason` | A Cursor request has no email, no matching Coder account in the organization, or a suspended or dormant account. | diff --git a/docs/agent-relay/troubleshooting.md b/docs/agent-relay/troubleshooting.md index 20ead1d42ec..3fbdd3bb377 100644 --- a/docs/agent-relay/troubleshooting.md +++ b/docs/agent-relay/troubleshooting.md @@ -36,7 +36,9 @@ Also check the pool configuration: - An unset `secret_env` variable, or a reserved `template_parameters` name. - An `idle_release_timeout` without a unit. Claude Code values must be whole minutes, and Cursor values must be whole seconds. -- Cursor only: more than four pools on one API key, two pools on one key with the same `cursor_pool_name`, or a `dispatch_deadline` longer than `15m`. +- A `dispatch_deadline` longer than `15m`. + Claude Code values must also be whole seconds and at least `10s`. +- Cursor only: more than four pools on one API key, or two pools on one key with the same `cursor_pool_name`. ### One pool is degraded and the others are fine @@ -63,8 +65,8 @@ The workspace's build log in Coder has the full output. ### Builds time out -- Claude Code: the build plus provisioner queue time exceeded the fixed 300-second budget. - Speed up the template or add provisioners. +- Claude Code: the build time plus queue time exceeded the pool's `dispatch_deadline`, `5m` by default. + Speed up the template, raise the deadline up to `15m`, or add provisioners. - Cursor: the build exceeded `dispatch_deadline` or waited for a provisioner. Speed up the template, raise the deadline up to `15m`, use prebuilds, or add provisioners.