Repository navigation
Sub-agents: the built-in general_purpose type - #341
Merged
Merged
Conversation
The built-in general-purpose type is off by default; an app turns it on with general_purpose=True, which needs a spawn source: with none, nothing could start it, and the policy refuses it as it is made, as it refuses a source that is not one of the three.
spawnable names general_purpose last for every source the policy enables, so can_have_children counts it (a root with no sub-agents gets task for it) and the general-purpose type itself starts none. general_purpose_config makes it for one spawner type: that type's tools, MCP servers, skills and model, the framework's prompt and description; general_purpose_spawners names the types each backend will build one for: the root, and below the root every type that may start one. An app's agent named general_purpose is refused while the policy enables the type. The contract suite's harness learns the type's prompt and scripts it.
… was made for A general_purpose run's start says the type that started it (based_on), and its instance keeps it, in the records beside the conversation: every later run of it is made for that type. Records written before it read None; RECORDS_VERSION stays 1.
…ose type offered lists general_purpose last, made for the caller's type; delegate checks a call's tools against that type's own and refuses a model, since the type has no choices; start runs it with based_on, the type it is made for, which its start reports and its instance keeps. The user's start makes it for the root. A follow-up, the user's or after a restart, runs on the same type's; one the app no longer makes is refused as a type that is gone. config_for is the one lookup, and general_purpose lists the configs made for each type that may start one, for the backends to build.
A skill whose frontmatter names general_purpose starts one made for the loading agent's type when the policy enables the type and lets skills start it. A general-purpose agent's own loads start no agent, and its build warns of none of its skills: its spawner's build warns of what that type cannot start.
Each type that may start the general-purpose type gets an agent of it at initialization, through the builder a model choice's goes through: that type's tools, toolsets of its own and model, no delegation tools, and a runner whose chain reads that type's model, kind and numbers under general_purpose. A run picks it by the type it is made for, its usage and raw log name that model, and the release closes it with the other runners; a model switch builds it again. The Deep Agents cases of the new contract scenarios stay red until the next commit, which follows at once: the change merges whole.
Each type that may start the general-purpose type gets a graph of it at initialization, built as a model choice's variant is but with tools and a prompt of its own: that type's registered and skill tools, its MCP servers on sessions of its own, the framework's prompt, that type's model and numbers. It is built without task. A run picks it by the type it is made for; the release drops it and closes its MCP sessions with the rest.
Its view's Model row, its context numbers and the status bar's ctx are those of the type that started it, whose model it runs on.
The CHANGELOG's Added bullet, the README's sub-agent section and CLAUDE.md's agents/ line and delegation paragraph describe SubAgentPolicy.general_purpose: a type the app does not configure, made for the type that starts it, started by every source the policy enables, starting none itself.
With no configured types the user is not offered general_purpose (there is no root to make it for) and its start is the no-types refusal, not a KeyError. A Deep Agents general-purpose agent's MCP notice names its spawner, and a comment says why its sessions start per spawner. Tests: release and rollback close the general-purpose runners and graphs on both backends, a general-purpose run starts no agent below the depth limit, the default policy builds none. Docs: the spawner rule says which source each kind needs, the structure lines and README's validation paragraph name the type; the ADK MCP scenarios filter ADK's own MCP warnings.
…awner The notice text and the unavailable-server log line read agent 'general_purpose' (for '<spawner>'), as its metadata does. The CHANGELOG bullet is rewrapped and the plugin-chain test's docstring says what it checks.
The manager always passes spawner= to MCPSessions.start; the test fake that wraps start forwards extra keywords instead.
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 built-in
general_purposeagent type: when the app enables it, a run that may start agents can hand a self-contained task to a general-purpose agent with its own tools and model, without the app defining one. Both backends.The type
SubAgentPolicy.general_purpose(defaultFalse) turns it on. It needsspawn_sources(refused at construction otherwise), and every enabled source may start it:tasklists it last, a skill may name it (agent: general_purpose), and/agent new general_purpose <objective>starts one.task, no follow-up tools), its spawner's model and context numbers (never a model choice the spawner runs on), and the framework's prompt. It starts no agent itself, and a skill it loads that names one is refused.task, the loading agent's for a skill, the main agent for/agent new. One is built per spawner type at initialization: the main agent always, and withmax_spawn_depth2 or more the types that may start one (those that do not inherit when"agent"is a source, those with skills when"skill"is). The release closes them, and a model switch builds them again.task'stoolsnarrow it to some of its spawner's own;modelis refused (it has no choices). A spawner's MCP server whose tools cannot be listed gets the usual "could not be listed just now" answer.general_purposeis refused while the type is on. With the default policy nothing is built and nothing changes.The records
InstanceRecord.based_on, from the start event); its follow-ups and a restart run on the same spawner's agent. A follow-up the app no longer allows (the policy off, the spawner gone) is refused as for a type that is gone. Records from before load unchanged.Tests: written first and seen failing. The shared contract suite runs on both backends and covers:
/agent newstarting one;modelrefused;There are unit tests for the policy,
spawn.py's spawners, the records,Delegations, the skill checks, both builders and the view. Reviewed, with two rounds of review fixes.The full offline suite passes in the worktree (11060 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 MCP tests and every touched file pass (1398).