# 6.9 Build a Minimal Coding Harness in 100 Lines and Equip Its First Skill

This experiment implements a complete, minimal coding harness in under 170 lines of pure Python standard library code (zero third-party dependencies):

1. **Three orthogonal atomic tools**: `read_file`, `write_file`, and `bash` (with `safe_path` workspace boundary checks and a 15-second command timeout).
2. **Progressive disclosure for Skills**: On startup, the harness scans the YAML frontmatter of `workspace/.agents/skills/*/SKILL.md` and injects only a one-line summary (`< 50` tokens) into the system prompt. When the model sees a task related to a Skill, it calls `read_file` on demand to read the full `SKILL.md` checklist.
3. **Agent main loop**: A simple loop that appends model tool calls and environment outputs to `messages` until all unit tests and ledger reconciliation checks pass.

## Requirements

Only the Python 3 standard library and an AI Builder Space API key. It runs on any machine.

## How to Run

```bash
cd 6_9_mini_harness
export AI_BUILDER_TOKEN=sk_your_key
python3 mini_harness.py
```

You can also pass a custom instruction:

```bash
python3 mini_harness.py --task "Add a max_discount=50.0 cap parameter to settle_order in settlement.py, and add a unit test that passes"
```

## What You Should See

By default, the task asks the agent to fix the order settlement function in `workspace/settlement.py`. When you run it, you will see a complete 6-turn closed-loop trajectory (a reference log is saved in `sample_output/deepseek_run.txt`):

- **Turn 1**: After seeing the Skill summary in the system prompt, the model proactively calls `read_file` to read `.agents/skills/settlement-reconcile/SKILL.md`.
- **Turns 2-3**: It reads `settlement.py`, `test_settlement.py`, and `verify_ledger.py`, then runs `bash` to reproduce the two bugs (premature per-item rounding and pre-discount coupon threshold checking).
- **Turns 4-5**: It calls `write_file` to fix the code, then runs both `unittest` and `verify_ledger.py` in `bash` as required by the `SKILL.md` checklist.
- **Turn 6**: Once both commands return `exit_code=0`, it outputs the final summary and exits the loop.
