AGENTICAMIT // LOOP ENGINEERING · WORKED the same machine, given a real job

AgenticAmit // worked example // sheet 2 of 2

One task, five turns.

Same ring as the schematic, now with real work on it: an agent fixing a flaky test, start to finish. Nothing on the ring is clever. Scroll, and see why it doesn't need to be.

Stage 01// ingestturn 01 · step 1 of 6

It packed light, on purpose.

Out of the whole repo: two files, one memory, three tools. Everything else stayed outside the window.

the packing list, verbatim

task    fix the flaky retry test
files   src/retry.py         1.2k
        tests/test_retry.py  0.8k
memory  "flaked 3x this week,
         always on slow CI"
tools   run_tests · read_file · edit_file

// the skill here was leaving the rest of the repo out.

Stage 02// assemblestep 2 of 6

The window, itemized.

This is the entire world the model will see this turn. Rules first, the ask last: recency is weight.

the assembled window, block by block

[system]     8.0k  rules + tool schemas
[history]    0.0k  first turn, empty
[knowledge]  8.9k  both files + the memory
[ask]        0.1k  "fix the flaky retry test"
─────────────────────────────
window      17.0k of 64k

// prompt = f(context). Can't diff it, can't debug it.

Stage 03// model callstep 3 of 6

It talked, then it asked.

The reply is just tokens: a thought, and a request. Note what it did not do: guess at a fix.

the reply, raw blocks, nothing run yet

text  "The failure is timing-shaped:
       test_backoff asserts elapsed
       < 0.3s. Reproducing it before
       touching anything."
tool_call  run_tests(
    path="tests/test_retry.py")

// a tool call is a sentence until something executes it.

Stage 04// parse & routestep 4 of 6

Two blocks, two lanes.

The parser doesn't understand the plan. It only sorts blocks: words to the transcript, calls to the sandbox.

the routing table for those two blocks

block 1  text       → say it
block 2  tool_call  → run_tests
routed    1 say · 1 call
malformed 0  // errors go back around

// on a bad turn, "malformed" is the row that saves the crash.

Stage 05// execute + observe

There's the flake, red-handed.

The agent didn't theorize. It ran the suite inside the wall and watched: 0.312 seconds against a 0.3 limit.

the sandbox terminal, exactly as observed

$ pytest tests/test_retry.py -q
....F
FAILED test_backoff_under_300ms
  AssertionError: 0.312 >= 0.3
1 failed, 4 passed in 2.41s

// an observation beats a theory. Every turn.

Stage 06// compact + verify

Keep the lesson, drop the log.

Four kilobytes of test output became one sentence. The checklist moved by exactly one line.

the state diff: kept vs dropped

+ "repro: jitter can push backoff
   past the 0.3s assert"
- 4.1k of raw pytest output
todos  ✓ reproduce the failure
       · locate the cause  // next

// compaction is lossy on purpose. What survives is a design decision.

The gate// continue or exitend of turn 01

Not done. That's the design.

One turn produced one verified fact. The gate sends it around again, carrying everything it learned.

the gate, evaluated on real state

state.done() ?
  todos   1 of 5 complete
  suite   still red
False · around again

// exit on verified todos, not on the model feeling done.

That's one turn. One verified fact.

four laps to green

Turns 02–05// same ring, compounding

Turn one took the whole page.

The next four take one lap each, because every lap starts with the last one's lesson already in the window.

  • reproduce the failureturn 01
  • locate the causeturn 02
  • write the patchturn 03
  • re-run the suiteturn 04
  • write it upturn 05

// the bad patch on turn 04 was caught by the same gate you just watched say no.

Return// gate open5 turns · ctx 42k

The answer, with receipts.

A one-line fix, a green suite, a written summary. Out through the gate, the only way there is.

the fix and the green run

- assert elapsed < 0.3
+ assert elapsed < 0.3 + JITTER_CAP
5 passed in 2.38s ✓

The drawing, re-inked

Nothing was magic. That's the point.

Every station did something a careful junior could do: pick two files, order a window, run the tests, keep one lesson. The intelligence is in the lap, not the stop. That is loop engineering, worked.

One Task, Five Turns · companion to the Loop Engineering schematic · an AgenticAmit engraving.