Work handed to a second model, which may not ask

subagent_run gives a self-contained piece of work to a helper carrying the
parent's connection, directory, model and effort, and hands its answer back as
the tool result. The mechanism is the one scheduled runs already use -- a hidden
chat, one turn, wake_chat, and a poll -- so tools, rounds, budgets, metrics and
steps all work with no second implementation. The two alternatives were
rejected where they had already been rejected once: a nested Generation is two
replies writing one transcript, and a one-shot complete() has no tools, which
schedule/runner.py records as useless for exactly this case.

Every restriction is a property of the child's row, applied by resolve_tools
after the gates, because a rule that lives in a system message is one a page the
model just read can argue with. No questions, no recursion, nothing that writes
unless the call asked for it and the parent's own mode would not have stopped
first, and commands only from a fixed read-only list -- in every mode including
Auto, because the task text can have come from a page.

Withdrawing ask_user turned out to be half of "nobody is watching". An approval
still built a card nobody could see and parked the reply until approval_timeout,
which from every screen is the feature not working. Chat.unattended is the
question now, and not the kind: _authorise answers with a refusal instead. A
scheduled task's chat had the same hole and is covered by the same flag.

Three bounds, counted where each is knowable: per reply on the parent's
Generation, instance-wide in a set a restart clears, and per helper in settings
of its own so one runs out of room long before the reply that asked. Past the
clock the helper is stopped rather than abandoned, so a partial answer comes
back with a sentence saying so.

Also: four gates had shipped into the scope menu with no name, taking the first
tool's label instead -- the canvas switch read "Canvas written". There is a test
that refuses a family without one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jaroslav Beneš
2026-08-06 15:05:30 +02:00
parent 0fa05c88b2
commit 46066150d9
17 changed files with 1850 additions and 13 deletions
+58
View File
@@ -31,6 +31,7 @@ PROMPTS = "prompts"
AGENTS = "agents"
IMAGES = "images"
SCHEDULES = "schedules"
SUBAGENTS = "subagents"
def _general_defaults() -> dict[str, Any]:
@@ -335,6 +336,43 @@ def _schedules_defaults() -> dict[str, Any]:
}
def _subagents_defaults() -> dict[str, Any]:
"""Delegating a piece of a reply to a second, unattended model.
Off until an administrator turns it on, for the reason agent execution and
scheduling are: a reply that may spawn helpers spends model time
multiplicatively, and on a single local endpoint four of them at once is
four times the queue rather than four times the speed.
Every number below is a **ceiling on one reply's helpers**, not a working
budget for one of them. The distinction is the one `Limits.steps` already
makes: a bound low enough to be reached by ordinary work stops the work
halfway instead of catching a runaway.
"""
return {
"enabled": False,
# How many one reply may spawn in total. Small on purpose: fanning out
# across four sub-questions is the use this exists for, and a reply that
# wants twenty has misunderstood the tool rather than found a use for it.
"max_per_reply": 4,
# Running at once across the whole instance. A subagent is a whole
# generation against the same endpoint the parent is waiting on.
"max_concurrent": 6,
# What one subagent may spend. Its own numbers rather than the chat's or
# the agent settings', because a helper answering one question is not
# the same shape of work as the reply that asked it: it should run out
# of room long before the parent does.
"max_rounds": 30,
"wall_seconds": 600,
"max_completion_tokens": 60_000,
# Whether the helper's own chat is kept after its answer is handed back.
# Off means it is deleted, which is what makes this cheap to use; on is
# for working out why one came back with something odd. Kept chats are
# temporary either way, so the day-old sweep still gets them.
"keep_transcript": False,
}
_DEFAULTS: dict[str, Any] = {
GENERAL: _general_defaults,
AUDIO: _audio_defaults,
@@ -343,6 +381,7 @@ _DEFAULTS: dict[str, Any] = {
AGENTS: _agents_defaults,
IMAGES: _images_defaults,
SCHEDULES: _schedules_defaults,
SUBAGENTS: _subagents_defaults,
}
@@ -506,6 +545,25 @@ def schedules(db: DBSession) -> dict[str, Any]:
return values
def subagents(db: DBSession) -> dict[str, Any]:
"""Subagent settings, clamped on read for the reason `agents` gives.
Zero is meaningful for `max_completion_tokens` alone — no ceiling on what
one helper writes — and is a floor of one everywhere else, because a
`max_per_reply` of zero is the feature switched off wearing the switch's
clothes, and that is a thing to answer in one place rather than two.
"""
values = get_group(db, SUBAGENTS)
values["max_per_reply"] = min(max(int(values.get("max_per_reply") or 1), 1), 20)
values["max_concurrent"] = min(max(int(values.get("max_concurrent") or 1), 1), 50)
values["max_rounds"] = min(max(int(values.get("max_rounds") or 1), 1), 200)
values["wall_seconds"] = min(max(int(values.get("wall_seconds") or 1), 30), 7200)
values["max_completion_tokens"] = min(
max(int(values.get("max_completion_tokens") or 0), 0), 5_000_000
)
return values
def images_ready(db: DBSession) -> bool:
"""Whether image generation can actually happen.