Conversation
|
Like the idea but don't you think the sub agent and Agent is kind of same thing, will it not work ? Ideally There could be interface called |
|
Yes, I was thinking of renaming it to subAgents() but the SubAgents are Agents themselves so I was back to using class FrontendEngineer implements SubAgent
{
use Promptable;
/**
* Get the subagent name.
*/
public function name(): string
{
return 'Frontend Engineer';
}
/**
* Get the instructions that the subagent should follow.
*/
public function instructions(): Stringable|string
{
return 'Build responsive, accessible, high-performance user interfaces using modern web technologies and best practices.';
}
/**
* Get the description of the subagent's purpose.
*/
public function description(): Stringable|string
{
return 'Builds and refines web UI from specs—creates responsive, accessible components and pages, integrates APIs, manages client-side state, handles loading/error states, and improves performance with clean, maintainable code.';
}
}
// On Primary Agent
class Orchestrator implements Agent, HasSubAgents, HasTools
{
use Promptable;
public function instructions(): string
{
return 'You are an orchestrator that can delegate to other engineers.';
}
public function agents(): array
{
// every sub agents are turned into tools internally
return [
new FrontendEngineer,
new BackendEngineer,
new Devops,
];
}
}Since the subagent is an agent itself, it inherits all the Agent can do. So you can do #[MaxSteps(10)]
#[MaxTokens(4096)]
#[Provider('anthropic')]
#[Temperature(0.7)]
#[Timeout(120)]
class BackendEngineer implements SubAgent
{
use Promptable;
// ...
}
#[Provider('gemini')]
#[Temperature(1)]
class BackendEngineer implements SubAgent
{
use Promptable;
// ...
}
#[Provider('openai')]
class Devops implements SubAgent
{
use Promptable;
// ...
} |
|
I know SubAgent technically extends Agent, but it doesn’t feel quite right to me. It’s still an Happy to hear Taylor’s thoughts on this. |
|
@eznix86 Thanks for the effort, I know zero to none about the internals of Agent in this SDK, but I'm going to explain the reason why I was asking for a multi-agent roadmap and then see how you're building this. In ADK (agent development kit) by Google (Python library), you can define an agent with instructions and feed it a list of sub agents just like you did. My concern is that in ADK, those things share a state, so that tools can pick up certain pieces of configuration that might be required. (i.e. tenant ID). It also seemlessly shares the history and updates the state according to user and system prompts like so: You get the point, ADK allows to build multi-agent systems where state is automatically updated and injected and resolved once an agent is finished. My question, is this what you're building, or is there additional work required? Is the state of the agents saved somewhere alongside the messages that resemble the message history? |
Right, it could be confusing also for the community. I agree with you on this. I'll rename it to subAgents in a few. thanks @pushpak1300 for looking into it! |
I see what you mean here. Those subagents are stateless, so they only share "state" with the tasks given. So, it will be the job of the primary agent to give the tasks clearly. Thats where the prompt in It would be more like this: the the flow is User -> agent -> subagent -> agent -> user. so the agent acts like the orchestrator/middleman. |
|
Indeed, I'm appreciate the effort but alas have no time to get involved. For now I'll keep my ADK stack and keep a close eye on the AI SDK developments. Doesn't take away I'm blown away by the AI SDK, I'll use it for sure to drop in replace semantic chunking, embedding and direct OpenAI wrapper API calls. |
|
@pushpak1300 changed: |
|
Hi! Just wanted to add a couple of thoughts to the discussion:
Curious what you think, especially around context ownership and how you want message/history to be shared (or isolated) across agents. |
|
I personally think you should just treat sub-agents as tools and be able to return an agent in the |
|
@taylorotwell do you think it is the proper way of managing it in this PR ? Or you have another thing in mind ? |
fix #58
example:
Edit: rename
agentstosubAgents