Planning
Planning is how an AI agent decides the sequence of steps needed to achieve a goal. Good planning is what distinguishes a capable agent from a basic one.
How AI Agents Plan
AI agents use the language model's reasoning capabilities to plan.
When given a goal, the agent:
1. Breaks the goal into sub-tasks
2. Orders the sub-tasks logically
3. Identifies which tool is needed for each sub-task
4. Estimates what information or inputs each step needs
This planning is done by the LLM itself. The agent prompts the LLM with the goal and asks it to produce a plan. The LLM uses its training to generate a reasonable step-by-step plan.
Some agents re-plan after each step if they discover that the situation is different from what they expected.
Deep Learning ⊂ Machine Learning ⊂ Artificial Intelligence
Planning Example
# AI agent planning: breaking a goal into actionable steps
def create_agent_plan(goal):
"""
Simulate how an AI agent creates a plan for a goal.
In a real agent, the LLM creates this plan automatically.
"""
print(f"Goal: {goal}")
print()
print("Agent Planning Process:")
print()
# A research and writing goal broken into steps
plan = [
{
"step": 1,
"sub_goal": "Understand the goal and identify information needed",
"tool": "reasoning",
"input_needed": "The goal description",
"output": "A list of questions to answer and sources to check"
},
{
"step": 2,
"sub_goal": "Find the top Python data visualization libraries",
"tool": "web_search",
"input_needed": "Search query about Python data visualization",
"output": "A list of popular libraries with brief descriptions"
},
{
"step": 3,
"sub_goal": "Get GitHub star counts for each library",
"tool": "web_search",
"input_needed": "Each library's GitHub URL",
"output": "Number of GitHub stars for each library"
},
{
"step": 4,
"sub_goal": "Create the comparison table",
"tool": "text_generation",
"input_needed": "Library names, descriptions, and star counts",
"output": "A formatted comparison table"
},
{
"step": 5,
"sub_goal": "Review and format the output for the user",
"tool": "text_generation",
"input_needed": "The comparison table",
"output": "Final formatted report"
},
]
for step_info in plan:
print(f"Step {step_info['step']}: {step_info['sub_goal']}")
print(f" Tool: {step_info['tool']}")
print(f" Needs: {step_info['input_needed']}")
print(f" Produces: {step_info['output']}")
print()
create_agent_plan("Find the top 5 Python data visualization libraries and compare their GitHub stars in a table")