Overview
MetaAgent (defined in meta_agent.py) is the top-level agent responsible for recursive self-improvement. Given a repository path and a folder of previous evaluation results, it uses chat_with_agent with all tools enabled to freely read, edit, and write any file in the codebase. After it finishes, the runner saves a git diff of every change made and resets the domains/ directory to keep evaluation scaffolding pristine.
MetaAgent extends AgentSystem and adds no new constructor parameters — it only implements forward.
Source
meta_agent.py
Constructor
MetaAgent inherits the constructor from AgentSystem unchanged.
AgentSystem for parameter details. When invoked from run_meta_agent.py, the default model is CLAUDE_MODEL ("anthropic/claude-sonnet-4-5-20250929").
forward
tools_available='all', then lets the agent loop autonomously until it stops calling tools (or hits the 40-call limit set by chat_with_agent).
Parameters
Filesystem path to the repository the agent is allowed to modify. This value
is interpolated directly into the instruction string:The agent receives this as its sole directive and may read, create, edit, or
delete any file under that path using the loaded tools.
Path to a folder containing previously generated agents and their evaluation
results (e.g.
./outputs/). This is passed to forward so the agent knows
where to look for prior iteration context. The parameter is accepted by the
method signature but is not currently interpolated into the instruction string
— it is available for subclasses or future versions to use.How many more meta-agent iterations are scheduled after this one. Passed
through from the CLI (
--iterations_left). Not used in the current instruction
string, but available to the agent via the method signature for context-aware
planning in future versions.Return Value
forward returns None. All meaningful output is the set of file modifications made to repo_path on disk. The caller (run_meta_agent.py) captures those changes via git diff.
Post-processing (run_meta_agent.py)
The entry pointrun_meta_agent.py performs two steps after forward returns:
- Reset
domains/— callsreset_paths_to_commit(git_dname, base_commit, paths=["domains/"])to undo any changes the agent made to the evaluation harness, ensuring benchmarks are not contaminated. - Save the diff — calls
diff_versus_commit(git_dir, base_commit)and writes the result to{outdir}/model_patch.diff. This patch file is the canonical output of a meta-agent run.
run_meta_agent.py
Examples
Python
CLI
run_meta_agent.py is the standard entry point. --git_dir and --base_commit are required so the runner can compute and save the diff.