Repository navigation
Sub-agents: fixes from the whole-branch review - #317
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The fixes from the whole-branch review of the sub-agent work merged in #307-#316.
completedwith its answer, as on Deep Agents (it used to readinterruptedwith 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.agents/runs.py::run_ended) used by both event processors; one reader of the<instance>#<n>run-id format (run_numberbesiderun_instance);/agents <id>matches throughAgentRuns.record.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.