autocontextDocs

Introduction

autocontext is a recursive self-improving harness that helps agents succeed on any task.

Last updated Aug 26, 2026

autocontext turns a goal written in plain language into something an agent can actually get better at. You point it at an objective, it works the problem against real evaluation, keeps what worked, discards what did not, and writes down what it learned. The next run (and the next agent) inherits that knowledge automatically.

Instead of a single prompt and a single answer, you get a loop: propose, evaluate, learn, repeat. Every run leaves behind a trace of what happened, the artifacts it produced, a playbook of durable lessons, and optionally a distilled model. That accumulated context is the product.

The loop in one paragraph

A run advances in generations. Five specialized roles divide the work: a competitor proposes a strategy, an analyst explains why it scored the way it did, a coach updates the playbook, an architect proposes new tooling, and a curator decides what is worth keeping. Strategies are scored by real evaluation (an LLM judge for open-ended tasks, tournament play with Elo for games). Weak changes roll back; strong ones persist as knowledge that carries across runs. Read the full picture in core concepts.

Try it in 30 seconds

AUTOCONTEXT_AGENT_PROVIDER=pi AUTOCONTEXT_PI_COMMAND=pi \
  autoctx solve "improve customer-support replies for billing disputes" --iterations 3
AUTOCONTEXT_AGENT_PROVIDER=pi \
  bunx autoctx solve "improve customer-support replies for billing disputes" --iterations 5 --json

Pi is the zero-config path: no API key plumbing. autocontext also runs against Anthropic, OpenAI, local models, and other agent CLIs. See providers.

What's New in 0.17.0

The 0.17.0 release aligns the Python and TypeScript core packages around stronger evidence contracts and adds a Python-first production path for governed context promotion, durable campaigns, isolated research execution, and accelerator-aware evaluation.

Outcome-Gated Context Bundles

Immutable candidates now move through matched screening, adaptive confirmation, held-out evaluation, false-promotion control, causal attribution, and atomic activation while rejected evidence remains available for scoped retesting.

Capability-Scoped Execution

Generated research code can run in a locked-down Docker workspace, remote scenarios ship as verified content-addressed packages, and trusted-local execution remains an explicit operator choice rather than a fallback.

Durable Campaign Operations

Restart-safe scheduling, leases, heartbeats, cancellation, bounded reuse, campaign auditing, and a paid-result outbox make long-running local and remote evaluation inspectable, accountable, and recoverable without duplicate provider execution.

Correctness-First Kernel Evolution

Protected workers, fresh confirmation, finite-sample promotion gates, autonomous model-backed campaigns, and three-family transfer studies expose regressions, specialists, plateaus, and generalizing champions without averaging failures away.

Capability-Validated Accelerators

Prime requests bind immutable images, accelerator type/count, region, telemetry, idempotency, and resolved hardware identity; unsupported or drifting configurations fail before paid candidate execution.

Stronger Learning Evidence Across Runtimes

Python and TypeScript share context-bundle, attribution, and negative-result contracts, while Python training adds replayable adaptive confirmation and minimum-effect promotion artifacts.

Install Python autocontext==0.17.0 or npm autoctx@0.17.0; npm still requires Node.js 22.19.0 or newer. The separately versioned pi-autocontext@0.10.0 extension still declares autoctx@^0.15.0, which accepts 0.15.x but excludes 0.16.x and 0.17.x. A separate global autoctx@0.17.0 installation does not replace the extension's nested SDK.

Live context promotion and paid accelerator execution are opt-in and fail closed when authority, identity, telemetry, or capability checks are not satisfied. TypeScript shares the portable bundle and evidence contracts; the live promotion coordinator, campaign scheduler and auditor, research executor, and kernel-evolution runtime are Python-only in this release.

0.16 Release Highlights

The 0.16.1 release aligned the Python and TypeScript core packages on a versioned automation contract and stabilized the TypeScript-first operator TUI, image-delivery path, and live runtime-composition system introduced in npm 0.16.0.

The paved-road CLI adopted --iterations and standardized status, show, and watch --ndjson for automation. Python exposed its full catalog with autoctx commands --all, while npm used autoctx --help --all. show rejects conflicting selectors instead of guessing; export defaults to JSON on stdout and supports pi-package. CLI contract v2 ships with versioned schemas and fixtures, while ratcheted dependency boundaries retain compatibility re-exports for older module paths.

0.15 Release Highlights

Recent capabilities

How autocontext is different

Prompt optimization is a special case of what autocontext does. autocontext takes a goal, generates or selects an evaluable scenario, runs a multi-role loop, and produces transferable artifacts the next run inherits.

ToolPrimary shapeDifference from autocontext
DSPyPrompt optimizerOptimizes prompts against a metric. autocontext can generate the scenario and verifier, run the loop, and gate changes across generations.
InspectEvaluation frameworkRuns evaluations. autocontext runs them in a loop and persists what survives as reusable knowledge.
TextGradGradient-style textual feedbackBackprops textual feedback into prompts. autocontext keeps artifacts, datasets, and distilled knowledge, not just better prompts.
autocontextSelf-improving harnessPlain-language goal → scenario → multi-role loop with verifier-driven gating → playbooks, datasets, and optional distilled local models the next agent inherits.

Repeated runs should get better, not just different. The durable product is the accumulated context: traces, artifacts, playbooks, lessons, and exported knowledge packages.

What it can evaluate

Scenario families are the reusable shapes autocontext can generate, run, score, and learn from. They are not the only surface—you can also run prompt-centric tasks, missions, simulations, and production traces—but they show the breadth of what the harness knows how to evaluate.

FamilyEvaluationWhat it tests
gameTournament + EloTurn-based strategy, including built-ins such as grid_ctf and othello.
agent_taskLLM judgePrompt-centric tasks with evaluate-and-improve loops.
simulationTrace evaluationAction traces with mock environments and fault injection.
artifact_editingArtifact validationFile, config, and schema edits with diff tracking.
investigationEvidence chainsDiagnosis accuracy, source use, and red-herring detection.
workflowWorkflow evaluationTransactional flows with compensation and retry behavior.
negotiationNegotiation evaluationHidden preferences, BATNA handling, and opponent modeling.
schema_evolutionSchema adaptationMid-run state changes and stale-context detection.
tool_fragilityDrift adaptationAPIs and tools that drift; strategies must adapt to changed behavior.
operator_loopJudgment evaluationEscalation, clarification, and operator handoff judgment.
coordinationCoordination evaluationMulti-agent handoff, merge behavior, and duplicate-work avoidance.

Read scenarios, tasks, missions, campaigns for the canonical object model, or solve & run for the CLI workflow.

Bring your own providers, runtimes, and executors

No API keys are required to start. The Pi runtime runs locally and handles its own auth; local providers and deterministic runs need no hosted key. Hosted APIs, remote sandboxes, and per-role model overrides are opt-in through environment variables.

LayerOptionsNotes
Shared model/API backendsanthropic, openai, openai-compatible, ollama, vllm, deterministicAvailable in both runtimes.
Runtime-specific model backendsPython: mlx, agent_sdk; TypeScript: gemini, mistral, groq, openrouter, azure-openaiThe hermes selector also differs by runtime: Python invokes the Hermes CLI; TypeScript targets an OpenAI-compatible Hermes gateway.
Agent runtimespi, pi-rpc, claude-cli, codex; Python also supports the Hermes CLIThe CLI owns auth; autocontext holds no key. Pi is the recommended zero-config path.
Executorslocal, ssh, monty, primeintellect; gondolin reservedExecution isolation is configured separately from the model provider. Use sandbox modes for the full reference.

Drive it from your agent

The CLI is the documented default. Any agent that can run shell can drive autocontext directly. Many operational commands offer --json; those payloads go to stdout, diagnostics go to stderr, and exit code 0 means success.

autoctx solve "resolve unpaid invoice disputes from contracts and email history" --json
autoctx status <run_id> --json
autoctx export <run_id> --json

Use MCP when your host wants typed tool discovery instead of shell commands. Install the Python MCP extra and start the server with the canonical autoctx serve mcp command; the host discovers the available catalog and exact runtime-specific tool names. The older mcp-serve spelling remains a hidden compatibility alias.

uv tool install 'autocontext[mcp]==0.17.0'
autoctx serve mcp

Pick your track

These docs serve three kinds of reader. Start wherever you are.

Detailed technical tables

When you need exact names, defaults, and contracts, jump into the technical reference pages:

Stay current

Follow the changelog for public website, documentation, LLM-readable docs, and launch-facing product milestones.

Next steps

New here? Go to get started and run your first solve, then read your first solve to understand the output.