A ceiling for a chat, and a nudge for an agent that stops early

MAX_ROUNDS = 1 was wrong, and wrong in a way worth writing down. The loop
already ends the moment a round comes back with no tool calls -- that is the
model saying it has what it needs, and it is the termination condition every
agentic harness uses. A round limit was never a schedule; it exists to catch the
case where the model never says so. One is low enough to stop being a ceiling
and start being a schedule: it overrode the model's judgement on every single
turn.

And it broke something concrete. Several built-ins are two-step pairs --
knowledge_get and notes_get read a document "by the id a search returned" -- so
one round left the library searchable and not readable. That is not an edge
case, it is the library working at half depth, and I understated it as "cannot
search the web and then read a result" when the change went in.

It is a setting now, under General, default 5, with 0 meaning no ceiling. The
loop and the harness both read settings_store.chat_rounds, so the model is never
told a budget that is not its own; tools.MAX_ROUNDS is the fallback for callers
with no session and a test pins the two equal. core.rounds goes back to naming
the number, and vanishes entirely when there is no ceiling rather than promising
zero rounds.

The other half of "let it decide how long to go": an agent reply that ends while
its plan still has open tasks is asked once to carry on. Only against a plan,
because that is the one thing there is to be objectively wrong about -- a model
with no plan that says it has finished is believed, and arguing with it would be
guessing. At most twice in a row, with the count reset the moment it calls a
tool again, so the bound is on consecutive stops rather than on stops in total.
Never in Plan mode and never past plan_submit, which ends the turn on purpose.
Giving up is recorded as an event rather than left silent.

The model's own words go back with the nudge, which turned up a real bug on the
way: ReasoningSplitter holds back a few characters against a <think> tag split
across chunks, so round_text at the end of a round was missing its tail. That
text is echoed as an assistant turn for tool rounds too, so a model has been
occasionally asked to continue from a transcript where it trailed off
mid-sentence. Flushed per round now.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jaroslav Beneš
2026-08-03 12:41:36 +02:00
parent 816f2ae957
commit a5fa982ae3
13 changed files with 530 additions and 55 deletions
@@ -155,6 +155,21 @@
<input class="input" id="max_total_output_bytes" name="max_total_output_bytes"
value="{{ values.max_total_output_bytes }}" inputmode="numeric">
</div>
<div class="field">
<label class="checkbox">
<input type="checkbox" name="nudge_unfinished"
{{ 'checked' if values.nudge_unfinished }}>
<span>Ask it to carry on when it stops with tasks outstanding</span>
</label>
<p class="field__hint">
Only ever against a plan, and only while tasks on it are still open —
that is the one thing there is to be objectively wrong about. A reply
with no plan that says it has finished is believed. It is asked at most
twice in a row, and if it stops a third time that is recorded in the
transcript rather than argued with.
</p>
</div>
<div class="field">
<label class="field__label" for="max_steps">Most rounds of tool calls</label>
<input class="input" id="max_steps" name="max_steps"
@@ -64,6 +64,29 @@
</div>
</section>
<section class="card">
<h2 class="card__title">Tool calls in an ordinary chat</h2>
<p class="card__lede">
A model ends its own turn the moment it stops asking for tools — that is
it saying it has what it needs, and nothing here overrides it. This is a
ceiling for the case where it never says so.
</p>
<div class="field">
<label class="field__label" for="max-chat-rounds">Most rounds of tool calls</label>
<input class="input" id="max-chat-rounds" name="max_chat_rounds" type="number"
min="0" max="100" value="{{ values.max_chat_rounds }}">
<p class="field__hint">
Several tools can be called in one round, so this is not a count of
tools. Leave room for at least two: <code>knowledge_get</code> and
<code>notes_get</code> read a document by an id a <em>search</em>
returned, so a ceiling of one leaves the library searchable and not
readable. <code>0</code> means no ceiling, which is how an agent chat
already works — those are bounded under
<a href="/admin/agents">Agents</a> by time and tokens instead.
</p>
</div>
</section>
<section class="card">
<h2 class="card__title">
Registration