OpenProgram Docs

Agent loop guards

Stuck inGuard in openprogram/runtime/agent/loop/ActsResult
Repeated textguards._RepeatedTextGuardStream consumer, streaming.pyResponse discarded and asked again
Repeated tool roundstool_loop_guard.ToolLoopGuardAfter each tool round, loop.pyTurn ends with a notice
Tool calls written as texttext_tool_calls.recover_text_tool_callsWhen a reply ends, streaming.pyWritten calls become real ones
Repeated failing callfailure_policy and the tool executorEach tool call, tool_dispatch.pyThird identical failure is not run; a note answers it
Long stretch with nothing shownprogress_note.QuietStretchAfter each tool round of a turn somebody is watching, loop.pyAfter 6 rounds of tool calls only, one note for this turn asks for a few words of progress; nothing ends

A healthy turn is left alone. Nothing here caps output length, round count or wall time.

Repeated text

Checked on
A response offered tools; a bounded tail of its text
Trigger
The tail ends in one exact segment of 32–1024 characters, repeated at least 8 times over at least 2 KB
Raises
RepetitiveOutputError
Loop
Closes the provider effect, keeps every completed tool result, asks again with a user note to continue without repeating. Draws on the turn's shared recovery allowance.
Allowance spent
The error goes up, non-retryable, so Runtime.exec never replays completed tool effects in a new session

Repeated tool rounds

ToolLoopGuard counts consecutive rounds with the same calls, arguments and results. At TOOL_LOOP_REPEATS (8) the turn ends before the next request, with an error naming the call. The user's next message carries the conversation on.

Stopped: the agent made the same tool call 8 times in a row and got the same result every time …
ComparedHow
CallsName and arguments with keys in one order (failure_policy.repeat_key); bash's presentation-only description is ignored
ResultsError flag, text and image content. Text about the run itself is normalized: elapsed 1.2s, Wall time, duration_seconds
Resets the countA changed result; anything the user says mid-turn (steering)
Never a loopA round of only waits: a tool whose name has the word sleep, wait, delay, pause or poll (clock__sleep, waitForCi), or whose arguments are only a duration

Tool calls written as text

Deep into a long conversation a model may write calls in its chat template's shape instead of making them; nothing runs, the turn ends, and on "go on" it reads its own written call back and writes the next one the same way.

When a reply to a request that offered tools ends with no call, text_tool_calls.read_written_calls reads it from the first call-shaped tag.

Model familyShape read
Hermes, Qwen<tool_call>{"name": …, "arguments": {…}}</tool_call>; arguments an object or a JSON string
GLM<tool_call>name<arg_key>k</arg_key><arg_value>v</arg_value></tool_call>
Claude, MiniMax<invoke name="…"><parameter name="k">v</parameter></invoke>, bare or inside <function_calls> or <minimax:tool_call>
DeepSeek DSMLThe same invoke with |DSML| in each tag, one or two pipes of either width
CaseOutcome
Every block names an offered tool, arguments readableBlocks become ToolCalls; the reply ends as a tool-use turn
Text before the callsKept
Text after the callsDropped: a made-up result. The real one follows.
Parameter valueTaken as JSON when it is JSON, unless DSML marks it string="true"
Unknown tool, unreadable arguments, a tag in proseReply left as it was

Recovery runs in the stream consumer before the reply is committed, so context, durable record and UI all see the real calls. The tool-loop guard and text-call recovery follow magpie's (yetone/magpie, MIT).

Last updated · 2026-11-25