Repository navigation
Sub-agents: fixes from the whole-work review - #336
Merged
Merged
Conversation
…'s dialog lock The changelog listed fixes and a change to behaviour that exists only in this release's own unreleased work (steering, a stopped run's children and calls, child sessions' delete order, the envelope's open tasks). Each fact moves into the bullet that introduces the feature, and the Fixed and Changed bullets that described them as released behaviour go. The view's bullet and the README now say that the app's session wraps its six dialog methods so one dialog opens at a time, and that an app keeps it by assigning its session through self.session.
CheckpointSessions.instances reads each instance thread's first input checkpoint, which holds the run's first input (in its __start__ channel and its pending writes): the brief, and an inheriting instance's copy of its parent's conversation. The saver decodes it on the event loop. The module docstring, the method's, CLAUDE.md and the changelog said that checkpoint holds no message; they now say what it holds, and the manager's hook says the threads are the records' floor, as the code reads them. The test counted only the messages channel, so it passed while the brief was decoded. It now records what each checkpoint read holds in __start__ and in its pending writes, and pins that it is each thread's first input and nothing a later run wrote. The scan's cost is unchanged.
…lt cap After /back the main agent was told the whole envelope of the run the user started in the view, uncut: a long report cost the root that much at once, and one over its budget could not be trimmed, since the newest turn stays. Every other envelope a model reads passes cap_tool_result. The manager now keeps the envelope it holds for instance_result as the cap leaves it (_user_ran), with the same cut, note and saved output a task result gets, saved under the instance's name. The cap is applied there rather than at the notice: the manager owns the settings that size it (tool_result_max_chars, the app's tool-output folder), as the backends' caps do; it covers both backends at once and any caller that tells the root through instance_result, an app's own tell_root(view_notice(...)) included; and it runs once, as the run ends.
…s so
A call left at its prompt by a sub-agent run its parent or a limit stopped
was told what stopped it (not_run), but a call that was running was still
told "Interrupted by the user before it finished", although the cause is
known on both backends.
interrupts.py gains INTERRUPTED_BY, "Interrupted: {cause} stopped the run
before this call finished; it may have partly run. Check before running it
again.", and interrupted_by(cause), which gives INTERRUPTED_BY_USER for
the user's stop, as not_run gives NOT_RUN. OpenCalls.answer reads the cause
for both kinds of call (the one given, else the one recorded with the
instance's stop) and unrecorded words a stopped run's call with it, so
ADK's seal (its stop_cause) and Deep Agents' next run (the cause recorded
with the instance's stop) answer alike. The user's stop and Ctrl+C keep
INTERRUPTED_BY_USER; a call no stop answers stays INTERRUPTED.
The contract test of a follow-up after a stop now pins the parent's stop
and a time limit on both backends.
A process exit interrupts a run: it ends interrupted and its instance stays idle. Only Ctrl+C in a view is the user's stop. At /exit the app stopped a view's run still working with the view's own stop, so the run ended cancelled by the user and the instance stayed stopped: after a restart the main agent's message_agent to it was refused, although the user never chose to stop it. The manager gains interrupt_instance(instance) (provisional): it ends the run of a run_instance as a turn's cancel ends its runs. The run's task is cancelled as its caller's would be, so it ends interrupted and its instance idle; the stream raises CancelledError, and run_instance's user-stop path is skipped for it, a stop of its stream included. The view's interrupt() calls it, then cancels the view's tasks (a line waiting to run never starts), and the app calls it at exit, still waiting for the run before the workflow is cleaned up so its turn records it and writes the records. TestExitInAView now asserts interrupted and idle, and that after a restart the main agent's message_agent continues the instance; a contract scenario pins interrupt_instance on both backends.
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.
Fixes from a review of the sub-agent work as a whole, before release. None of them is a crash. Each is a wrong message, an uncapped result, or text that says something untrue.
Behaviour
/exitwhile a sub-agent's run works in its view interrupts the run. The run endsinterruptedand the sub-agent staysidle, so its parent can continue it after a restart. It is still waited for before the workflow is cleaned up. Before, exit counted as the user's stop: the sub-agent was leftstopped, and its parent'smessage_agentwas refused. Ctrl+C in the view is still the user's stop.interrupt_instance(provisional) for this./backpasses the tool result cap. A long result from a sub-agent's view used to reach the main agent whole, and one over its budget ended the notice turn in an overflow. It is now cut as ataskresult is, with the same note and the full output saved forread_file.Text
self.session.Tests: each behaviour change has a test written first and seen failing. The
/exitand stopped-call scenarios run on both backends.The full offline suite passes in the worktree, except
TestChildImportOrigin::test_child_resolves_the_checkout, which fails the same way on develop under the worktree wrapper. The shared contract suite and the touched tests also pass on CI's library versions (google-adk 2.15, deepagents 0.7.41) in a scratch virtualenv.