A Claude Code, OpenCode and Codex skill that runs goal-driven modify-verify-keep/discard loops, inspired by Karpathy's autoresearch.
greyhaven-ai/autocontext
A recursive self-improving harness that runs agent tasks against evaluation, keeps useful lessons, and leaves traces and playbooks for the next run.
- Stars
- 1,310
- Forks
- 114
- Open issues
- 17
- Last commit
- 2 days ago
What is it?
autocontext is a harness for improving agents over repeated runs. You give it a goal, it executes the task, scores the result against an evaluation, keeps lessons that worked, and discards dead ends. Each run leaves filesystem-based artifacts such as traces, per-generation scores, reports, playbooks, and datasets that the next run can build on.
It ships a Python CLI (autoctx) and a TypeScript/Node CLI and TUI, and can be driven from Pi, MCP clients such as Claude Code and Cursor, or Hermes. Model providers include Anthropic, OpenAI-compatible endpoints, OpenRouter, Codex, and self-hosted models through vLLM or Ollama. Optional local-model training can distill stable behavior into a cheaper runtime.
The project covers scenario families such as games, agent tasks, simulations, and investigations, and exposes commands like solve, run, status, and show for inspecting results. Its HTTP and WebSocket control planes bind to loopback by default.
Key features
- 01Runs a goal through evaluation over multiple iterations and keeps the lessons that help.
- 02Saves traces, per-generation scores, reports, and playbooks as plain files.
- 03Works with Anthropic, OpenAI-compatible, OpenRouter, Codex, and self-hosted model endpoints.
- 04Exposes an MCP server so agents like Claude Code and Cursor can call its tools.
- 05Offers both a Python CLI and a TypeScript CLI with a terminal UI.
- 06Can train a local model from stable run behavior (Python).
Use cases
- Iteratively improving customer-support reply quality against a scoring rubric.
- Running repeated agent experiments while keeping an auditable record of each attempt.
- Driving an agent from Claude Code or Cursor through the MCP tool surface.
- Running the improvement loop on self-hosted open-weight models.
Quick start
- 1
Install the Python CLI with uv
uv tool install autocontext==0.19.1 - 2
Run a goal with the Pi provider (uses your local agent auth)
AUTOCONTEXT_AGENT_PROVIDER=pi AUTOCONTEXT_PI_COMMAND=pi autoctx solve "improve customer-support replies for billing disputes" --iterations 3
Things to know
- Full runs need a configured agent provider, such as Pi, Anthropic, OpenAI-compatible, or a self-hosted model endpoint.
- Some advanced features (training, kernel evolution, remote execution) are Python-specific or depend on extra setup.
In collections
Topics
FAQ
- What is autocontext?
- A recursive self-improving harness that runs agent tasks against evaluation, keeps useful lessons, and leaves traces and playbooks for the next run. autocontext is a harness for improving agents over repeated runs. You give it a goal, it executes the task, scores the result against an evaluation, keeps lessons that worked, and discards dead ends. Each run leaves filesystem-based artifacts such as traces, per-generation scores, reports, playbooks, and datasets that the next run can build on.
- Is autocontext free to use? What license does it have?
- autocontext is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
- Is autocontext still maintained?
- Actively maintained. The last commit to autocontext was on Oct 21, 2026.
- What can I use autocontext for?
- Iteratively improving customer-support reply quality against a scoring rubric. Running repeated agent experiments while keeping an auditable record of each attempt. Driving an agent from Claude Code or Cursor through the MCP tool surface. Running the improvement loop on self-hosted open-weight models.
- How do I install autocontext?
- Install the Python CLI with uv: uv tool install autocontext==0.19.1 Run a goal with the Pi provider (uses your local agent auth): AUTOCONTEXT_AGENT_PROVIDER=pi AUTOCONTEXT_PI_COMMAND=pi autoctx solve "improve customer-support replies for billing disputes" --iterations 3
- Where can I get autocontext?
- The source code and installation instructions are on GitHub: https://github.com/greyhaven-ai/autocontext
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
Code-first Python framework from Google for building, evaluating, and deploying AI agents, optimized for Gemini but model-agnostic.
Open-source SDK for building and running AI agents in Python and TypeScript, with tools, MCP, memory, and model portability.
A minimal Python library for building AI agents that write and run their actions as Python code.
Python framework for building autonomous AI agents that research, plan, code and run tasks, with memory, RAG and 100+ LLM providers.
Python framework for building and orchestrating multi-agent systems with sequential, concurrent, graph-based and hierarchical workflows.