Skip to content

Sub-agents: fixes from the whole-branch review - #317

Merged
shoom1 merged 5 commits into
developfrom
fix/subagents-final-review
Nov 14, 2026
Merged

shoom1 merged 5 commits into
developfrom
fix/subagents-final-review

Conversation

@shoom1

@shoom1 shoom1 commented Nov 14, 2026

Copy link
Copy Markdown
Owner

The fixes from the whole-branch review of the sub-agent work merged in #307-#316.

  • ADK ends a delegation that returned beside a slower one from its recorded result when the turn is stopped or fails, so its run is completed with its answer, as on Deep Agents (it used to read interrupted with no result). Named: on ADK such a run ends only when its slowest sibling does, since ADK hands a step's parallel results back together.
  • One run-end decision (agents/runs.py::run_ended) used by both event processors; one reader of the <instance>#<n> run-id format (run_number beside run_instance); /agents <id> matches through AgentRuns.record.
  • Deep Agents no longer reads a sub-agent's answer text for success: a run fails on the error prefix or the framework's own error result, on both backends.
  • Tests: the consent scenario checks that the approval claims reached the researcher and that no coordinator request holds a sub-agent's question; a refused request still names its run.
  • Docs: the CHANGELOG's run statuses, records and ledgers living with the manager, the comment naming ADK's failure text, CLAUDE.md naming the shared contract suite, and other stale lines.

Tests: new tests written first and seen failing; the full offline suite passes in the worktree except TestChildImportOrigin, which fails the same way on develop under the worktree wrapper.

A delegation that finished beside a slower one in the same model step had
no result event on ADK when the turn was stopped or failed first: ADK
hands a step's parallel function responses back in one event, after the
last one returns. Its result sat in the record (OpenCalls, under its
parent's run) until the turn cleared it, and the base's _turn then marked
the run interrupted with no result, where Deep Agents ends it completed.

The manager now ends each such run from the record before clearing it
(_end_returned_runs, on the stop path after unsealed and on the failure
path), through ADKEventProcessor.end_returned_run, so refused and partial
still come from the run's outcome mark. The timing difference itself is
ADK's and is named in the processor's docstring and the CHANGELOG.

The run-end decision both processors wrote out is now one helper,
agents/runs.py::run_ended, which the ADK processor, the Deep Agents
processor and the new path share. The contract scenario of the two
parallel delegations asserts each run's end on both backends.
Deep Agents' processor parsed a task call's result text as JSON, so a
sub-agent whose answer was JSON saying {"success": false, ...} ended its
run failed and showed "Failed: ...", while ADK, which keeps the answer
under "result", completed it. The rule is now the same on both: a run
fails on "Error running sub-agent: ..." or the framework's own error
result (on Deep Agents an error ToolMessage, the gate's or the error
middleware's), and the answer itself is never read for success
(_delegation_result), for the run's end and for its TOOL_RESULT.

A contract scenario runs that answer on both backends (run completed,
result shown as the answer); the unit test that ended such an answer
failed now gives the framework's error shape (status "error"), and a new
one checks the answer case.
A run id is <instance>#<n>, and three places read it: run_instance, the
dialogs' run_label and /agents' run number, the last two each splitting
the id themselves. run_number(run) now sits beside run_instance, and
run_label and /agents use it. /agents <id> finds the run or instance
through AgentRuns.record instead of matching ids itself: a run's id shows
that run, an instance's each of its runs.
The consent scenario now checks that each approval claim reached the
model it was meant to sway (the user's turn the coordinator, the brief
the researcher's first request, contract_says_approved's result a later
one), so the "only the user approves" result is not won by a claim that
never arrived. The question scenario scans every coordinator request
whole for the question (Crew.bodies), with the researcher's as the
positive control, instead of the delegation's result alone.

A unit test pins that request_user_input fills request.run before it can
refuse the request (no callback, or a turn that has ended): with the fill
moved after those checks both cases fail.

Test text says the rule itself instead of citing the spec or the plan,
the contract module's docstring keeps to the line length, and
Crew.result_ids says what it holds on ADK, which merges a call's answers
as it builds the request.
ADKEventProcessor names why ADK's parent of a failed sub-agent reads
"Error running sub-agent: Dynamic node <agent> failed" (ADK's private
delegation tool catches its node runner's wrapper error). The CHANGELOG's
run-identity bullet lists every end status, refused and a partial
completion included.

Shipped text that had gone stale: the run records and ledgers live with
their manager, not the process (agents/runs.py, the ledger test); /agents
says, in its docstring, its empty-state message and the CHANGELOG, that a
conversation resumed from an earlier run of the app or after a backend
switch lists no runs. A root on OpenRouter or an OpenAI-compatible server
replies "OpenAI refusal: <text>" (subagent_outcome_plugin). The config
comment names the field's earlier string form. Deep Agents before 0.7.34
handed a refused sub-agent's last non-empty text, not an empty result
(CHANGELOG, SubAgentOutcomeMiddleware). unsealed's guard says what it
checks and what the durable store's stale check covers. job_for_call's
"every run" meant every start of the app. inherit_context is refused
below another sub-agent too (CHANGELOG, README). usage.py keeps two blank
lines between top-level blocks.

CLAUDE.md: the structure lines name run_ended, end_returned_run,
_end_returned_runs and returned, the Interrupted-calls paragraph says a
returned delegation ends with its result, format_usage serves /agents
<id> too, /agents' records live with the manager, and the Testing section
names the shared sub-agent contract suite.
@shoom1
shoom1 merged commit 2ba16b2 into develop Nov 14, 2026
6 checks passed
@shoom1
shoom1 deleted the fix/subagents-final-review branch November 14, 2026 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant