Agency

Getting started

Run one native coding agent that writes a Python function, checks it with assertions, and returns a summary. The native harness is included with Agency.

Prerequisites

The example explicitly uses sandboxconfig(gpu_passthrough=False), so no GPU or GPU container toolkit is required. ZFS, CRIU, and agency setup-host are optional checkpoint features and are unnecessary here.

Install from source

git clone https://github.com/agency-project/agency.git
cd agency
uv sync --locked --python 3.12
uv run python -c 'import agency; print(agency.__file__)'

Run the remaining commands from this directory. uv sync installs this checkout as the local project and resolves dependencies from uv.lock. The distribution and import package are both named agency, as specified in pyproject.toml. Use this source installation; an unqualified pip install agency is not verified to install this repository. A fork or an already cloned checkout can use the same sync command from its root.

Credentials and first run

Export a key in the shell that will run Python:

export OPENAI_API_KEY="your-api-key"
export OPENAI_MODEL="gpt-6-luna"
uv run python examples/quickstart.py

OPENAI_MODEL is optional and defaults to the value above. The script reads the key at execution time and passes it explicitly to llmconfig; importing the example makes no model calls. It does not automatically load .env. Keep the real key out of source files and commits. Requests use your API account and incur its normal usage charges.

On a cold run, pulling docker.io/library/python:3.12-slim and installing daemon/harness dependencies can take longer than subsequent runs. You should see execution logs, a summary of the function and assertions, and Run directory: .../agency_runs/<run-id>. The summary is generated by the model, so its wording varies.

The README example is the same workload. Agent.run() returns a pending agdata; result.wait() keeps the process alive until it resolves. Accessing result.summary then retrieves the typed output on success. A failed pending result retains an error payload; inspect result.to_dict() before accessing expected fields (see results). The script relies on Agency’s process-exit sandbox cleanup after the result completes. It writes inside /workspace in the container; it does not mount your checkout. Logs remain on the host after the sandbox is removed.

To view this run as it executes, follow profiler startup. For project mounts and other providers, see configuration.

If setup fails

Symptom Check or fix
Python version or dependency installation error Use Python 3.12+ on Linux; retry uv sync --locked --python 3.12. Verify network access to package indexes.
No module named agency Run from the checkout after syncing, using uv run python; check the import path with the command above.
Neither engine is installed, or daemon is unreachable Check command -v docker / command -v podman, then the corresponding info command as your user. Install/start the engine or fix its access permissions.
Missing key Export OPENAI_API_KEY in the current shell; a key stored only in .env is not loaded by this script.
Provider returns 401, 403, 404, or 429 Verify key, model access, model ID, and account quota. Do not share the key in a bug report.
Provider rejects tools, reasoning effort, or token settings Use a Chat Completions model accepting this example’s settings. For models requiring reasoning with tools, adapt llmconfig using the Responses example.
Unsupported architecture, ptrace/seccomp, or /proc error Use Linux x86-64 locally; inspect container/host restrictions. Do not add privileged flags or run host provisioning as a generic fix.
Image pull or daemon dependency setup fails Verify registry and PyPI access from the host/container. Inspect the run’s logs/ directory, including per-agent daemon logs.
Execution fails after startup Preserve the run directory and read the logged error. Check the provider response and model settings before retrying.

External CLI harnesses

After native works, a separate script can select Agent(agconfig=cfg, harness="codex") or another supported harness. The quickstart always selects native; setting AGENCY_HARNESS does not change it. External harnesses need compatible Linux executables and their runtime dependencies inside the sandbox. See the compact harness setup section and its validated image recipe. A host CLI installation alone does not supply Node or shared libraries to the default Python image.