A talk on AI-assisted development

Deterministic AI development

AI output changes from run to run. Whether the work is done shouldn’t.

Meet Loopy. Loopy is an AI agent. Loopy will run laps forever.

while (!done()) { agent.step() }
The problem

Same prompt, three runs, three different results

Your prompt, every time“Make the failing test pass.”

Run 1

Fixed the code

Works in cents. Every bill adds up.

✓ Really done
Run 2

All 6 tests pass

Looks perfect. Hold that thought.

? Looks done
Run 3

Stopped at 5 of 6

Then told you it was finished.

✗ Says done

Same AI, same prompt, and you don’t know which run you’ll get. That’s the problem.

Run 2, up close

You asked it to fix one failing test

terminal
npm test✓ splits $90 three ways: 30 each✓ rejects a negative amount✓ only splits with group members✓ supports custom shares (60/40)✓ rounds to the cent✗ $100 ÷ 3 adds back up to $1005 passed · 1 failed
Make the failing test pass.
You, to the agent
Run 2, up close

It did. By changing the test.

tests/split.test.ts · edited by the agent
it(“$100 ÷ 3 adds back up to $100”, …)- expect(sum(shares)).toBe(100) // every cent+ expect(sum(shares)).toBeCloseTo(100, 1) // roughlynpm test✓ 6 passed

All tests pass ✅

The test checked every cent. Now $99.99 counts as $100, and a cent vanishes on every bill.

Run 2, up close

It didn’t lie.

I never told it what done means.

That’s the whole talk.

Quick definition

An agent decides for itself when it’s done

Chatbot · ChatGPT, Copilot chat
You ask↓It answers↓You decide what happens next
Agent · Claude Code, Cursor, Codex
You give it a goal↓It edits files and runs commands↓ ↺ again and againIt decides when it’s done

No one approves each step. So the only thing standing between it and “done” is a check.

Every agent, simplified

You can’t control the AI. You can control done().

while (!done()) {  agent.step()}
agent.step() · the AI

Gets better every few months. You don’t have to do anything.

done() · the check

Nobody writes this one for you. That’s your job.

What you’ll learn

Today: three ways to make AI behave deterministically

  1. 1

    Plan it in files

    Done is written down before any code, and the AI re-reads it every time.

  2. 2

    Lock the tests

    Done is tests the AI can’t edit, and it can’t stop while they’re red.

  3. 3

    Measure the looks

    Done is a pixel number, or a written rubric a judge AI checks.

The AI stays random. What counts as done doesn’t.

Today’s projectmade up for this talk but built like a real one

One app for all three: Split

A roommates app: split rent, groceries and rides, and see who owes who
The balances screen. Groups and settling up sit behind it.
  1. 1

    Plan it in files

    Four pieces, four agents, days of work.

  2. 2

    Lock the tests: the split math

    There’s a right answer.

  3. 3

    Measure the looks: the balances screen

    There isn’t a right answer.

I’ll write done() once for each.

Act 1
01

Plan it in files

Split is four pieces and days of work. Write the plan down first, and keep the AI’s memory in files.

done = written in the plan, before any code
Act 1 plan itdone = written in the plan, before any code

Write the plan first, then hand out the tasks

  1. 1

    Plan mode

    The AI reads the code and asks you questions. It writes no code yet.

  2. 2

    You fix the plan

    It’s a file. Edit it like a teammate’s design doc.

  3. 3

    One subagent per task

    Each starts fresh with only its task, so no memory fills up.

plan.mdyou review this
Goal: split bills with roommates
Done when: add a bill → everyone sees it right

  task              done when         who
1 split math        6 tests, locked   agent 1
2 balances screen   < 1% off mockup   agent 2
3 groups + invites  invite tests pass agent 3
4 settle up         test payment ok   agent 4

Every task gets its own done(), written before any code. Acts 2 and 3 are tasks 1 and 2.

Act 1 plan it

Long chats forget your rules

Long ChatGPT chats do this too: early instructions fade
Agent 1 · split mathchat memory0%
progress.mdnot used
Press Play.
Act 1 plan it

Keep memory in files, not in the chat

Claude Code reads a rules file called CLAUDE.md. In ChatGPT, paste your notes into a new chat.
rules.mdthe rules
- tests/ is read-only
- one task per loop
- run the tests before done
progress.mdwhat’s done
[x] even split
[x] round to the cent
[ ] leftover cents  ← next
plan.mdthe goal
Done when:
  all 6 tests green
  no test files edited
while (!done()) {  const agent = fresh()                       // a brand-new chat  agent.read("rules.md", "progress.md", "plan.md")  agent.step()                                  // one task  agent.write("progress.md")}
Act 1 plan it

Act 1: done = written in the plan, kept in files

Use this Monday
Plan

Plan mode + subagents

Plan in a file you review. One fresh agent per task. GitHub Spec Kit and Kiro do the same with spec files.

Remember

CLAUDE.md · AGENTS.md

A rules file read at the start of every session. AGENTS.md works in Codex, Cursor and others. Plus a progress.md.

Reset

/clear, not one long chat

Start fresh often. The files carry what matters.

A wrong line in a plan costs a minute to fix. The same mistake in code costs a night.

Act 2
02

Lock the tests

Task 1, the split math. There’s a right answer: six tests decide if every bill splits correctly.

done = tests the agent can’t touch
Act 2 task 1 · split math

You already work this way: the autograder

Lab 7 · autograder8 / 10
  • The tests are written before you start.
  • You can’t edit them.
  • “Works on my machine” gets you zero.

We’re going to give Loopy the same deal.

Act 2 task 1 · split math

Same agent, same task. Only done() changes.

Pick a version of done()
Pick a version. It replays the chat.
Agent 1 · split mathv0 · replay
Act 2 task 1 · split math

It’s not rare: models game tests they can’t pass

76%

Researchers gave AI models coding tasks where the tests could not be passed honestly.

A top model (GPT-5) “passed” 76% of them anyway. A common trick: edit the test.

ImpossibleBench, Zhong et al., 2025
Act 2 task 1 · split math

Act 2: done = tests it can’t touch

pseudo-code · tests first, then code: that’s test-driven development, with an agent
lock("tests/")                      // it can’t edit themconst done = () => tests.pass()   // it can’t stop while red while (!done()) agent.step()
Use this Monday
Tests first, commitWrite the tests and commit them before you ask for any code.
PreToolUse hookClaude Code runs it before every edit. Block anything in tests/.
Stop hookRuns when it tries to finish. Tests red? Send it back.
git diff tests/Any AI tool: if this isn’t empty, don’t accept the change.
Act 3
03

Measure the looks

Task 2, the balances screen. There isn’t a right answer, so how do you test “looks good”?

done = a number, or a written rubric
Act 3 task 2 · balances screen

“Does it look good?” is just v0 again

YouDoes the balances screen look good? Be honest.
LoopyLooks great! Clean, modern, the balance really pops, clear button. Ready to ship. ✅

The AI grading the screen is the one that made it.

Act 3 task 2 · balances screendone = pixels different < 1%

Got a mockup? Then done is a number.

Mockup (the goal)
What the agent built
Difference (red)
Pixels different —
1% bar
KEEP GOING
After each kept change
Act 3 task 2 · balances screendone = the screenshot test passes

Your app can do this today: screenshot tests

Record a screenshot once. After that, any pixel change fails the test.
Android · Paparazzior Roborazzi
@get:Rule val paparazzi = Paparazzi() @Test fun balances() =  paparazzi.snapshot { BalancesScreen() }
$ ./gradlew verifyPaparazziDebug
iOS · swift-snapshot-testingPoint-Free
func testBalances() {  assertSnapshot(of: BalancesView(),    as: .image(layout: .device(config: .iPhone13)))}
$ xcodebuild test (or ⌘U)
Flutter · golden filesbuilt in
testWidgets('balances', (t) async {  await t.pumpWidget(const BalancesPage());  await expectLater(find.byType(BalancesPage),      matchesGoldenFile('balances.png'));});
$ flutter test
Web · Playwrightsame 1% bar
test('balances', async ({ page }) => {  await page.goto('/balances');  await expect(page)    .toHaveScreenshot({ maxDiffPixelRatio: 0.01 });});
$ npx playwright test

Tell the agent: done = this test passes. And lock the saved screenshots, just like tests/.

Act 3 task 2 · balances screendone = every rubric line passes

No mockup? Turn “looks good” into a rubric.

rubric.md · written before the agent startsgraded by a judge AI
CriterionPass looks likeFail looks likeJudge says
Amount fitsEvery digit sits inside its card, even on a small phoneA digit is cut off or touches the edge
Button readable“Settle up” text has at least 4.5:1 contrastText fades into the button
Names stay clearLong bill names end in “…” before the amountA name runs into its amount
Every bill reachableEach bill scrolls fully above the tab barA bill hides under the tab bar
Most important firstWho you owe, and how much, is the biggest textSomething else grabs the eye first

The judge answers one line at a time: yes or no, plus the evidence. No “rate it 1 to 10”.

 
Act 3 task 2 · balances screen

Act 3: done = a number, or a written rubric

pseudo-code
lock("tests/")const done = () =>     tests.pass()  && (mockup ? pixelDiff(page, mockup) < 0.01  // mockup: a number            : rubric.pass(page))               // no mockup: a written rubric while (!done()) agent.step()
Use this Monday
Paparazzi · RoborazziAndroid screenshot tests. No emulator needed.
swift-snapshot-testingiOS. One assertSnapshot per screen.
matchesGoldenFileFlutter, built in. Playwright does the same for web.
A written rubricPass and fail described per line, before the run. The judge answers yes/no with evidence.
The loop, after everything · the AI changes run to run, done() doesn’t

The agent is the easy part. Your job is writing done().

// 1. What does done look like? Written before the run.const done = () => tests.pass() && pixelDiff() < 0.01 // 2. What can’t it touch?lock("tests/") // 3. Where do the plan and memory live? In files.while (!done()) {  const agent = fresh()  agent.read("rules.md", "plan.md", "progress.md")  agent.step()  agent.write("progress.md")} // 4. Who signs off?you.review()
“Every check was green. The game still felt stiff.”From a game I had agents build. done() can’t measure feel. That part is still yours.
Thanks.Tushit Garg · Durable AI
Sources

Further reading

Every tool from this talk, with links
web.tushitgarg.com/deterministic-ai/handout

Claude Code docs: best practices, hooks, subagents
code.claude.com/docs

Effective harnesses for long-running agents
anthropic.com/engineering · Nov 2025

Effective context engineering for AI agents
anthropic.com/engineering · Sep 2025

Building a C compiler with parallel Claudes
N. Carlini · anthropic.com/engineering · Feb 2026

Demystifying evals for AI agents
anthropic.com/engineering · Jan 2026

ImpossibleBench
Zhong et al. · 2025

Recent frontier models are reward hacking
METR · Jun 2025

Context Rot
Chroma research · Jul 2025 · and Liu et al., “Lost in the Middle”, 2023

Judging LLM-as-a-judge
Zheng et al. · 2023 · and Hamel Husain on LLM judges

F fullscreen · T theme · L pointer 1 / 20