A model plus a harness
Wrap your tool loop in the parts that make it usable: instructions in a file, a permission question, a budget and a log.
You build: harness.py: your loop from lab 13 that asks before it writes, stops at a budget, and logs every message.
- Python 3.11 or newer and uv
- An OpenRouter key (free models are enough)
- Lab 13 done
-
01Move the instructions into SYSTEM.md and load them at start
uv run --with openai harness.py "What are your rules?"You pass when: It answers from SYSTEM.md. Change a rule in the file and the answer changes with no code edit.
-
02Add a write_file tool that asks y or n before it runs
Reading is safe to allow. Writing, running commands and spending money ask first. That one split is most of agent safety.
uv run --with openai harness.py "Create notes.txt with one line saying hello"You pass when: It asks before writing. Answer n: no file appears and the model is told it was refused.
-
03Stop the run at a turn limit and a token limit
uv run --with openai harness.py --max-tokens 2000 "Read every file here and summarise each one"You pass when: It stops with a clear message that the budget ran out, and says how far it got.
-
04Append every message and tool result to a log file
wc -l transcript.jsonl && tail -n 1 transcript.jsonlYou pass when: One JSON line per message, with a timestamp and token counts. You can replay a run from the file alone.
The check runs on the computer, not on your word: a step passes when its command exits with 0 there.
Computers are not set up on this site yet. Run each command on your own machine and compare with "You pass when".
Commands run in labs/30-harness and may take up to 60 seconds each. Every command starts a new shell: put keys and settings in a .env file there, it is loaded each time.