Harness From Scratch is a hands-on repository for learning how to build real agent harnesses, and then applying those lessons to a full graduation project: RepoPilot Harness.
It has two layers:
agents/: the 12 progressive lessons that explain the core mechanics of agent runtimesproducts/repopilot_harness/: a real local-first engineering control plane built from those lessons
Most agent demos stop at chat. This repository focuses on the harder part: execution infrastructure.
It shows how to go from:
LLM call -> tool loop -> task system -> subagents -> background jobs -> protocols -> autonomous teammates -> isolated worktrees
to a product that can actually manage software delivery work.
Each agents/sXX_*.py file introduces one capability in isolation so the harness architecture stays understandable.
s01: minimal agent loops02: tool uses03: todo states04: subagents and context isolations05: skill loadings06: context compactions07: durable task systems08: background taskss09: agent teamss10: team protocolss11: autonomous teammatess12: task-to-worktree isolation
Course materials live under docs/, including:
docs/course-outline-zh.mddocs/lesson-test-log-zh.mddocs/course-graduation-review-zh.mddocs/s08-background-tasks-guide-zh.mddocs/s09-agent-teams-guide-zh.mddocs/s10-team-protocols-guide-zh.mddocs/s11-autonomous-agents-guide-zh.mddocs/s12-worktree-task-isolation-guide-zh.md
RepoPilot Harness is the practical culmination of the course.
It turns a natural-language development mission into:
mission intake -> planning -> task graph -> isolated workspaces -> implementation execution -> validation -> delivery handoff
Below is the current engineering console demo for RepoPilot Harness:
Current product capabilities include:
- operator console UI
- durable runs, tasks, jobs, workspaces, and events
- approval / pause / retry flow
- isolated implementation workspaces
- direct LLM execution or external agent command execution
- validation commands with persisted logs
- run recovery after restart
- file and artifact inspection in the UI
See products/repopilot_harness/README.md for product details.
.
├── agents/ # 12 lesson scripts + earlier console prototype
├── docs/ # Chinese course notes, plans, ADRs, demo writeups
├── lesson3_demo/ # Small standalone demo used in the course
├── products/
│ └── repopilot_harness/ # Graduation project: real harness product
├── skills/ # Loadable example skills
├── tests/ # Course-level pytest suite
├── conftest.py
├── pyproject.toml
└── requirements.txt
Create .env in the repository root:
cp .env.example .envThen fill in at least:
ANTHROPIC_API_KEY=your_api_key
MODEL_ID=claude-opus-4-1
# Optional when using a compatible proxy endpoint
ANTHROPIC_BASE_URL=Notes:
.envis intentionally ignored by git- if you use a third-party compatible endpoint, set
ANTHROPIC_BASE_URL - direct LLM execution requires both
ANTHROPIC_API_KEYandMODEL_ID
python3 -m pip install -r requirements.txtOr install in editable mode:
python3 -m pip install -e .Start from lesson 1:
python3 agents/s01_agent_loop.pyThen continue upward lesson by lesson.
python3 products/repopilot_harness/backend/main.pyOpen http://127.0.0.1:8877 in your browser.
Run the lesson and product tests:
python3 -m pytest tests products/repopilot_harness/tests -qExamples:
python3 -m pytest tests/test_s07_task_system.py -q
python3 -m pytest products/repopilot_harness/tests/test_repopilot_harness_app.py -qThe course lessons use agents/auth.py as the shared client bootstrap.
from agents.auth import make_client
client, MODEL = make_client()That factory centralizes:
.envloadingMODEL_IDlookup- optional
ANTHROPIC_BASE_URL - compatible proxy safety handling when a custom base URL is set
The graduation project uses products/repopilot_harness/backend/app/llm_client.py for direct runtime execution and supports both:
direct_llm: RepoPilot directly calls the LLM APIagent_command: RepoPilot executes a real external coding agent command inside each workspace
If you want the full learning path:
docs/course-outline-zh.mdagents/s01_agent_loop.pythroughagents/s12_worktree_task_isolation.pydocs/lesson-test-log-zh.mddocs/course-graduation-review-zh.mdproducts/repopilot_harness/README.md
This repository is not a toy chat wrapper. The current graduation project already supports real local task execution and real file outputs inside isolated workspaces.
The next natural upgrades are:
- richer execution policies and safety controls
- diff review and merge workflows
- stronger multi-agent protocol orchestration
- better operator dashboards and replay tools
MIT
