diff --git a/src/content/docs/factories/self-hosting/reference.mdx b/src/content/docs/factories/self-hosting/reference.mdx index 9c01087eb..c3aa5c3fd 100644 --- a/src/content/docs/factories/self-hosting/reference.mdx +++ b/src/content/docs/factories/self-hosting/reference.mdx @@ -1,11 +1,11 @@ --- title: Self-hosted worker reference description: >- - Complete reference for the oz-agent-worker daemon — CLI flags and config - file schema for the Docker, Kubernetes, Direct, and Command backends. + Look up CLI flags, YAML config fields, and telemetry variables for + oz-agent-worker across Docker, Kubernetes, Direct, and Command backends. --- -Look up CLI flags and YAML config fields for the `oz-agent-worker` daemon's [managed backends](/factories/self-hosting/#managed-architecture). For installation, see [Install and run the worker](/factories/self-hosting/managed-docker/#install-and-run-the-worker). +Look up CLI flags, YAML config fields, and telemetry environment variables for the `oz-agent-worker` daemon's [managed backends](/factories/self-hosting/#managed-architecture). For installation, see [Install and run the worker](/factories/self-hosting/managed-docker/#install-and-run-the-worker). --- @@ -15,21 +15,25 @@ The following flags are available when starting the worker. ### Required -* `--worker-id` — A string identifying this worker. This is the value you pass to `--host` when routing tasks. Choose something meaningful for your team (e.g., `prod-runner-1` or `ci-worker`). Multiple workers can share the same ID for load balancing. -* `--api-key` or `WARP_API_KEY` env var — Your [self-hosted worker API key](/agents/cli/oz-cli/api-keys/#creating-a-self-hosted-worker-api-key) for team authentication. When running via Docker, pass it as `-e WARP_API_KEY="..."`. When running the binary directly, use `--api-key` or the environment variable. +* `--worker-id` — A string identifying this worker. Required via `--worker-id` or `worker_id` in the YAML config file. This is the value you pass to `--host` when routing tasks (e.g., `prod-runner-1` or `ci-worker`). Multiple workers can share the same ID for load balancing. +* `--api-key` or `WARP_API_KEY` env var — Your [self-hosted worker API key](/agents/cli/oz-cli/api-keys/#creating-a-self-hosted-worker-api-key) for team authentication. When running via Docker, pass it as `-e WARP_API_KEY="..."`. When running the binary directly, use `--api-key` or the environment variable. Authentication is configured via CLI flag or environment variable only and has no YAML key. ### Optional -* `--config-file` — Path to a YAML [config file](#config-file). CLI flags take precedence over config file values. +* `--config-file` — Path to a YAML [config file](#config-file). There is no automatic config-file discovery. * `--backend` — Backend type: `docker` (default), `kubernetes`, `direct`, or `command`. See [Managed: Kubernetes](/factories/self-hosting/managed-kubernetes/), [Managed: Direct](/factories/self-hosting/managed-direct/), and [External orchestrators](/factories/self-hosting/external-orchestrators/) for backend-specific setup. -* `--log-level` — Log verbosity. One of `debug`, `info`, `warn`, `error`. Defaults to `info`. -* `--no-cleanup` — Keep task containers, Kubernetes Jobs, or workspace directories after execution instead of removing them. For Direct tasks that use per-task workspaces, this also skips `teardown_command`. Useful for debugging failed tasks. -* `--target-dir` — Shared working directory for all Direct backend tasks. When set, the worker does not create or remove per-task workspace directories. This flag overrides `backend.direct.target_dir` in the config file. -* `-v` / `--volumes` — Mount host directories into task containers (Docker backend only). Format: `HOST_PATH:CONTAINER_PATH` or `HOST_PATH:CONTAINER_PATH:MODE` (where MODE is `ro` or `rw`). Can be specified multiple times. -* `-e` / `--env` — Set environment variables for tasks. Format: `KEY=VALUE` (explicit value) or `KEY` (pass through from host environment). Can be specified multiple times. -* `--max-concurrent-tasks` — Maximum number of tasks to run concurrently. Defaults to `0` (unlimited). When set, additional tasks wait until a slot is available. -* `--one-shot` — Exit after one accepted task succeeds, fails, or is cancelled. Supported only by the Direct backend and forces `max_concurrent_tasks` to `1`. -* `--idle-on-complete` — How long to keep the `oz` process alive after a task's conversation finishes, allowing follow-up interactions via session sharing. Uses duration format (e.g. `45m`, `10m`, `0s`). Defaults to `45m` when the task has no `config.idle_timeout_minutes` value. A task-level value takes precedence; runs created directly through the Agent API default to 10 minutes. See [Configure the completion timeout](/factories/self-hosting/external-orchestrators/#configure-the-completion-timeout). +* `--log-level` — Log verbosity. One of `debug`, `info`, `warn`, `error`. Defaults to `info`. CLI-only (no YAML equivalent). +* `--no-cleanup` — Keep task containers, Kubernetes Jobs, or workspace directories after execution instead of removing them. For Direct tasks that use per-task workspaces, this also skips `teardown_command`. Omitting this flag does not override YAML `cleanup: false`. +* `--target-dir` — Shared working directory for all Direct backend tasks. When set, the worker does not create or remove per-task workspace directories, and disables per-task isolation and standby sandbox support. Overrides `backend.direct.target_dir`. +* `-v` / `--volumes` — Mount host directories into task containers (Docker backend only). Format: `HOST_PATH:CONTAINER_PATH` or `HOST_PATH:CONTAINER_PATH:MODE` (where MODE is `ro` or `rw`). Can be specified multiple times. Concatenates with `backend.docker.volumes` from the config file. +* `-e` / `--env` — Set environment variables for tasks. Format: `KEY=VALUE` (explicit value) or `KEY` (pass through from host environment). Can be specified multiple times. Overrides same-name entries from the backend's YAML `environment`. +* `--max-concurrent-tasks` — Maximum number of tasks to run concurrently. Defaults to `0` (unlimited). Overrides YAML `max_concurrent_tasks` only when nonzero. +* `--max-prewarmed-sandboxes` — Maximum number of standby sandboxes to hold at once. Must be non-negative. Defaults to `0` (shares the `max_concurrent_tasks` limit). Overrides YAML `max_prewarmed_sandboxes` only when nonzero. +* `--one-shot` — Exit after one accepted task succeeds, fails, or is cancelled. Supported only by the Direct backend, forces `max_concurrent_tasks` to `1`, and disables standby sandboxes. Omitting this flag does not override YAML `one_shot: true`. +* `--collect-task-logs` or `OZ_COLLECT_TASK_LOGS` env var — Collect per-task logs when requested by the server. Defaults to `true`. Set `--collect-task-logs=false` or `OZ_COLLECT_TASK_LOGS=false` to opt out. Precedence: `--collect-task-logs` > `OZ_COLLECT_TASK_LOGS` > YAML `collect_task_logs`. +* `--idle-on-complete` — How long to keep the `oz` process alive after a task's conversation finishes, allowing follow-up interactions via session sharing. Uses duration format (e.g., `45m`, `10m`, `0s`). Defaults to `45m` when the task has no `config.idle_timeout_minutes` value. A task-level value takes precedence; runs created directly through the Agent API default to 10 minutes. See [Configure the completion timeout](/factories/self-hosting/external-orchestrators/#configure-the-completion-timeout). +* `--kubernetes-qps` — Kubernetes API requests per second (`float32`, non-negative). Defaults to `0` (uses the client-go default of `5`). Overrides YAML `backend.kubernetes.clientConfig.QPS` only when nonzero. +* `--kubernetes-burst` — Kubernetes API request burst (`int`, non-negative). Defaults to `0` (uses the client-go default of `10`). Overrides YAML `backend.kubernetes.clientConfig.burst` only when nonzero. Worker IDs starting with `warp` are reserved and cannot be used. The worker refuses to start if `--worker-id` begins with `warp`. @@ -67,7 +71,14 @@ For complex setups, use a YAML config file instead of (or in addition to) CLI fl oz-agent-worker --api-key "$WARP_API_KEY" --config-file config.yaml ``` -CLI flags always take precedence over config file values. +CLI flags generally override config file values, with these exceptions: + +* `--max-concurrent-tasks`, `--max-prewarmed-sandboxes`, `--kubernetes-qps`, and `--kubernetes-burst` override YAML only when nonzero. To replace a configured limit with `0`, edit the YAML file. +* Omitting `--no-cleanup` or `--one-shot` does not override YAML `cleanup: false` or `one_shot: true`. +* Docker `-v` / `--volumes` concatenates with YAML `backend.docker.volumes` instead of replacing it. +* `--collect-task-logs` overrides `OZ_COLLECT_TASK_LOGS`, which overrides YAML `collect_task_logs`. + +Unknown YAML keys are rejected, except inside the raw Kubernetes `pod_template` and `preflight_resources` blocks. ### Docker backend config @@ -151,16 +162,18 @@ backend: **Top-level:** -* `worker_id` — Worker identifier (same as `--worker-id` flag). +* `worker_id` — Worker identifier (required via `worker_id` or `--worker-id`). Values starting with `warp` are reserved. * `cleanup` — Whether to clean up after tasks. Defaults to `true`. Set to `false` to keep containers/workspaces for debugging (equivalent to `--no-cleanup`). -* `max_concurrent_tasks` — Maximum concurrent tasks. Defaults to unlimited. -* `one_shot` — Exit after one accepted Direct backend task reaches a terminal state. Defaults to `false` and forces `max_concurrent_tasks` to `1` when enabled. -* `idle_on_complete` — Duration to keep the `oz` process alive after task completion (e.g. `"45m"`, `"0s"`). Task-level timeout values take precedence; see [Configure the completion timeout](/factories/self-hosting/external-orchestrators/#configure-the-completion-timeout). +* `max_concurrent_tasks` — Maximum concurrent tasks. Defaults to `0` (unlimited). +* `max_prewarmed_sandboxes` — Maximum standby sandboxes to hold at once. Non-negative integer; defaults to `0` (shares `max_concurrent_tasks`, or unlimited when both are `0`). Supported by Docker, Kubernetes, and Direct (except in `target_dir` or `one_shot` mode); unsupported by Command. +* `one_shot` — Exit after one accepted Direct backend task reaches a terminal state. Defaults to `false`, forces `max_concurrent_tasks` to `1`, and disables standby sandboxes. +* `collect_task_logs` — Whether to collect per-task logs when requested by the server. Defaults to `true`. +* `idle_on_complete` — Duration to keep the `oz` process alive after task completion (e.g., `"45m"`, `"0s"`). Task-level timeout values take precedence; see [Configure the completion timeout](/factories/self-hosting/external-orchestrators/#configure-the-completion-timeout). * `backend` — Backend configuration block. Only one backend (`docker`, `kubernetes`, `direct`, or `command`) may be specified. **`backend.docker`:** -* `volumes` — List of volume mounts (same format as `-v` flag). +* `volumes` — List of volume mounts (same format as `-v` flag). CLI `-v` / `--volumes` values append to this list. * `image_pull_policy` — Pull policy for task and sidecar images. One of `Always`, `Never`, or `IfNotPresent`. Defaults to `Always`. Requires worker release `v2026-08-20-16-38-31` or newer. * `sidecar_image` — Image reference for the Warp Agent sidecar mounted at `/agent`. It does not affect additional sidecars. Requires worker release `v2026-08-28-21-43-14` or newer. * `sidecar_image_mappings` — Map of Warp sidecar repositories (without a tag or digest) to mirrored image references, for example `docker.io/warpdotdev/warp-claude-acp-sidecar: "registry.internal/claude-acp"`. Applies to every assigned sidecar. Cannot be combined with `sidecar_image`. See [Pulling self-hosted images from a private registry](/factories/self-hosting/private-container-registry/). @@ -168,57 +181,68 @@ backend: **`backend.kubernetes`:** -* `namespace` — Kubernetes namespace for task Jobs. Defaults to `default`. Selects the namespace inside the chosen cluster; does not choose the cluster. +* `namespace` — Kubernetes namespace for task and preflight Jobs. Defaults to `default`. Selects the namespace inside the chosen cluster; does not choose the cluster. * `kubeconfig` — Path to an explicit kubeconfig file. If omitted, the worker uses in-cluster config when running inside Kubernetes, or falls back to the default kubeconfig loading rules. +* `clientConfig.QPS` — Kubernetes API requests per second (`float32`, non-negative). `0` or omitted uses the client-go default of `5`. Note exact key casing (`clientConfig`, uppercase `QPS`). +* `clientConfig.burst` — Kubernetes API request burst (`int`, non-negative). `0` or omitted uses the client-go default of `10`. Note exact key casing (`clientConfig`, lowercase `burst`). * `default_image` — Default Docker image for task Jobs when the run has no Warp environment image. Precedence: Warp environment image > `default_image` > `ubuntu:22.04`. Set this to skip creating a Warp environment when all your tasks use the same base image. * `image_pull_policy` — Pull policy for task, sidecar, and preflight images. One of `Always`, `Never`, or `IfNotPresent`. Defaults to `IfNotPresent`. -* `use_image_volumes` — Use native image volumes instead of root init containers. Defaults to `false` and requires cluster and runtime support. +* `use_image_volumes` — Controls native Kubernetes image volumes for sidecar mounts. When omitted, the worker runs a startup probe Job to detect cluster and runtime support and falls back to root init containers on failure. Set to `true` to require native image volumes (failing startup if the probe fails), or `false` to skip the probe and always copy sidecars with root init containers. Read-write sidecars still use root init containers even when image volumes are enabled. * `preflight_image` — Startup preflight Job image. Defaults to `busybox:1.36`. Override this if your cluster only allows pulling from an internal or allowlisted registry. -* `preflight_resources` — CPU and memory requests and limits for startup preflight containers. -* `sidecar_image` — Image reference that replaces the Warp Agent sidecar mounted at `/agent`. +* `preflight_timeout` — Positive Go duration bounding each startup preflight wait (e.g., `"5m"`). Defaults to `15s`. In automatic `use_image_volumes` mode, the image-volume probe and any legacy fallback each get this timeout. +* `preflight_resources` — Kubernetes `ResourceRequirements` (CPU and memory requests and limits) for startup preflight containers. Defaults to requests `10m` CPU / `16Mi` memory and limits `100m` CPU / `64Mi` memory. +* `sidecar_image` — Image reference that replaces the Warp Agent sidecar mounted at `/agent`. Cannot be combined with `sidecar_image_mappings`. * `sidecar_image_mappings` — Map of Warp sidecar repositories (without a tag or digest) to mirrored image references. Applies to every assigned sidecar. Cannot be combined with `sidecar_image` or `coding_cli_sidecars`. See [Pulling self-hosted images from a private registry](/factories/self-hosting/private-container-registry/). * `coding_cli_sidecars` — Legacy map of harness names such as `claude` or `codex` to coding CLI sidecar images. A bare harness key maps both the `warp--cli-sidecar` and `warp--acp-sidecar` repositories to that image, so the agent runs the harness over a terminal (PTY). To use the Agent Client Protocol (ACP), replace this option with explicit ACP repository keys in `sidecar_image_mappings`, such as `docker.io/warpdotdev/warp-claude-acp-sidecar`. See [Images to mirror](/factories/self-hosting/private-container-registry/#images-to-mirror) for versioned CLI-only mapping behavior. -* `setup_command` — Shell command to run before each task. -* `teardown_command` — Shell command to run after each task completes. -* `extra_labels` — Map of additional labels to add to task Jobs and Pods. +* `setup_command` — Shell command run via `/bin/sh -c` in a `setup` init container in `/workspace` before the task container starts. Write `KEY=VALUE` lines to `$OZ_ENVIRONMENT_FILE` to pass variables to the agent. +* `teardown_command` — Shell command run via `/bin/sh -c` as the task container's `preStop` lifecycle hook. Because `preStop` runs on container termination, it is not a guaranteed post-success hook. +* `extra_labels` — Map of additional labels to add to task Jobs and Pods. Worker identity labels are applied last. * `extra_annotations` — Map of additional annotations to add to task Jobs and Pods. * `active_deadline_seconds` — Maximum task Job lifetime (Kubernetes `activeDeadlineSeconds`). The worker has no default; the Helm chart defaults `kubernetesBackend.activeDeadlineSeconds` to eight hours. -* `ttl_seconds_after_finished` — Retention period for failed or orphaned Jobs. Defaults to 24 hours when cleanup is enabled. -* `workspace_size_limit` — Size limit for the workspace `emptyDir` volume (e.g., `10Gi`). +* `ttl_seconds_after_finished` — Retention period in seconds for finished Jobs left behind by the worker, including failed and orphaned Jobs. Successful Jobs are deleted immediately. Defaults to `86400` (24 hours); ignored when `cleanup: false`. +* `workspace_size_limit` — Size limit for the workspace `emptyDir` volume (e.g., `10Gi`). Cannot be combined with `task_volume` or `workspace_volume`. +* `task_volume` — Provisions a dedicated generic ephemeral PVC for each task pod instead of an `emptyDir` workspace. Requires dynamic volume provisioning for the chosen `StorageClass`, and adds a root `prepare-workspace` init container to every task pod (the namespace must admit root init containers). Cannot be combined with `workspace_size_limit`. Subfields: + * `base_size` — Required positive Kubernetes quantity (e.g., `"32Gi"`). + * `size_per_compute_unit` — Optional non-negative Kubernetes quantity added once per compute unit of the task container. Requested disk size is `base_size + size_per_compute_unit × count`, where `count` is `max(ceil(CPU / 1 vCPU), ceil(memory / 2 GiB))` using the task container's resource requests (or limits where a request is absent) after run-shape overrides (for example, 8 vCPU and 32 GiB counts as 16 units). + * `storage_class` — Optional dynamically provisioned `StorageClass` name. Defaults to the cluster default `StorageClass`. + * `paths` — Optional list of clean, absolute, non-overlapping paths in the task container backed by the volume. Defaults to `["/workspace"]` and must include `/workspace` when set. Rejects `/oz-task-volume` (reserved) and any path that overlaps a sidecar mount. +* `workspace_volume` — Compatibility alias for `task_volume` with the same subfields. Setting both `task_volume` and `workspace_volume` is an error. * `unschedulable_timeout` — How long a task Pod can stay unschedulable before the worker fails the task. Defaults to `10m`, which leaves time for node autoscaling. Set to `0s` to disable. * `pod_template` — Raw Kubernetes PodSpec YAML merged with the worker's required fields at runtime. Use this to configure task pod scheduling, `serviceAccountName`, `imagePullSecrets`, `nodeSelector`, `tolerations`, resources, and environment variables (including `valueFrom.secretKeyRef` for Kubernetes Secrets). Define a container named `task` to customize the main task container directly; otherwise the worker appends its own. **`backend.direct`:** * `workspace_root` — Directory where per-task workspaces are created. Defaults to `/var/lib/oz/workspaces`. -* `target_dir` — Shared directory used as the working directory for every task. When set, the worker does not create or remove per-task workspace directories. +* `target_dir` — Shared directory used as the working directory for every task. When set, the worker does not create or remove per-task workspace directories, and disables per-task workspace isolation and standby sandbox support. * `oz_path` — Path to the oz CLI binary. If omitted, the worker looks up `oz` in `PATH`. -* `setup_command` — Shell command to run before each task. Receives `OZ_WORKSPACE_ROOT`, `OZ_RUN_ID`, `OZ_ENVIRONMENT_FILE`, and `OZ_WORKER_BACKEND` as environment variables. -* `teardown_command` — Shell command to run after each task completes. +* `setup_command` — Shell command to run before each task. Receives `OZ_WORKSPACE_ROOT`, `OZ_RUN_ID`, `OZ_ENVIRONMENT_FILE`, and `OZ_WORKER_BACKEND`, each also exposed under a `WARP_`-prefixed alias (`WARP_WORKSPACE_ROOT`, `WARP_RUN_ID`, `WARP_ENVIRONMENT_FILE`, `WARP_WORKER_BACKEND`). For standby sandboxes, hooks receive `WARP_PREWARMED_SANDBOX_ID` (no `OZ_` alias) instead of run ID variables. +* `teardown_command` — Shell command to run after each task completes. Receives the same `OZ_*` and `WARP_*` variables (except `OZ_ENVIRONMENT_FILE` and `WARP_ENVIRONMENT_FILE`) plus `GIT_CONFIG_GLOBAL` pointing to the task's isolated Git config. * `environment` — List of environment variables (same format as the Docker backend). **`backend.command`:** * `dispatch_command` — Required shell command that accepts a JSON task payload on standard input and hands the task to an external runtime. * `cancel_command` — Optional shell command invoked when a dispatched task is cancelled. -* `dispatch_timeout` — Maximum runtime for the dispatch command. Defaults to `60s`. +* `dispatch_timeout` — Maximum runtime for the dispatch command (Go duration, e.g., `"60s"` or `"2m"`). Unset or non-positive values default to `60s`. * `environment` — Environment variables for the dispatch and cancellation commands. Task credentials remain in the standard-input payload. Only one backend can be configured at a time. Specifying more than one of `docker`, `kubernetes`, `direct`, and `command` in the same config file is an error. --- -## Metrics configuration +## Telemetry configuration -Configure OpenTelemetry metrics with environment variables on the worker process or container: +Configure OpenTelemetry metrics, tracing, and per-task log collection with environment variables on the worker process or container: -* `OTEL_METRICS_EXPORTER` — Exporter to use: `prometheus`, `otlp`, `console`, or `none`. When unset, the worker uses the OpenTelemetry autoexport default, OTLP. Set it to `none` to disable metrics initialization. +* `OTEL_METRICS_EXPORTER` — Metrics exporter to use: `prometheus`, `otlp`, `console`, or `none`. When unset, the worker uses the OpenTelemetry autoexport default, OTLP. Set it to `none` to disable metrics initialization. +* `OTEL_TRACES_EXPORTER` — Opt-in trace exporter (for example, `otlp`). Unlike `OTEL_METRICS_EXPORTER`, leaving this unset or setting `none` disables tracing. * `OTEL_EXPORTER_PROMETHEUS_HOST` — Bind address for the Prometheus exporter. Defaults to `localhost`. Set to `0.0.0.0` when running in Docker or Kubernetes. * `OTEL_EXPORTER_PROMETHEUS_PORT` — Port for the Prometheus exporter. Defaults to `9464`. * `OTEL_EXPORTER_OTLP_ENDPOINT` — OTLP collector endpoint (e.g., `http://otel-collector.observability.svc:4318`). * `OTEL_EXPORTER_OTLP_PROTOCOL` — OTLP protocol: `http/protobuf` (default) or `grpc`. +* `OZ_COLLECT_TASK_LOGS` — Controls server-requested per-task log collection. Defaults to `true`. Set to `false` to opt out (overridden by `--collect-task-logs`; overrides YAML `collect_task_logs`). -When deploying with the Helm chart, use the `metrics.*` values instead of setting these variables manually. See [Monitoring](/factories/self-hosting/monitoring/) for the full setup guide, metric catalog, Helm values, and sample PromQL queries. +When deploying with the Helm chart, use the `metrics.*` values and `worker.collectTaskLogs` instead of setting these variables manually. See [Monitoring](/factories/self-hosting/monitoring/) for the full setup guide, metric catalog, Helm values, and sample PromQL queries. ---