# Agent Apprenticeship

> Run your agent in mentor-judged loops and keep what it learned as reusable experience

- Category: AI Coding / Coding-Agent Harnesses & Runtimes
- Language: Python
- Licence: MIT
- Repository: https://github.com/ray-r-ren/agent-apprenticeship
- Canonical page: https://ai-tldr.dev/tools/agent-apprenticeship/
- Updated: 2026-10-19

## In short

Agent Apprenticeship is an MIT-licensed command-line tool that wraps an AI agent you already have installed and runs it on a task in repeated loops. The agent doing the work is the "Apprentice Agent": Codex, Cursor, Claude Code, OpenClaw, OpenCode, Hermes Agent, or any other CLI you describe with a command template. It sits in the Coding-Agent Harnesses & Runtimes category of the AI Coding tools and is open-source, written in Python and licensed MIT.

## Overview

Agent Apprenticeship is an MIT-licensed command-line tool that wraps an AI agent you already have installed and runs it on a task in repeated loops. The agent doing the work is the "Apprentice Agent": Codex, Cursor, Claude Code, OpenClaw, OpenCode, Hermes Agent, or any other CLI you describe with a command template. Each iteration is evaluated by a "Mentor", either a model you configure with your own OpenAI, Anthropic, Gemini or OpenRouter key, or a human expert, and the loop runs until the work passes or the maximum loop depth is reached.

What sets it apart from other harnesses is what happens after a run. Agent Apprenticeship writes a local run folder and an "Experience Compilation": the task, the execution traces, the mentor's evaluations and lessons drawn from them. You can inspect and validate that bundle, export it in full, and install it as "Runtime Training" so the next run of your agent starts from the lessons of the previous ones. Version 0.3.0 (October 2026) added trace interchange in the Harbor ATIF v1.8 format.

Runs can stay private or feed a shared pool. In Public Ecosystem mode completed experience is contributed back, and `apprentice ecosystem search` and `pull` fetch experience others published; Private Internal Only mode keeps everything on your machine. The project also publishes a seed dataset on Hugging Face (Apache-2.0) with 505 experience compilations plus traces, reward, verifier and preference rows derived from them. The CLI is written in Python (3.11+) and distributed through npm, which needs Node.js 18+.

## What it does

- Wraps existing agent CLIs (Codex, Cursor, Claude Code, OpenClaw, OpenCode, Hermes Agent) and auto-detects which are installed, plus a custom command template for anything else
- Mentor evaluation by a model on your own OpenAI, Anthropic, Gemini or OpenRouter key, or by a human, in Autonomous, Expert-Led or Organization Custom modes
- Configurable loop depth (`AA_MAX_ITERATIONS` or `apprentice settings`) and live progress with `apprentice watch <run_id>`
- Experience Compilations: per-run bundles of traces, evaluations and lessons that can be inspected, checked, exported and installed as Runtime Training for later runs
- Optional public ecosystem to search, inspect and pull experience other users contributed, or a private internal-only mode
- Trace interchange in the Harbor ATIF v1.8 format and an open Apache-2.0 seed dataset on Hugging Face

## Getting started

From the README. You need at least one supported agent CLI installed and an API key for the mentor model; the npm package requires Node.js 18+ and runs on Python 3.11+.

1. Initialise

   Runs the setup wizard; add `--defaults` to accept the default answers. To install globally instead, run `npm install -g agent-apprenticeship` and then `apprentice init`.

```bash
npx agent-apprenticeship init
```

2. Add a mentor model key

   Keys live in `~/.agent-apprenticeship/.env.local` (shell environment variables also work). Fill in the providers you use.

```bash
OPENAI_API_KEY=""
ANTHROPIC_API_KEY=""
GEMINI_API_KEY=""
OPENROUTER_API_KEY=""
```

3. Pick the agent, model and mode, then check the setup

```bash
apprentice configure
apprentice configure model
apprentice doctor
```

4. Run a task and watch it

   When the run completes, the CLI prints the local run folder and the Experience Compilation path.

```bash
apprentice run "Create a short market map for AI procurement tools."
apprentice watch <run_id>
```

5. Inspect the experience and reuse it

   Check the compiled bundle, then install it as Runtime Training so later runs build on it.

```bash
apprentice ecosystem inspect <experience_compilation_path>
apprentice bundle check <experience_compilation_path>
apprentice learn install <experience_compilation_path>
```

## When to use it

- Put a second, independent judge (a mentor model or a domain expert) over an agent's work instead of trusting its own "done"
- Make an agent improve across runs by installing the lessons of earlier runs as Runtime Training
- Collect structured execution traces, evaluations and lessons from real tasks as training or evaluation data
- Share or pull agent work experience through a public pool, or keep it strictly internal

## Version history

- 2026-10-19 v0.3.0: Version 0.3.0 added trace interchange in the Harbor ATIF v1.8 format; it was published to npm on 25 October 2026.
