OrionAboutResources
Back to resourcesHow to Create an AI Planner Agent: Part 1
Leah BonserLeah Bonser
AI

How to Create an AI Planner Agent: Part 1

The Challenge: Why Planning is a Weak Spot in AI

While Generative AI excels in various areas, planning can be a weak point, especially when prompts and agents aren’t structured properly. Without a well-defined process, agents may generate incomplete, inaccurate, or confusing results.

Here’s what will be explored:

  • How to craft a prompt that generates a robust plan from an AI agent.
  • Using Autogen to set up an efficient group chat structure for successful task execution.

A Real-World Example of AI Planning

To illustrate how AI planning can go wrong and how it can be improved, consider the following query:

"Find out the birthdate of each of the members of The Beatles, saving each date on a new line. Add up the last digit of each of those dates and tell me the answer."

When initially tested with GPT-4, the plan generated seemed adequate. However, it had several issues:

  • Data Retrieval: The AI pulled information from its training data instead of searching the web.
  • Misinterpretation: It misunderstood which part of the dates to add up, leading to an incorrect answer.

This example highlights the limitations of a poorly structured prompt and the risks of relying on training data alone. To resolve such challenges, a well-structured prompt, combined with task decomposition, is necessary for more effective execution.

The diagram below outlines how an AI agent, using task decomposition, would structure and execute the query using the planner agent model:

Exec agent diagram

How to Build a Better Planner Agent

The core function of a planner agent is task decomposition, which involves breaking down tasks into smaller, actionable steps. The CoALA framework structures this process into three phases, ensuring a methodical approach to task planning:

Here’s a breakdown of the CoALA framework:

  1. Proposal: Break the task into a series of subtasks.
  2. Evaluation: Review and refine the proposed subtasks for accuracy.
  3. Selection: Choose the best path for executing the plan efficiently.

The Importance of Prompt Structuring

For a planner agent to be effective, it must understand exactly what needs to be done. Key details for a prompt include:

  • Who the agent is (their defined role).
  • What their job is (the goal or task).
  • Which functions the agent has access to (tools and capabilities).
  • The output structure (how results should be delivered).

This clarity ensures that the AI can handle complex workflows with precision, regardless of whether tasks are independent or rely on previous steps.

From Planning to Execution: The Execution Agent

Once the planner agent has broken down the task, the next step is executing the plan. The execution agent takes the subtasks and:

  • Analyzes the subtasks to understand their order and dependencies.
  • Translates the subtasks into executable function calls.
  • Ensures the correct functions are executed to complete each subtask.

Through careful analysis and task management, the execution agent ensures even the most complex tasks are handled efficiently.

The following diagram demonstrates how the execution agent interacts with other agents to process and complete tasks:

Proxy Agent Diagram

Delivering Results: Managing the Output

Once the planning and execution phases are complete, managing the output is essential. At Gravity Foundation, a Proxy agent is used to handle result delivery. This agent ensures that the output is returned in a structured, clear, and actionable format.

The diagram below provides a preview of how hierarchical planning can organize multiple agents and workflows to tackle complex tasks more efficiently:

Agent stack

What’s Next?

In this article, we covered the essentials of building effective AI planner agents and using task decomposition. Next in Part 2, we’ll dive into hierarchical planning—showing how agent workflows can solve even more complex problems.

Want to learn more? Reach out to discover how Orion by Gravity Foundation is helping business do more with their data.