Skip to content

Factories > Managed self-hosting

Self-hosted worker reference

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, YAML config fields, and telemetry environment variables for the oz-agent-worker daemon’s managed backends. For installation, see Install and run the worker.


The following flags are available when starting the worker.

  • --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 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.
  • --config-file — Path to a YAML config file. There is no automatic config-file discovery.
  • --backend — Backend type: docker (default), kubernetes, direct, or command. See Managed: Kubernetes, Managed: Direct, and External orchestrators for backend-specific setup.
  • --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.
  • --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.

Rootful Linux Docker example with all flags

Section titled “Rootful Linux Docker example with all flags”
Terminal window
export DOCKER_SOCKET_GID="$(stat -c '%g' /var/run/docker.sock)"
docker run \
--group-add "$DOCKER_SOCKET_GID" \
-v /var/run/docker.sock:/var/run/docker.sock \
-e WARP_API_KEY="$WARP_API_KEY" \
warpdotdev/oz-agent-worker \
--worker-id "prod-runner-1" \
--log-level debug \
--no-cleanup \
--max-concurrent-tasks 4 \
--idle-on-complete 10m \
-v /opt/shared-cache:/cache:ro \
-e NPM_TOKEN=your_token \
-e GITHUB_TOKEN

For complex setups, use a YAML config file instead of (or in addition to) CLI flags. Pass it with --config-file:

Terminal window
oz-agent-worker --api-key "$WARP_API_KEY" --config-file config.yaml

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.

worker_id: "my-worker"
cleanup: true
max_concurrent_tasks: 4
idle_on_complete: "10m"
backend:
docker:
volumes:
- "/data:/data:ro"
- "/cache:/cache"
environment:
- name: NPM_TOKEN
value: "your_token"
- name: GITHUB_TOKEN # inherits from host environment
worker_id: "k8s-worker"
max_concurrent_tasks: 4
backend:
kubernetes:
namespace: "warp-oz"
default_image: "my-registry.io/dev-image:latest"
unschedulable_timeout: "2m"
pod_template:
nodeSelector:
kubernetes.io/os: linux
containers:
- name: task
resources:
requests:
cpu: "2"
memory: 4Gi
env:
- name: GITHUB_TOKEN
valueFrom:
secretKeyRef:
name: my-k8s-secret
key: github-token
worker_id: "direct-worker"
max_concurrent_tasks: 2
backend:
direct:
workspace_root: "/var/lib/oz/workspaces"
oz_path: "/usr/local/bin/oz"
setup_command: "/opt/scripts/setup.sh"
teardown_command: "/opt/scripts/teardown.sh"
environment:
- name: MY_VAR
value: "hello"
worker_id: "command-worker"
backend:
command:
dispatch_command: "python3 /opt/warp/dispatch.py"
cancel_command: "python3 /opt/warp/cancel.py"
dispatch_timeout: "60s"
environment:
- name: OZ_DISPATCH_URL
value: "https://runtime.internal.example.com/agent-runs"
- name: OZ_CANCEL_URL
value: "https://runtime.internal.example.com/agent-runs/cancel"
- name: OZ_DISPATCH_AUTH_HEADER

Top-level:

  • 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 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.
  • 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). 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.
  • environment — List of environment variables with name and optional value. If value is omitted, the variable is inherited from the host.

backend.kubernetes:

  • 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 — 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_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.
  • 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-<harness>-cli-sidecar and warp-<harness>-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 for versioned CLI-only mapping behavior.
  • 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 in seconds for finished Jobs when cleanup is enabled. 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. 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, where one compute unit is max(1 vCPU, 2 GiB memory) rounded up.
    • 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.
  • 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, 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, 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 (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.


Configure OpenTelemetry metrics, tracing, and per-task log collection with environment variables on the worker process or container:

  • 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 and worker.collectTaskLogs instead of setting these variables manually. See Monitoring for the full setup guide, metric catalog, Helm values, and sample PromQL queries.


Once a worker is running, route cloud agent runs to it with the --host flag or its equivalents. See Routing runs to self-hosted workers for examples across the CLI, schedules, integrations, the API, and the web UI.