Repository navigation
Sub-agents: the user stops, closes and continues them from the console - #334
Merged
Merged
Conversation
stop_by_user cancels a running instance's run by the user and waits for its end, which leaves the instance stopped; an idle one is stopped at once. close_by_user closes an instance and its descendants, a running one as its run ends. Only the user may start a stopped instance's next run.
…(failing) The harness makes the crew's conversation the manager's open one and stops any turn a failed scenario left running before the manager is cleaned up. The scenarios drive run_instance, stop_instance, close_instance and steer_instance on both backends.
run_instance runs the user's follow-up as a turn of its own, in a task it shields so that stopping its stream is the user's stop of the run (cancelled by the user, the instance stopped). stop_instance and close_instance cancel from outside, wait for the run's end and the records, and take no turn lock. steer_instance gives a running run the user's line. Each acts on the open conversation or the one session_id and user_id name. A run the user starts begins from the conversation's outside-content mark (_conversation_state, one hook per backend).
…text tell_root runs the root on a notice the user did not type, marked as a job's notice is so recent_messages and the conversation's row leave it out; the outside-content mark a run the user started brought is written with it. On ADK the run carries RunConfig.custom_metadata, which ADK stamps on each event including the notice's user event; on Deep Agents the message's response_metadata says so. view_notice words what the root is told after the user worked with a sub-agent.
/agents is a picker of the conversation's instances, each followed by the ones it started; Enter shows the one picked as /agents <id> does. /agent <id> shows one, /agent stop <id> and /agent close <id> are the user's stop and close, each saying what it did or why not and acting on the app's own conversation. The runs table goes; its row checks move to the panel's tests.
A cancel of run_instance's consumer that came after the pump was made but before the follow-up's first step found the instance idle and cancelled nothing, so the run completed and the instance stayed idle. The source looks again when it is cancelled. Also pins that stop_instance and close_instance load the records first, that the base tell_root refuses without a notice hook, and that a blank steer is a ValueError.
…d alone The manager's hold of a mark a user's run changed, and ADK's write of the held mark with the notice (the root's model call fails, so the permission plugin never writes it), each fail a test when removed.
A type that takes no more runs closes as its stopped run ends; the line is worded from the instance's status after the stop. Also a blank-line slip in two test files.
PR-order of the Added bullets (the roster and brief bullets first), the comma in the base manager's delete clause, and run_instance and tell_root among what enters through _turn.
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 user can now see, stop and close the open conversation's sub-agents from the console. The manager gains the entry points behind that, which a view of a sub-agent can build on. Both backends are covered.
The console
/agentsis a picker of the conversation's sub-agent instances. Each instance is followed by the ones it started, with its id, type, status (running,idle,stopped,closed) and title. Enter shows the one picked. The runs table is gone;/agents <id>still shows one instance or run in full./agent:/agent <id>shows one instance./agent stop <id>stops one. Its working run, if any, is cancelled by the user (cancelled_by: user), and the instance isstopped. Its parent'smessage_agentis then refused, and only the user may start its next run. A one-shot instance whose run is stopped endsclosedinstead, and the command says so./agent close <id>closes the instance and its own sub-agents. They take no more runs, and their work stays readable./agentalone says its usage.The manager's entry points (provisional). Each works on the open conversation, or on the one
session_id/user_idname, and on any of its instances. All go throughDelegations, as a parent's tools do.run_instance(instance, message)is the user's follow-up, a turn of its own.started_by: userand counts toward no turn's runs. It starts from the conversation's outside-content mark.cancelledand the instancestopped, notinterruptedandidle.stop_instance/close_instancetake no turn lock. They cancel the run from outside and wait for its end, so the status is final and the records written when they return.steer_instance(instance, message)gives a running run the user's message before its next step.instance_resultreturns the envelope of the latest run the user started.tell_root(text)runs a turn of the root on a notice the user did not type.agents/envelope.py::view_notice: "The user worked with directly; its latest result: ".Tests: written first and seen failing. The shared contract suite runs on both backends and covers:
Each new async path also runs once under the loop guard. Unit tests cover
Delegations' user stop and close (including a run that finishes as the stop comes), the notice on each backend's sessions, and the CLI commands.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 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.