Feature request: RPC api for calling subagents with streaming and cancellation
Subagents are a good way for LLMs to to work on complex, multi-step tasks. Delegating to a subagent allows it to focus its context window on the subtask, thereby offloading the main agent's context. Advanced models now have good enough reasoning capabilities to plan sub-tasks and use function calling to delegate to subagents.
The addition of a first class RPC api for invoking subagents, with streaming responses, and with cancellation, would go a long way toward using Agents SDK for more agentic use cases.
Simple subagents are already possible in the Agents SDK today, by providing a tool which invokes saveMessages on another named AIChatAgent instance using RPC. This has the effect of creating the subagent instance, sending the prompt for the subagent to call the LLM in its own message thread, and returning when done, but saveMessages does not currently return the response stream from the subagent back to the main agent, and it depends on a websocket event for cancellation.
NOTE: You can go to @jldec's https://agents-chat.jldec.workers.dev/chat-agent-agent to try out subagents using saveMessage over RPC.
cool idea, i had an insomnia so i made something work locally, will do a bit more resting in the morning and will show you
cool idea, i had an insomnia so i made something work locally, will do a bit more resting in the morning and will show you
🔥 looking forward to trying it out @whoiskatrin. (watch out for that insomnia)