feat: experimental sub-agent API and examples#1060
Merged
Conversation
Introduce an experimental sub-agent system and integrate it into example gadgets. Adds a new RFC (design/rfc-sub-agents.md) describing sub-agents, plus an implementation (packages/agents/src/experimental/sub-agent.ts) with a withSubAgents mixin and typed RPC stubs. Refactors Agents package (index/build/scripts/tests) and adds tests for sub-agents. Update example apps to use sub-agents: experimental/gadgets-chat now uses SubAgent facets, a StreamRelay RPC target, and a client-side AgentChatTransport that supports streaming, cancel, and resume; other gadgets and servers updated to the new API. Misc: docs/README and design listings updated and various package metadata/build changes to wire everything together.
|
commit: |
Replace experimental Durable Object "facet" docs with the new sub-agent pattern across four READMEs. Updated terminology, diagrams and TypeScript examples to use SubAgent / withSubAgents, added Key Pattern snippets, streaming protocol details (chat), and Related links. Files changed: experimental/gadgets-chat/README.md, experimental/gadgets-gatekeeper/README.md, experimental/gadgets-sandbox/README.md, experimental/gadgets-subagents/README.md. Primarily documentation updates to reflect API/architecture changes (no functional code changes).
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.
Adds a first-class sub-agent abstraction for spawning child Durable Objects (facets) with isolated SQLite from a parent Agent.
What
SubAgentbase class — extends partyserver'sServer, providessubAgent(),abortSubAgent(),deleteSubAgent()withSubAgents()mixin — adds sub-agent methods toAgent,AIChatAgent,McpAgent, etc. without shipping them in the base classSubAgentStub<T>— typed RPC stubs that expose user-defined methods while hiding Server/DO internalsdesign/rfc-sub-agents.mddocumenting the problem, proposal, alternatives, patterns, and open questionsExamples updated
All four
experimental/gadgets-*examples now use the sub-agent API:gadgets-subagents— fan-out/fan-in with parallel LLM calls across three perspective sub-agentsgadgets-chat— multi-room chat viaChatRoomsub-agents with isolated message historygadgets-sandbox—CustomerDatabaseas a sub-agent for data isolation in a code sandboxgadgets-gatekeeper— gated database access enforced structurally via sub-agent boundaryExported from
Requires the
"experimental"compatibility flag inwrangler.jsonc.