2026-08-28·作者 Sijie Wang#cybernetics#engineering

loop-termination-is-a-gate

#thread/agent-loop

The agent loop (GPT and Claude share the skeleton): model → tool calls → feed results back → repeat → stop. They differ mainly in who owns the loop — raw API (you drive it: finish_reason/stop_reason) vs managed (OpenAI Assistants/Responses "runs", Anthropic Agent SDK / Claude Code).

The crux is termination: who decides "done"? In a vanilla loop, the executor (model) self-certifies completion (end_turn / finish_reason=stop). That is the unreliable point — the same nerve as this whole vault: a stochastic executor self-declaring success is exactly what you can't trust (gatekeeper-not-driver).

Three ways to control termination = three of the eight controls (control-methods):

  • trust the executor (vanilla loop)
  • meter it — max-iterations / timeout (StandMeet's force-final-answer; control #4)
  • gate it — keep going until a condition holds (/goal; control #2)

/goal = a semantic gate on the loop's exit (confirmed from docs)

/goal <condition> is a session-scoped prompt-based Stop hook. After each turn, (condition + transcript) is sent to a separate, fresh small model (Haiku by default) that returns yes/no + a reason; not met → reason fed back, loop continues.

  • Generator ≠ verifier, productized. The model doing the work is not the one judging it done — a fresh evaluator with no ego in the work. recognizer-not-generator made real; the docs name it as the safeguard against "the model that wrote the code declaring it correct."
  • verify-cheaper-than-execute, literal — the judge is a cheap small model; eval tokens negligible vs the work.
  • Limitation (honest): the judge only sees the transcript — it can't run tests or read files. So it judges claims + visible output; a semantic gate is gameable by what you can plausibly surface (Goodhart). Hence "write the condition as something the output can demonstrate."

Two kinds of gate (the eval-is-type-system split)

  • mechanical gate (scripted hook, exit code): deterministic, reliable, but only codifiable predicates (test passed, file exists).
  • semantic gate (/goal's LLM judge): handles fuzzy "done" (e.g. "each paper is A-grade"), but the judge is fallible. De-biased by separation (different model, empty context), not by being infallible.

→ Termination is the load-bearing decision of any agent loop, and a gate there (mechanical or semantic) is how you stop trusting "I'm done."

关于这一条

sijie 的一条 wiki 条目。本站的 AI 以同一套语料库为依据、以 sijie 的口吻作答,并附有指向此类条目的引用——回答会花 sijie 的钱,所以它在访问码后等待: 输入访问码 →