an-agent-loop-that-will-not-stop

Find why an agent keeps replanning past its budget — usually because nothing it called ever said plainly that it had succeeded.

Procedure

  1. start start. Goes next to s1
  2. check Count the iterations that actually ran. Goes on_fail to s9; next to s2
  3. decision Past the budget, or stuck inside one call?. Goes if one_call to s9; if default to s3
  4. check Read what the last tools returned. Goes on_fail to s9; next to s4
  5. decision Could success be recognised at all?. Goes if ambiguous to s5; if default to s6
  6. action Make one tool say plainly that it worked, RW (reversible-write). Goes on_fail to s9; next to s6
  7. decision Is any tool's output crowding the window?. Goes if verbose to s7; if default to s8
  8. action Return less, and only what is used, RW (reversible-write). Goes on_fail to s9; next to s8
  9. action Give it a way to stop and ask, RW (reversible-write). Goes on_fail to s9; next to __end_success
  10. escalate Escalate with the trace. Terminal
  11. end success. Terminal

Open the graph on its own page — larger, printable, and an address you can send.

Walk it without running it — you answer what your environment would answer, and the path, the capabilities, the approvals and the distance back to an undo come out of the document. Nothing executes; there is no Run button here and there will not be one.

Trust

T2 · attested 2026-10-11 · runbooks.directory

Nobody has attested this record. That is the ordinary case: T2 is what the catalog can check on its own, and T3 needs somebody to run the procedure and sign for it.

  • Link liveness has not been checked: it needs a network and the catalog builds without one. Run pnpm gates --online where there is one.

Steps

  1. s1 check — Count the iterations that actually ran
  2. s2 decision — Past the budget, or stuck inside one call?
  3. s3 check — Read what the last tools returned
  4. s4 decision — Could success be recognised at all?
  5. s5 action — Make one tool say plainly that it worked (reversible-write)
  6. s6 decision — Is any tool's output crowding the window?
  7. s7 action — Return less, and only what is used (reversible-write)
  8. s8 action — Give it a way to stop and ask (reversible-write)
  9. s9 escalate — Escalate with the trace

Capabilities

This is a privilege request. Check it against your own allowlist before running.

    Provenance

    Source
    https://github.com/microsoft/ai-agent-runbooks/blob/083f33eec889/02-patterns/Agentic-Workflow-Orchestration/Agentic-Workflow-Orchestration-Runbook.md
    Fetched
    2026-09-04
    Source last checked
    not since it was captured on 2026-09-04 — recorded as current
    Licence
    MIT
    How it got here
    Rewritten here from the source above, under its licence. The words and the steps are this catalog's; the procedure it describes is not this catalog's invention, and the source is where to check it.
    Highest risk in this procedure
    reversible-write

    Take it with you

    Run it under supervision

    Runs here, on your machine, under supervision: every step is proposed before it happens, an approval gate stops for you, and a failed expectation goes where the procedure says rather than on to the next step. Nothing is sent anywhere. To supervise an agent that is doing the work instead, runbooks hook sits in its tool-call path.

    npx @runbooks/cli run adapted/an-agent-loop-that-will-not-stop@1.0.0 --as "$(whoami)" \
      --input session=<the run that would not finish> \
      --input budget=<how many tool calls it was supposed to be allowed>