Multi-step agent execution
Agent 1, Agent 3, back to Agent 1 and finish.
What makes AI Agents powerful isn't their ability to use tools, but their ability to work in concert to complete a task (orchestration).
Within the base coordinator prompt that we showed you before, there is native handling of assignment to multiple Agents. These assignments are not just linear, they also have depth - each assignment can depend on another assignment.
Once the assignment is complete - usually the coordinator will echo back to you how it will execute and give you an opportunity to confirm. After confirmation - the system will ensure that the tasks are executed in the proper order, leveraging the chat memory to pass the completion details of each step to the next assignment and ultimately finish the task.
A trivial example
First - let's setup a team of 4 agents.
@PeoplelogicAgent(value="coordinatorAgent",
name = "Know It All Agent",
persona = "Funny but a bit snarky")
@PeoplelogicAgentInstructions("Assigns tasks and runs first, telling the user its name. Also runs last after everything else and says Thank you (in your own unique way!)")
public interface AllInOneAgent extends WorkerAgent, CoordinatorAgent {}
By now, these samples should feel familiar if you've been following along in the other section of the documentation. Let's start up the agent CLI (remember, ./gradlew bootRun
) and see what it gives us:
peoplelogic:>q do my agents things
Starting new conversation, 'New Conversation...'
agent:> No additional details are needed to proceed. You’ve provided everything required, so just say the word if you want your agents to do their thing! If you’re ready, just confirm, and I’ll get things rolling (well, figuratively—I never actually do the rolling, just the organizing).
peoplelogic:>q do it
agent:> Let's get the agent show started!
1. Hello! My name is Know It All Agent, and I'll be coordinating things today.
2. Hi! (from the Secondary Agent)
3. The current date is July 19, 2025. (from the Third Agent)
4. Goodbye! (from the Fourth Agent)
5. Thank you for working with the agents today—I hope someone brings you coffee (or tea, I don't judge) because you deserve it!
If you want to parade these agents out again, just say the word!
Trivial, but what are we seeing here? We see that the CLI automatically handles creating a new Conversation and then has the CoordinatorAgent verify that we don't need anything else. Since this is a bit more complicated of a task it is going to confirm with us first. Then, we confirm that we're ready to go and it executes the workflow. The agent assignment goes:
coordinatorAgent (step1) -> secondAgent -> thirdAgent
-> fourthAgent -> coordinatorAgent
This is exactly as we would expect to see with the instructions we provided. In a real example you might also provide tools to each agent to do specialized work. You can see the power in this when you start to combine the built-in agents (and their tools) with your own agents - the sky is the limit. Now let's look at how we give your agents actual tools to work with!
Last updated
Was this helpful?