Running a harness
afh run runs a harness without any other agent tool. It pulls the harness, loads its system prompt and skills, and runs a small agent loop against the model you pick, using your own API key. The model gets a few file tools over the current folder and nothing else.
afh run yoyo/hello-harness --model anthropic/claude-sonnet-5-5 "What does this repo do?"
# No task: chat, /exit to quit
afh run yoyo/hello-harness --model openai/gpt-5
# A local folder, for authors
afh run ./my-harness --model ollama/llama3.3
Only declarative harnesses (a system prompt plus skills) can be run this way for now. Harnesses with a python, node or container runtime run their own code, which needs a sandbox; afh run refuses them and you can still download them with afh pull.
Models and keys
--model is <provider>/<model-id>. Use the model ID the provider gives in its docs.
| Provider | Example | Key |
|---|---|---|
| Anthropic | anthropic/claude-sonnet-5-5 |
ANTHROPIC_API_KEY |
| OpenAI | openai/gpt-5 |
OPENAI_API_KEY |
| OpenRouter | openrouter/<vendor>/<model>, as listed on OpenRouter |
OPENROUTER_API_KEY |
| Ollama (local) | ollama/llama3.3 |
none |
| Any OpenAI-compatible server | --base-url http://localhost:4000/v1 --model my-route |
AFH_MODEL_API_KEY (optional) |
With --base-url, the whole --model value goes to the server unchanged, so LiteLLM routes like anthropic/claude-sonnet-5-5 work as they are. ANTHROPIC_BASE_URL, OPENAI_BASE_URL and OLLAMA_HOST are honoured too.
Keys are read from the environment only. afh run never stores them, and never puts them in traces, logs or error messages.
The model has to support tool use. If the provider says it doesn’t, afh run tells you so; the harness’s models.requires and models.min_context are printed before the run starts.
What the harness can touch
A stranger wrote the harness’s prompt, and the files the model reads may contain instructions of their own. So the tools are deliberately small:
| Tool | What it does |
|---|---|
list_files, read_file, search |
Read the workspace: the current folder, or --workspace <dir> |
load_skill |
Read one of the harness’s own skills, only when the model needs it |
write_file, edit_file |
Only with --allow-write. Each change is shown as a diff and needs your yes |
There is no shell, no network access for tools, and MCP servers in tools.mcp_servers aren’t started yet.
The file tools follow these rules:
- Every path is resolved inside the workspace, symlinks included.
.., absolute paths elsewhere and symlinks that point outside are refused. .envfiles,.git,node_modules,.ssh,.awsand key files (*.pem,*.key,id_rsa*, …) are never read, listed or written.- Reads stop at 256 KB per call; binary files are refused.
--allow-writeneeds an interactive terminal, since it asks before every write.- A harness with
permissions.filesystem: nonegets no file tools at all.
Before the first model call, afh run prints what the harness can do in this run.
Limits
A task stops when the model is done, after permissions.max_runtime_s (default 300 seconds), after 40 model calls (--max-turns to change), or when you press Ctrl-C. At the end you get the number of turns, tokens in and out, and the time taken.
permissions.max_cost_usd isn’t enforced locally yet, because afh run has no price table for every provider. Watch the token counts.
Caching and integrity
Hub harnesses are downloaded once into ~/.cache/agentfacehub/harnesses/ (or under $XDG_CACHE_HOME). Every file is checked against its SHA-256 when it’s downloaded, and the cached copy’s tree hash is checked against the hub every time you run it, so a changed cache is downloaded again. A pinned version (@0.1.0) still runs from the cache when you’re offline.
A local folder (./my-harness) is read in place, so authors can edit and rerun. Local folders must start with ., / or ~.
Traces
Each run writes a JSONL trace to ~/.cache/agentfacehub/runs/, or to --trace <file>. It holds the harness and its tree hash, the model, every message, tool call and result, token usage and timing. The path is printed at the end. Field names follow the OpenTelemetry GenAI conventions where they exist.
Traces are readable only by you. They can contain the contents of files the model read, so check before you share one.