Skip to main content

autocontext control plane for iterative strategy evolution.

Project description

autocontext Python package

This package is the Python control plane for autocontext: scenario runs, solve, simulations, investigations, MCP/HTTP surfaces, persistent knowledge, training-data export, and local training hooks.

Use it when you want the full harness in Python, a CLI installed with uv/pip, or the MCP/HTTP server that coding agents can call.

Install

pip install autocontext
# or, for an isolated CLI tool:
uv tool install autocontext

Optional extras:

pip install 'autocontext[browser]'          # Chrome/CDP capture
pip install 'autocontext[primeintellect]'   # PrimeIntellect sandbox backend
pip install 'autocontext[mcp]'              # MCP server dependencies

The CLI entrypoint is autoctx. Provider env vars are listed in the repo-level .env.example.

Run from a checkout

cd autocontext
uv venv
source .venv/bin/activate
uv sync --group dev

AUTOCONTEXT_AGENT_PROVIDER=deterministic \
uv run autoctx solve "improve customer-support replies for billing disputes" --iterations 3

Use a real provider by changing AUTOCONTEXT_AGENT_PROVIDER and setting its credential:

AUTOCONTEXT_AGENT_PROVIDER=anthropic \
ANTHROPIC_API_KEY=... \
uv run autoctx solve "improve customer-support replies for billing disputes" --iterations 3

Pi and local CLI providers avoid API-key plumbing when those tools are already authenticated:

AUTOCONTEXT_AGENT_PROVIDER=pi AUTOCONTEXT_PI_COMMAND=pi uv run autoctx solve "..." --iterations 3
AUTOCONTEXT_AGENT_PROVIDER=claude-cli AUTOCONTEXT_CLAUDE_MODEL=sonnet uv run autoctx solve "..." --iterations 3
AUTOCONTEXT_AGENT_PROVIDER=codex AUTOCONTEXT_CODEX_MODEL=o4-mini uv run autoctx solve "..." --iterations 3

Common commands

Command Purpose
uv run autoctx solve "..." --iterations 3 Generate and run a scenario from a plain-language goal
uv run autoctx run <scenario> --iterations 3 Improve an existing scenario
uv run autoctx simulate --description "..." Create/replay/compare modeled-world simulations
uv run autoctx investigate --description "..." Run synthetic or iterative investigations
uv run autoctx list / status <run_id> / show <run_id> Inspect runs
uv run autoctx replay <run_id> --generation 1 Replay a generation before accepting knowledge
uv run autoctx queue add --task-prompt "..." --rubric "..." Queue evaluation/improvement work
uv run autoctx serve --host 127.0.0.1 --port 8000 Start the local HTTP API
uv run autoctx worker --poll-interval 5 --concurrency 2 Process queued tasks beside the API server
uv run autoctx mcp-serve Expose the MCP tool surface
uv run autoctx export-training-data --scenario <name> --all-runs --output data.jsonl Build a training corpus
uv run autoctx train --scenario <name> --data data.jsonl --time-budget 300 Run the local training hook
uv run autoctx hermes inspect --json Inspect Hermes Curator state

Saved custom scenarios under knowledge/_custom_scenarios/ can be rerun and benchmarked by name after their spec.json is persisted.

HTTP, MCP, and agents

uv sync --group dev --extra mcp
uv run autoctx mcp-serve

Python runtime-backed run and solve calls append provider prompts/responses to run-scoped runtime-session logs. The same logs are readable through the cockpit HTTP API and MCP tools.

Detailed setup moved out of this README:

Contract probes

Contract probes turn observed harness traces into executable checks:

uv run autoctx probes check --suite contract-probes.json
uv run autoctx probes check --suite contract-probes.json --json
uv run autoctx probes extract --trace harness-trace.json --output contract-probes.json

Probe suites are strict JSON: unknown keys fail validation and required observation fields must be present. Pipe stdin with --suite - when another tool generates the suite.

Production traces

Wrap an existing Anthropic/OpenAI client once, then persist emitted traces through a sink:

from anthropic import Anthropic
from autocontext.integrations.anthropic import FileSink, instrument_client

sink = FileSink("./traces/anthropic.jsonl")
client = instrument_client(
    Anthropic(),
    sink=sink,
    app_id="billing-bot",
    environment_tag="prod",
)

For lower-level emit APIs, use autocontext.production_traces.build_trace and write_jsonl. Architecture notes are in ../docs/analytics.md and ../docs/opentelemetry-bridge.md.

Training

uv run autoctx export-training-data \
  --scenario support_triage --all-runs \
  --output training/support_triage.jsonl
uv run autoctx train \
  --scenario support_triage \
  --data training/support_triage.jsonl \
  --time-budget 300

For MLX/CUDA setup and case studies, use:

Repository layout

autocontext/
├── src/autocontext/       # Python package
├── tests/                 # pytest suite
├── docs/                  # package-specific docs
├── demo_data/             # small bundled examples
├── migrations/            # SQLite migrations
└── pyproject.toml

Development

uv run ruff check .
uv run mypy src
uv run pytest

Keep this README concise. Add deep reference prose to docs/ or the repo-level docs index instead.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autocontext-0.11.0.tar.gz (2.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

autocontext-0.11.0-py3-none-any.whl (1.4 MB view details)

Uploaded Python 3

File details

Details for the file autocontext-0.11.0.tar.gz.

File metadata

  • Download URL: autocontext-0.11.0.tar.gz
  • Upload date:
  • Size: 2.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for autocontext-0.11.0.tar.gz
Algorithm Hash digest
SHA256 01ba82e51607530ddeffde01eb1eeba7e1af27abaf8b5ed993a858c11add7f5f
MD5 b6a6f500c4c61d2d007737bb49e4f7b1
BLAKE2b-256 9a6e09c9ceb02b189db94d63681820a54664d52231097a906a0033beafffd3e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for autocontext-0.11.0.tar.gz:

Publisher: publish-python.yml on greyhaven-ai/autocontext

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file autocontext-0.11.0-py3-none-any.whl.

File metadata

  • Download URL: autocontext-0.11.0-py3-none-any.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for autocontext-0.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2b6195c9867f6dbf33017a9646e39899cc29be437330756c77070386dd6fa760
MD5 beb9fa77b66dabc4289bbab0f77a549e
BLAKE2b-256 61c9093b6260e0b79a41fda89b4cb9bf9da73e23dbd30a3924821534d30b7d08

See more details on using hashes here.

Provenance

The following attestation bundles were made for autocontext-0.11.0-py3-none-any.whl:

Publisher: publish-python.yml on greyhaven-ai/autocontext

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page