autocontext
autocontext is a control plane for improving agent behavior over repeated runs. It combines multi-agent candidate generation, staged validation, scenario execution, knowledge accumulation, optional local distillation, and OpenClaw-facing APIs.
Working Directory
Run the commands in this README from the autocontext/ directory. The Python package, CLI entrypoint, tests, and migrations all live here.
What It Does
- Runs iterative generation loops against game scenarios and agent-task scenarios
- Adds a first-class
simulatesurface for modeled-world exploration, replay, compare, and export - Persists playbooks, hints, tools, reports, and snapshots across runs
- Supports staged validation, harness synthesis, and harness-aware routing
- Exports training data and runs autoresearch-style local training loops
- Exposes evaluation, validation, artifact, and discovery operations over MCP and HTTP
0.3.0 Surface Summary
The Python package is the full control-plane surface in this repo. In 0.3.0 it includes:
- generation-loop execution via
autoctx run - plain-language simulation via
autoctx simulate - local training workflows via
autoctx export-training-dataandautoctx train - scenario creation/materialization via
autoctx new-scenario - HTTP API and MCP server surfaces via
autoctx serveandautoctx mcp-serve
Some newer operator-facing surfaces are currently TypeScript-first:
autoctx investigateautoctx analyze- the interactive terminal UI via
npx autoctx tui
Quick Start
From the repo root:
cd autocontext
uv venv
source .venv/bin/activate
uv sync --group dev
Use the repo-level .env.example as the reference for available AUTOCONTEXT_* settings.
operator-in-the-loop remains a typed scenario family for capability discovery and experimentation, but autocontext does not scaffold executable operator-loop runtimes. Use datasets, tools, or live-agent experiments instead of harness-owned escalation scripts.
Run a deterministic local scenario:
AUTOCONTEXT_AGENT_PROVIDER=deterministic \
uv run autoctx run --scenario grid_ctf --gens 3 --run-id quickstart
Run with Anthropic:
AUTOCONTEXT_AGENT_PROVIDER=anthropic \
AUTOCONTEXT_ANTHROPIC_API_KEY=... \
uv run autoctx run --scenario grid_ctf --gens 3
Run with Pi CLI (local Pi agent runtime):
AUTOCONTEXT_AGENT_PROVIDER=pi \
AUTOCONTEXT_PI_COMMAND=pi \
uv run autoctx run --scenario grid_ctf --gens 3
Run with Pi RPC (remote Pi agent via HTTP):
AUTOCONTEXT_AGENT_PROVIDER=pi-rpc \
AUTOCONTEXT_PI_RPC_ENDPOINT=http://localhost:3284 \
uv run autoctx run --scenario grid_ctf --gens 3
Run with Hermes (via OpenAI-compatible gateway):
AUTOCONTEXT_AGENT_PROVIDER=openai-compatible \
AUTOCONTEXT_AGENT_BASE_URL=http://localhost:8080/v1 \
AUTOCONTEXT_AGENT_API_KEY=no-key \
AUTOCONTEXT_AGENT_DEFAULT_MODEL=hermes-3-llama-3.1-8b \
uv run autoctx run --scenario grid_ctf --gens 3
Start the API server:
uv run autoctx serve --host 127.0.0.1 --port 8000
Inspect http://127.0.0.1:8000/ for the API index after the server starts. For an interactive terminal UI, use the TypeScript package: npx autoctx tui.
Start the MCP server:
uv sync --group dev --extra mcp
uv run autoctx mcp-serve
Main CLI Commands
uv run autoctx run --scenario grid_ctf --gens 3
uv run autoctx simulate --description "simulate deploying a web service with rollback"
uv run autoctx simulate --replay deploy_sim --variables threshold=0.9
uv run autoctx list
uv run autoctx status <run_id>
uv run autoctx replay <run_id> --generation 1
uv run autoctx benchmark --scenario grid_ctf --runs 5
uv run autoctx new-scenario --template prompt-optimization --name my-task
uv run autoctx export-training-data --scenario grid_ctf --all-runs --output training/grid_ctf.jsonl
uv run autoctx train --scenario grid_ctf --data training/grid_ctf.jsonl --time-budget 300
uv run autoctx serve --host 127.0.0.1 --port 8000
uv run autoctx mcp-serve
uv run autoctx wait <condition_id> --json
Useful variants:
AUTOCONTEXT_AGENT_PROVIDER=anthropic AUTOCONTEXT_ANTHROPIC_API_KEY=... \
uv run autoctx run --scenario grid_ctf --gens 3
AUTOCONTEXT_AGENT_PROVIDER=deterministic AUTOCONTEXT_RLM_ENABLED=true \
uv run autoctx run --scenario grid_ctf --gens 3
Training Workflow
Export JSONL training data from completed runs:
uv run autoctx export-training-data \
--scenario grid_ctf \
--all-runs \
--output training/grid_ctf.jsonl
Launch the autoresearch-style training loop:
uv sync --group dev --extra mlx
uv run autoctx train \
--scenario grid_ctf \
--data training/grid_ctf.jsonl \
--time-budget 300
MLX training is host-only. It must run on an Apple Silicon macOS machine with Metal access. It will not run correctly inside a Docker sandbox on macOS.
If you only want to inspect generated training data first, export without training and open the JSONL directly.
For host setup details and OpenClaw automation via a file-based watcher bridge, see docs/mlx-training.md.
Configuration
Configuration is loaded from AUTOCONTEXT_* environment variables in src/autocontext/config/settings.py.
Common settings:
AUTOCONTEXT_AGENT_PROVIDERAUTOCONTEXT_EXECUTOR_MODEAUTOCONTEXT_MODEL_COMPETITORAUTOCONTEXT_MATCHES_PER_GENERATIONAUTOCONTEXT_MAX_RETRIESAUTOCONTEXT_JUDGE_PROVIDERAUTOCONTEXT_RLM_ENABLEDAUTOCONTEXT_HARNESS_PREFLIGHT_ENABLEDAUTOCONTEXT_STAGED_VALIDATION_ENABLED
See the repo-level .env.example for a working starting point.
Repository Structure
autocontext/
src/autocontext/ Python package
tests/ Pytest suite
docs/ Package-specific documentation
migrations/ SQLite migrations
ts/ TypeScript package
infra/ Docker, Fly.io, bootstrap scripts
Validation and Development
uv run ruff check src tests
uv run mypy src
uv run pytest
If you change protocol messages, regenerate the derived protocol artifacts from the repo root:
cd ..
uv run --directory autocontext python scripts/generate_protocol.py
OpenClaw / ClawHub
autocontext exposes:
- artifact contracts for harnesses, policies, and distilled models
- REST and MCP operations for evaluate, validate, publish, import, and discover
- ClawHub skill manifests and scenario discovery metadata
- an adapter layer for running OpenClaw agents inside the harness
Additional Docs
- Canonical concept model
- Agent integration guide — CLI-first integration for external agents, MCP fallback, JSON output reference
- Sandbox modes
- MLX host training
- TypeScript package guide —
investigate,analyze, and interactive TUI surfaces - Demo data notes
- Copy-paste examples
- Change history
- Repository overview
Release files for autoctx 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| autoctx-0.3.0.tar.gz | 1.2 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| autoctx-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.9 MB
Release files / autoctx-0.3.0.tar.gz
| Download URL | autoctx-0.3.0.tar.gz |
|---|---|
| Size | 1.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
75a64a83f84375964315bd4ff5d7f484937f9c6fa10c6690c7ceb103819d1fac
|
|
BLAKE2b-256 checksum How to use checksums |
55eff4978b750d97d0fd99c411e1079a90d9214acb963977c1713c5d9839eb82
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 30, 2026.
Transparency logRelease files / autoctx-0.3.0-py3-none-any.whl
| Download URL | autoctx-0.3.0-py3-none-any.whl |
|---|---|
| Size | 723.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6a55cf9eda5e8de9bd606503327661c1fdf2083516fa6223da2b3407215eb20c
|
|
BLAKE2b-256 checksum How to use checksums |
5a4082d94b3111105920256e7c951df533c3754b495448e3df6eb7040d7d52ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 30, 2026.
Transparency log