A child, some homework, and a parent at the table
A child sits down with a maths question: "What is 7 x 8?" They write "54". A parent glances at it and says, "Close, check your 8 times table." The child tries again and writes "56". The parent says, "Yes." Homework done.
Look at what made that work:
- The child does the writing. The parent checks. They are different people, and that matters: the child is the worst person to mark their own work.
- The parent gives feedback, not just "wrong".
- There is a limit. After a few tries, the parent says, "Let's go ask the teacher tomorrow."
- If the child writes "54" again and again, the parent notices the child is stuck and stops the loop early.
- Whatever happens, the question and the attempts are written in the exercise book, so tomorrow nobody has to remember.
- The child may use a calculator and a textbook but not the parent's wallet.
Those six points are the whole of this post. A "loop" in agent engineering is the child and parent at the table. This is Part 2 of three; Part 1 covered the five subsystems and the shift handover. The example here is the homework table, and the Java code is named after it.
1. From repeated prompts to an explicit loop
Without a loop, a person types "try again" many times. With a goal loop, the harness does it:
flowchart LR
G@{ icon: "algomi:svc-cube", label: "Goal", pos: "b", h: 52 }
E@{ icon: "algomi:svc-cube", label: "Execute", pos: "b", h: 52 }
V@{ icon: "algomi:svc-decision", label: "Evaluate", pos: "b", h: 52 }
G --> E --> V
V -->|not done| E
D@{ icon: "algomi:svc-cube", label: "Complete", pos: "b", h: 52 }
V -->|done| DReading the diagram. It's the homework table in three boxes:
- Goal: "What is 7 x 8?"
- Execute: the child writes an answer.
- Evaluate: the parent checks it. The diamond has two exits. Done ends the loop, and not done sends the child back to try again.
This diagram is deliberately bare. It shows the loop shape but none of the safety features, which is exactly the trouble with a plain while (true). The fuller version below adds them.
flowchart LR
G@{ icon: "algomi:svc-cube", label: "Goal", pos: "b", h: 52 }
B@{ icon: "algomi:svc-decision", label: "Budget left?", pos: "b", h: 52 }
G --> B
ESC@{ icon: "algomi:svc-cube", label: "Escalate: ask the teacher", pos: "b", h: 52 }
B -->|no| ESC
E@{ icon: "algomi:svc-spark", label: "Execute: write an answer", pos: "b", h: 52 }
B -->|yes| E
V@{ icon: "algomi:svc-decision", label: "Evaluate", pos: "b", h: 52 }
E --> V
D@{ icon: "algomi:svc-cube", label: "Complete", pos: "b", h: 52 }
V -->|done| D
S@{ icon: "algomi:svc-decision", label: "Same wrong answer as last time?", pos: "b", h: 52 }
V -->|not done| S
S -->|yes: stalled| ESC
FB@{ icon: "algomi:svc-cube", label: "Record feedback in the exercise book", pos: "b", h: 52 }
S -->|no| FB
FB --> B
You've reached the free preview of this post.
Subscribe to the Blogs plan (₹99/mo) — or use any Algomi Suite, Career, Investor, or Trader plan — to keep reading.
See plans