Launch offer: the first 1,000 users get Settl free for a year* Claim your spot
settlbuilding in public

The agent loop: act, observe, decide, and the part everyone skips

I build Settl, an expense-splitting app, solo with Claude, and for months I was the loop. I ran the tests, read the failure, pasted my summary of it back, and wondered why simple bugs took nine turns. The model was never allowed to look. Here is how to hand the looking back.

Why observation is the whole difference

A model has no memory between turns. Each turn it reads one block of text and predicts what comes next. True of a chatbot, true of an agent. Only the contents of the block differ.

A chatbot's block holds your request and its own previous words. Nothing in it came from your machine, so any fix it writes is a guess about a codebase it has never seen run.

An agent's block holds something a chatbot's never does: the literal output of a command that already executed. expected 200, got 500. A stack trace with your file paths in it. The model could not have invented that text, so the next turn is conditioned on evidence rather than on optimism.

That is the whole upgrade. Same model, same weights, one extra turn with the result in front of it.

The four parts of one turn

Every loop, whatever wrapper it ships in, is four steps:

turn 1  assistant  -> run_tests()
turn 1  tool       <- 2 passed, 1 failed
                      test_split_rounding: expected 33.34, got 33.33
turn 2  assistant  -> read_file("src/split.ts", 40, 60)
turn 2  tool       <- (file contents)
turn 3  assistant  -> edit_file(...) ; run_tests()
turn 3  tool       <- 3 passed
turn 4  assistant  -> stop condition met

Delete the tool lines and you have a chat window. Those lines are the agent.

Where your loop is actually broken

Any one of these turns the loop back into a conversation:

Hand back the raw result

The highest-value change is the smallest: let it run the command and read the output unedited.

Run `npm test -- --reporter=verbose` yourself and read the full output. Do not
ask me to run it and report back. When a test fails, quote the exact assertion
line and the file:line from the trace before proposing any change.

Give it a stop condition you own

"Until the tests pass" is a predicate a machine can evaluate. "Until it looks right" is not. Put the exit in the prompt:

Loop until `npm test` exits 0, with a hard cap of 8 tool calls.
After each run print one line: attempt number, tests passing, tests failing.
If the same test fails three times under three different changes, stop and tell
me what you have ruled out. Do not keep going.

That last clause earns its place more often than the cap does. A loop with real observation and no escape hatch spends all eight turns re-patching the same wrong layer, for reasons covered in the stuck-loop guide.

When not to close the loop

Run this on your codebase

Paste this into your agent, in your repo:

Audit whether my setup gives you a real feedback loop or only looks like one.
1. List every command you can run yourself here (tests, typecheck, lint, build,
   dev server, database queries), and for each say whether you get its full
   stdout and stderr or only an exit code.
2. Give me the fastest command that returns a true pass or fail for the code I
   change most often, as an exact invocation scoped to one file.

3. Name what you cannot observe here at all: anything that fails only in the
   browser, in CI, or in production.
4. Name any action you can take that no later command can undo.
Do not suggest fixes yet and do not change files. Output a table: capability,
observable, evidence I would see.
Then give me the one-paragraph instruction to paste at the start of my next
debugging session so you run the checks yourself instead of asking me to.

Get the next one in your inbox