Harness engineering (TypeScript) · Chapter 12 of 23
Plans and todos
By the end of this chapter you can give a coding agent a todo list the harness keeps and shows back, so a task in parts gets done in parts; stop a run from ending while the list still has open items; and spot a todo tool that quietly loses an item. Build it in your browser: a real editor and terminal, AI that explains, and tests that tell you when it works.
- Part: Context
- 4 tasks
- TypeScript
- In the all labs plan
The first 2 chapters of Harness engineering (TypeScript) are free. This one comes with the all labs plan.
Why you need this
Sunita's shop sent one issue with two problems in it. That is T07:
Two problems from Sunita's shop:
1. `upiLink` puts the payee name in the link as it is, so 'Sharma
General Store' breaks the link. Encode it.
2. `reminderText` shows the amount as ₹123456.50. Reminders must group
the Indian way: ₹1,23,456.50.
Under the chapter's harness (list, read, an exact edit, a command tool, and a prompt that says to run the tests) the model fixes the first problem, runs the tests and stops:
list_files({}) -> .env ...
read_file(src/upi.ts) -> // UPI payment links, ...
edit_file(src/upi.ts, ...) -> ok
run_command(npm test) -> ... ℹ fail 1
answer: I could not get the tests to pass. reminder text
It never opened reminders.ts. Nandini sees T07 fail in the suite, and the reason is not a bad fix: the second part was never started. Real coding models drift the same way on long tasks, where the first part fills the context and the rest slips. Nothing in the harness so far remembers that the issue had two parts, and nothing stops the run when the model says it is done.
What you build: 4 tasks
Each task has tests. You write the code in the lab's editor and press Check.
- Task 1
todo-tool.ts: a list the harness keeps
Nandini wants the agent's plan written down where the harness can see it. In todo-tool.ts, export class TodoList (items starts as []) with write(args), the todo_write tool's function: it checks args.todos and returns, for a bad list, "error: todos must be a list of items", "error: every item needs a content", "error: status must be one of pending, in_progress, completed" or "error: only one item can be in_progress", changing nothing; for a good one it replaces items (content and status only) and returns show().
openItems() is the items not completed. show() is one line per item, "[x] text" for completed and "[ ] text" for the rest, then "(D of N done)".
Trap: what write returns is what the model reads back; it must show every item.
- Task 2
t07-both.ts: T07 with and without a plan
T07's issue has two numbered parts. In t07-both.ts, under if (import.meta.main), run T07 on a fresh checkout with runAgent and no extra tool, then on another with extra { todo_write: [SCHEMA, (a) => todos.write(a)] } for a new TodoList, and print one line per run, then the second run's list as show() gives it:
T07 no todo failed 5 steps
T07 todo_write passed N steps
Trap: give each run its own checkout and its own TodoList.
- Task 3
finish-guard.ts: no answer while items are open
In finish-guard.ts, export planFromIssue(issue): a TodoList with one pending item per numbered line of the issue ("1. ..." or "1) ..."), its content the text after the number. Export makeFinishGuard(todos, maxReminders = 1): an onAnswer for runAgent that, while todos has open items and fewer than maxReminders reminders were sent, returns
Your todo list still has open items:
[ ] 2. TEXT
Finish them before you answer.
(one "[ ] N. TEXT" line per open item, N its place in the list), and null otherwise.
Under if (import.meta.main), run T07 three ways, each with todos = planFromIssue(issue): plain, guard, and todo_write + guard (the tool writing into the same todos). Print one line per run: T07 plain failed 5 steps reminders: 0 (reminders are the trail lines starting with "(harness)").
Trap: with no budget, a list nobody ticks never lets the run end.
- Task 4 · interview question
Interview: lossy-todo.ts, a todo tool that loses an item
A teammate's ShortList shows the todo list in fewer lines, and T07 fails with it: the model wrote both parts, fixed the first and never touched the second. Run lossy-todo.ts, read what todo_write sent back, and fix ShortList's show() so it shows every item ("[x] text" or "[ ] text") and then the count "(D of N done)". Keep the prints: fixed, the last line is T07: passed.
Trap: the count still says 2 items. Only the lines show which one went missing.
What you will learn
- A todo tool: the model writes its plan as items with a status.
- The harness keeps the list, checks it and shows it back after every write.
- A finish guard: an answer while items are open gets a reminder instead of ending the run.
- A plan from the issue: the numbered parts as the harness's own list.
- Trusting what is shown: the model works from the list it sees.
More in Context
Build "Plans and todos" yourself
Hisaab, a Lucknow invoicing startup, wants a coding agent to clear its bug list. You build its harness in TypeScript and score it on twelve tasks. A real editor and terminal in your browser, AI that explains, and a Check that says when it works.
The first 2 chapters of Harness engineering (TypeScript) are free. This one comes with the all labs plan.