Repository navigation
Sub-agents: a sub-agent's view, /agent <id> and /back - #335
Merged
Merged
Conversation
…urns process_instance draws the user's line in a sub-agent's view as a turn whose source is run_instance: the instance's text is the reply and its lines name nobody, and each event of its run draws the status bar again. process_notice draws the main agent's notice after a view (tell_root) as a job's notice turn is.
…er, /back /agent <id> (and Enter in /agents' picker) opens one instance's view: a rule, a recap, the prompt <id>> and a status bar naming the instance, its status, its own ctx and tokens. A line typed there is the instance's next run, started in a task of its own outside the input handler so the prompt stays open, or, while its run works, is given to that run before its next model step. /back leaves it. A closed instance's view is read-only.
…, /new, /resume, /status there Leaving a view tells the main agent once, in a notice turn, when a run the user started there ended since it last heard of the instance. The main agent's own notices (finished jobs) wait while a view is open and are told after /back. In a view /compact is refused, /new and /resume leave it first, and /status shows the instance's context.
…l working The view's run works outside the input handler, which thinking-prompt's Ctrl+C does not reach, so the session gets one more key binding, active only while that run works. A run still working at exit is the user's stop, waited for before the workflow is cleaned up.
A sub-agent's view runs its run outside the input handler, so a command may open a dialog while the run asks its question. thinking-prompt raises on a second dialog, which would turn a permission prompt into a denial the user never saw, or fail the command. Every dialog now takes the session's one lock while it is open: the commands' through show_dialog, a run's question inside the message processor. Whichever comes second waits for the first.
_write was a copy of run_turn's frame without the echo. run_turn now calls it with the line to echo, shown once the turn lock is taken and before the cancelled line when the wait for the lock is stopped, so every write to the conversation follows the same rules for held, turned and written.
…urn does After a model switch whose rebuild failed, a line typed in a sub-agent's view was refused where the main conversation retries the start, and /back skipped the main agent's notice. A line is now the instance's next run all the same (its start retries the workflow), and /back retries the start before it tells the main agent.
…rather than hangs A second line typed before the first run ended waited for the turn lock and said "Operation cancelled..." again when Ctrl+C stopped it. A queued line now waits for the run before it inside the view, where a stop is silent. The Ctrl+C test waits for the run with a bound and cancels what is left, so a stop that stops working fails the test instead of stalling teardown.
…versation keeps run() logs at info when the session takes no Ctrl+C binding (Ctrl+C in a view is then thinking-prompt's own and the run goes on until it ends or /exit stops it). New tests: the main agent's ctx stays put after a view run, finished jobs are not told in a view (resume_finished_jobs, and the bar counts them).
The context rows are read after the Model, App Name, Session ID and Services rows again, so rows that fail to read leave those shown. Only in a sub-agent's view are the instance's rows read first, to drop the main Model row.
An app's command that calls app.session.show_dialog itself skipped the helper the framework's commands used, so a question of a view's run could still be refused. BaseCLIApp.session now wraps a real session's dialog methods once, on assignment: every caller is serialized. The commands call the session directly again, the helper is gone, and the lock lets the same task take it again, so the message processor's question lock and the wrapper never wait for each other. The one-dialog tests wait on conditions (the run's record reading input_required, the command's picker built), not on a sleep.
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 work with one of the conversation's sub-agents directly, in its view.
Opening it:
/agent <id>(or Enter in/agents' picker) opens the view.── researcher-2 · researcher · idle ──.researcher-2>.ctxand tokens. The jobs segment is kept.Working in it
run_instance,started_by: user).steer_instance). It is never queued as a turn.stopped. A Ctrl+C that lands as the run starts still stops it.Leaving it:
/backwaits for a run still working, then prints── back to main ──.tell_rootwith "The user worked with directly; its latest result: …"). The turn is drawn as a job's notice is.↻Nand told after/back.Commands inside a view
/statusshows the sub-agent's model and context./compactis refused./new,/resumeand/agent <another id>leave the view first, waiting for its run./exitwith a run working is the user's stop, waited for before the workflow is cleaned up.A closed sub-agent's view is read-only: there is no prompt, a typed line is refused, and commands work.
The app's API (provisional):
agent_view,open_agent_view(id)andleave_agent_view().Also: the main conversation's turns and the view's runs now share one write frame in
ConversationCore. Before, there were two copies.Tests: written first and seen failing.
/backwith its notice once per run, the notices that wait, the commands in a view, a closed view, a model switch in a view, and the dialog lock in both orders./exitwith a run working.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 CLI tests, the render tests and the shared contract suite also pass on CI's library versions (google-adk 2.15, deepagents 0.7.41) in a scratch virtualenv, apart from the LangGraph deprecation test, which fails only in that virtualenv.