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
co-authored by Claude Opus 5
parent 0452e742e8
commit bf9287493b
12 changed files with 491 additions and 45 deletions
+15 -9
View File
@@ -50,16 +50,22 @@ log = logging.getLogger(__name__)
# instead, which is two orders of magnitude larger, because an agent reply is
# meant to run until the work is done.
#
# One, deliberately. A plain conversation asking a question is one round of
# looking things up and then an answer; the rounds after that were a small model
# that had decided searching was the answer searching until the context ran out,
# at a full request each. Several tools can still be called *within* that round,
# which is the thing worth telling the model -- see `core.rounds`.
# A **ceiling, not a schedule.** The loop 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 same termination condition every agentic harness uses. This number only
# catches the case where it never says so: a small model that has decided
# searching is the answer, searching until the context runs out at a full
# request each.
#
# The trade is real and worth naming: a chat can no longer search and then read
# one of the results, because reading is a second round. That is what an agent
# chat is for.
MAX_ROUNDS = 1
# It was briefly 1, which is low enough to stop being a ceiling and start being
# a schedule: it overrode the model's judgement on every turn rather than
# catching a runaway. Worse, 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.
#
# `settings_store.chat_rounds()` is what the loop and the harness read; this is
# the fallback for callers with no session, and a test pins the two together.
MAX_ROUNDS = 5
# Tool families, matching the per-model capability flags and the permission
# keys. The three names differ by prefix only, which is deliberate: adding a