Repository navigation
Sub-agents: /agent new, the user's own start - #340
Merged
Merged
Conversation
AgentRuns.run_for names a run per (conversation, parent run, call id) so a repeated call is the same run while it is open. A start with no call (the user's) has no such key: it is a new instance each time, and nothing is remembered under an empty call id.
Delegations.start_by_user starts a type for the user (/agent new): through start, with no caller and no call, so its parent is the root at depth 1, started_by user, counted toward no turn's runs, its brief the objective titled with its first line. Only a type whose spawnable_by and the policy's spawn_sources both name the user (startable_by_user); another is refused naming those the user may start, and a blank objective is refused (user_start_refused), with no run.
start_instance(agent_type, objective) starts a sub-agent the user asked for as a turn of its own on the open conversation, as run_instance continues one: its first event is the run's start, which names the instance; a type the user may not start, or a blank objective, is one ERROR. Stopping the stream is the user's stop of the run, also before the run started (it is stopped as it starts), and interrupt_instance ends it as a process exit does. An inheriting type reads the conversation as the root's task would hand it, through a new backend hook (_inherited_history: ADK's session events, Deep Agents' root messages). run_instance and start_instance share one stream (_users_run).
MessageProcessor.process_start runs the workflow's start_instance as a turn: once the run's start names the new instance, opens is told it (its view opens there) before the start is drawn, and from then on the instance's text is the reply and its lines name nobody, as in a follow-up's view. A refusal is the turn's one error, and nothing opens.
The /agent command takes new <type> <objective>, the objective the rest of the line as typed, and hands them to the app's start_agent; without a type or an objective it says Usage: /agent new <type> <objective>. /agent alone, the command's usage and its examples (/help agent) name it.
start_view (BaseCLIApp.start_agent) leaves a view that is open, then starts the instance (ConversationCore.start_instance) in a task of its own; once the run's start names the instance its view opens, holding that task and the processor drawing it (AgentView.adopt, AgentView(processor=)), so the first run streams there, a line steers it, Ctrl+C is the user's stop and /back tells the main agent, as for a follow-up. A refusal opens nothing; Ctrl+C before the view opened stops the run and opens none.
The console app's scripted workflow starts a researcher for /agent new; over a pty the new sub-agent's view opens on its first run, a line typed steers it, and /back tells the main agent once.
The CHANGELOG, the README's user's control and commands table, and CLAUDE.md's lines for the agents command, the view, the message processor, the conversation core, the manager and the delegations say how the user starts a sub-agent and where its first run streams.
…s its conversation until_started awaits one future, resolved by the report of the run's start or the end of its work, so a stop before the start cancels the run before its hook is entered. start_instance stores a conversation that is not yet (ADK: the session with one state-only event, Deep Agents: an index row, titled from the objective, no turns), so /resume, --continue and --resume reach a conversation whose only work is a start. The processors' shared body is one helper (_user_turn). The docs say the main agent continues the user's instance only with the follow-up tools.
Deep Agents' record keeps the title of a row keep wrote (the objective's) when a notice or the first typed prompt rewrites it, and a turn that stored no message leaves that row instead of deleting it, as ADK does. The state-only event keep_conversation writes on ADK is authored by the root agent, so the router logs no unknown-agent warning at the next turn. A CHANGELOG line and a docstring paragraph are moved.
…ts row The state-only event keep_conversation writes on ADK carries an unmarked outside-content record, so the conversation is not read as one from before 0.7.0 and marked, nor its new instance. The Deep Agents backfill leaves a row keep wrote as it is.
The stop-as-the-stream-starts scenario of the user's new instance started on a manager that was not initialized, so its worker-thread service build ran inside the window search and the hop budget ran out on a slow runner. The manager is brought up first, the search runs to a deadline, and a miss says whether the start ended first.
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 start a sub-agent themselves:
/agent new <type> <objective>starts an instance of a type the app lets the user start, opens its view and shows its first run there. Both backends./agent new/agent new researcher Find what changed in the 2.0 release.starts an instance of a type whosespawnable_byand the policy'sspawn_sourcesboth name"user". The objective is the rest of the line as typed.started_by: user, and it counts toward no turn's runs. Its brief is the objective;brief_requiredis not asked. A type that inherits the conversation reads the open one.stopped, also when it lands before the run started, which then never runs), and/backtells the main agent once./agent newtyped inside a view leaves that view first.You cannot start '<type>' here. Types you can start: ...), an app that lets the user start none (This app lets you start no agent types., the default policy), and the usage line for a missing type or objective. A refusal starts nothing.The manager
BaseWorkflowManager.start_instance(agent_type, objective, *, session_id=None, user_id=None): a turn of its own on the conversation, through the one entry for a first run./resume,--continueand the exit's--resumehint reach it. On both backends it keeps that title after the main agent's first turn, and is never marked as a conversation from before 0.7.0.run_instanceandstart_instanceshare one stream of the user's run; a stop before either run starts cancels it before it enters the agent.Tests: written first and seen failing. The shared contract suite runs on both backends and covers:
There are unit tests for
Delegations' user start,run_forwithout a call, the processor's start drawn in its view,/agent new's parsing and the view, plus a run on a real console over a pty. Reviewed, with three rounds of review fixes.The full offline suite passes in the worktree (10955 passed), except
TestChildImportOrigin::test_child_resolves_the_checkout, which fails the same way on develop under the worktree wrapper. On CI's library versions the contract suites, the session suites and every touched file pass (1203).