Agent Capabilities
In this lesson, we’ll focus on the core capabilities of AI agents that allow them to operate effectively. These capabilities represent the skills that agents employ to break down problems, make decisions, and interact with their environment.
This Lesson Will Cover
- 🧩 Task Decomposition: Breaking complex goals into manageable subtasks
- 📝 Planning: Creating and executing systematic action sequences
- 🤔 Decision Making: Evaluating options and selecting optimal actions
Task Decomposition
One of the most fundamental capabilities of an AI agent is breaking down complex goals into smaller, manageable tasks. This is known as task decomposition.
Example: Breaking Down a Goal
Suppose an AI agent is tasked with organizing an event. It might decompose the task as follows:
- Book a venue
- Send invitations
- Arrange catering
- Prepare schedule
Task decomposition allows agents to focus on solving smaller problems one at a time.
We’ll see an example of task decomposition using LangGraph down below.
Planning
Planning is an important capability for AI agents, enabling them to break down complex tasks into manageable steps and execute them systematically. Effective planning helps agents navigate multi-step problems while maintaining focus on the overall goal.
Key Planning Components
- Task Decomposition: Breaking complex goals into subtasks (discussed above)
- Step Sequencing: Determining the optimal order of operations
- Progress Monitoring: Tracking completion status
- Goal Alignment: Ensuring actions support intended outcomes
Example: Task Planning Agent with LangGraph
Here’s an agent that I’m going to use to plan my birthday party.
Warning: This example is a big step up from the previous LangGraph examples in this section.
I found LangGraph very difficult to grok. It’s beyond the scope of this course for me to explain everything going on below.
However I will of course show you outputs from running this and explain generally how it works.
from typing import TypedDict, Annotated, Sequence, Literal
from langgraph.graph import Graph, START, END
from langchain_core.messages import BaseMessage, HumanMessage, AIMessage, ToolMessage
from langgraph.graph.message import add_messages
from langchain_core.tools import tool
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import ToolNode
from langchain_core.tools import Tool
# Define state
class PlannerState(TypedDict):
messages: list[BaseMessage]
plan: list[str]
current_step: int
status: str
# Define tools with proper decorators
@tool
def fetch_interests() -> list[str]:
"""Fetch user's interests and hobbies."""
return ["Dancing", "Live Music", "Karaoke"]
@tool
def check_calendar() -> dict[str, list[str]]:
"""Check available dates in calendar."""
return {"available_dates": ["2025-03-15", "2025-03-16", "2025-03-22"]}
@tool
def get_venues() -> list[dict]:
"""Search for available venues matching criteria."""
return [
{"name": "Club Neon", "location": "Downtown", "capacity": 100},
{"name": "The Jazz Bar", "location": "Midtown", "capacity": 50},
]
@tool
def call_venue(venue_name: str) -> str:
"""Call a venue to check availability and booking details."""
return f"Called {venue_name}, they are available for booking."
@tool
def find_friends() -> list[dict]:
"""Find friends to invite to the event."""
return [
{"name": "Marie", "email": "Marie@example.com"},
{"name": "Bohr", "email": "Bohr@example.com"},
{"name": "Dirac", "email": "Dirac@example.com"},
]
@tool
def email_friends(friend_emails: list[str], message: str) -> str:
"""Send email invitations to friends."""
for email in friend_emails:
print(f"Emailed {email}")
return "Friends have been emailed"
# Collect all tools
tools = [
fetch_interests,
check_calendar,
get_venues,
call_venue,
find_friends,
email_friends
]
tools_by_name = {tool.name: tool for tool in tools}
def tool_node(state: PlannerState) -> PlannerState:
for tool_call in state["messages"][-1].tool_calls:
tool = tools_by_name[tool_call["name"]]
observation = tool.invoke(tool_call["args"])
state["messages"].append(ToolMessage(content=str(observation), tool_call_id=tool_call["id"]))
return state
# Create LLM with tools bound
model = ChatOpenAI(model="gpt-4o-mini").bind_tools(tools)
def create_plan(state: PlannerState) -> PlannerState:
# Create human prompt
state["messages"].append(
HumanMessage(content="Create a step-by-step plan to accomplish this task. Return only numbered steps and a maximum of 5 steps.")
)
response = model.invoke(state["messages"])
# Append the response to the messages, it will be included in the
# context below when running "execute_step"
state["messages"].append(response)
# Extract the plan
state["plan"] = [step.strip() for step in response.content.split("\n") if step.strip()]
state["current_step"] = 0
return state
def execute_step(state: PlannerState) -> PlannerState:
current_step = state["plan"][state["current_step"]]
# Create human prompt
state["messages"].append(HumanMessage(content=f"Execute this step: {current_step}"))
response = model.invoke(state["messages"])
# Append response to messages to carry forward full conversation context
state["messages"].append(response)
# Progress to the next step
state["current_step"] += 1
return state
def summarize_result(state: PlannerState) -> PlannerState:
state["messages"].append(HumanMessage(content=f"Summarize the plan that you have come up with"))
response = model.invoke(state["messages"])
# Append response to messages to carry forward full conversation context
state["messages"].append(response)
return state
def should_use_tools(state: PlannerState) -> Literal["tools", "check_completion"]:
messages = state["messages"]
last_message = messages[-1]
# If the LLM makes a tool call, route to the tools node
if hasattr(last_message, 'tool_calls') and last_message.tool_calls:
return "tools"
# Otherwise, continue to completion check
return "check_completion"
def check_completion(state: PlannerState) -> PlannerState:
if state["current_step"] >= len(state["plan"]):
state["status"] = "complete"
else:
state["status"] = "in_progress"
return state
def route_check_completion(state: PlannerState) -> Literal["execute_step", "summarize_result"]:
if state["status"] == "in_progress":
return "execute_step"
else:
return "summarize_result"
# Create workflow
workflow = Graph()
# Add nodes
workflow.add_node("create_plan", create_plan)
workflow.add_node("execute_step", execute_step)
workflow.add_node("check_completion", check_completion)
workflow.add_node("summarize_result", summarize_result)
workflow.add_node("tools", tool_node)
# Add edges
workflow.add_edge(START, "create_plan")
workflow.add_edge("create_plan", "execute_step")
workflow.add_conditional_edges(
"execute_step",
should_use_tools,
)
workflow.add_edge("tools", "check_completion")
workflow.add_conditional_edges("check_completion", route_check_completion)
workflow.add_edge("summarize_result", END)
# Compile
graph = workflow.compile()
# Initial state
inputs = {
"messages": [
HumanMessage(content="Plan my birthday party")
],
"plan": [],
"current_step": 0,
"status": "starting"
}
# Execute
state_history = []
for state in graph.stream(inputs):
state_history.append(state)
state_key = list(state.keys())[0]
print(repr(state[state_key]["messages"][-1]))
Let’s start by looking at the graph. It’s… beautiful 🥹
from io import BytesIO
from PIL import Image
from IPython.display import display
img = graph.get_graph().draw_mermaid_png()
with open("img/LangGraph_Task_Planning_Agent.png", "wb") as f:
f.write(img)
display(Image.open(BytesIO(img)))

Here’s how this works:
__start__: Enter the graph here.create_plan: Run the prompt: Create a step-by-step plan to accomplish this task. Return only numbered steps and a maximum of 5 steps.execute_step: The execution node that asks the model to generate the next step in the plan.tools: If the execution node returns a tool call, then we run that tool using this node.check_completion: We route back toexecute_stepif there are still steps to run, otherwise we route tosummarize_result.summarize_result: Run the prompt: Summarize the plan that you have come up with
Now I’ll show you the output from running this:
AIMessage(content='1. **Determine Your Interests and Theme**: Identify your interests and decide on a theme for the birthday party.\n2. **Set a Date**: Check your calendar to choose a suitable date for the celebration.\n3. **Find a Venue**: Look for available venues that fit the theme and can accommodate guests.\n4. **Invite Friends**: Compile a list of friends to invite and send them invitations via email.\n5. **Finalize Details**: Confirm the venue booking and finalize the party details such as decorations, food, and activities.', additional_kwargs={'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 112, 'prompt_tokens': 169, 'total_tokens': 281, 'completion_tokens_details': {'accepted_prediction_tokens': 0, 'audio_tokens': 0, 'reasoning_tokens': 0, 'rejected_prediction_tokens': 0}, 'prompt_tokens_details': {'audio_tokens': 0, 'cached_tokens': 0}}, 'model_name': 'gpt-4o-mini-2024-07-18', 'system_fingerprint': 'fp_709714d124', 'finish_reason': 'stop', 'logprobs': None}, id='run-0a51db50-dbaf-4232-9800-acb8d2745b1c-0', usage_metadata={'input_tokens': 169, 'output_tokens': 112, 'total_tokens': 281, 'input_token_details': {'audio': 0, 'cache_read': 0}, 'output_token_details': {'audio': 0, 'reasoning': 0}})
AIMessage(content='', additional_kwargs={'tool_calls': [{'id': 'call_5eQKX2SWSoa36nAFFR1HFYLv', 'function': {'arguments': '{}', 'name': 'fetch_interests'}, 'type': 'function'}], 'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 12, 'prompt_tokens': 315, 'total_tokens': 327, 'completion_tokens_details': {'accepted_prediction_tokens': 0, 'audio_tokens': 0, 'reasoning_tokens': 0, 'rejected_prediction_tokens': 0}, 'prompt_tokens_details': {'audio_tokens': 0, 'cached_tokens': 0}}, 'model_name': 'gpt-4o-mini-2024-07-18', 'system_fingerprint': 'fp_709714d124', 'finish_reason': 'tool_calls', 'logprobs': None}, id='run-a6218cf4-bb80-40df-8085-24d104a18b89-0', tool_calls=[{'name': 'fetch_interests', 'args': {}, 'id': 'call_5eQKX2SWSoa36nAFFR1HFYLv', 'type': 'tool_call'}], usage_metadata={'input_tokens': 315, 'output_tokens': 12, 'total_tokens': 327, 'input_token_details': {'audio': 0, 'cache_read': 0}, 'output_token_details': {'audio': 0, 'reasoning': 0}})
ToolMessage(content="['Dancing', 'Live Music', 'Karaoke']", tool_call_id='call_5eQKX2SWSoa36nAFFR1HFYLv')
ToolMessage(content="['Dancing', 'Live Music', 'Karaoke']", tool_call_id='call_5eQKX2SWSoa36nAFFR1HFYLv')
AIMessage(content='', additional_kwargs={'tool_calls': [{'id': 'call_ZHQzAIb9FLdvjkKvfTOlH0Vv', 'function': {'arguments': '{}', 'name': 'check_calendar'}, 'type': 'function'}], 'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 11, 'prompt_tokens': 377, 'total_tokens': 388, 'completion_tokens_details': {'accepted_prediction_tokens': 0, 'audio_tokens': 0, 'reasoning_tokens': 0, 'rejected_prediction_tokens': 0}, 'prompt_tokens_details': {'audio_tokens': 0, 'cached_tokens': 0}}, 'model_name': 'gpt-4o-mini-2024-07-18', 'system_fingerprint': 'fp_709714d124', 'finish_reason': 'tool_calls', 'logprobs': None}, id='run-81bec8bf-25e6-46f3-81ca-4aec733d546c-0', tool_calls=[{'name': 'check_calendar', 'args': {}, 'id': 'call_ZHQzAIb9FLdvjkKvfTOlH0Vv', 'type': 'tool_call'}], usage_metadata={'input_tokens': 377, 'output_tokens': 11, 'total_tokens': 388, 'input_token_details': {'audio': 0, 'cache_read': 0}, 'output_token_details': {'audio': 0, 'reasoning': 0}})
ToolMessage(content="{'available_dates': ['2025-03-15', '2025-03-16', '2025-03-22']}", tool_call_id='call_ZHQzAIb9FLdvjkKvfTOlH0Vv')
ToolMessage(content="{'available_dates': ['2025-03-15', '2025-03-16', '2025-03-22']}", tool_call_id='call_ZHQzAIb9FLdvjkKvfTOlH0Vv')
AIMessage(content='', additional_kwargs={'tool_calls': [{'id': 'call_uQyv5bUaX2JBqYobgAn3f1HO', 'function': {'arguments': '{}', 'name': 'get_venues'}, 'type': 'function'}], 'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 12, 'prompt_tokens': 453, 'total_tokens': 465, 'completion_tokens_details': {'accepted_prediction_tokens': 0, 'audio_tokens': 0, 'reasoning_tokens': 0, 'rejected_prediction_tokens': 0}, 'prompt_tokens_details': {'audio_tokens': 0, 'cached_tokens': 0}}, 'model_name': 'gpt-4o-mini-2024-07-18', 'system_fingerprint': 'fp_709714d124', 'finish_reason': 'tool_calls', 'logprobs': None}, id='run-f34385ae-7bcf-4186-b860-83f296ab3142-0', tool_calls=[{'name': 'get_venues', 'args': {}, 'id': 'call_uQyv5bUaX2JBqYobgAn3f1HO', 'type': 'tool_call'}], usage_metadata={'input_tokens': 453, 'output_tokens': 12, 'total_tokens': 465, 'input_token_details': {'audio': 0, 'cache_read': 0}, 'output_token_details': {'audio': 0, 'reasoning': 0}})
ToolMessage(content="[{'name': 'Club Neon', 'location': 'Downtown', 'capacity': 100}, {'name': 'The Jazz Bar', 'location': 'Midtown', 'capacity': 50}]", tool_call_id='call_uQyv5bUaX2JBqYobgAn3f1HO')
ToolMessage(content="[{'name': 'Club Neon', 'location': 'Downtown', 'capacity': 100}, {'name': 'The Jazz Bar', 'location': 'Midtown', 'capacity': 50}]", tool_call_id='call_uQyv5bUaX2JBqYobgAn3f1HO')
AIMessage(content='', additional_kwargs={'tool_calls': [{'id': 'call_5i5UKPxA2mDv05h8Px2nxIBp', 'function': {'arguments': '{}', 'name': 'find_friends'}, 'type': 'function'}], 'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 12, 'prompt_tokens': 545, 'total_tokens': 557, 'completion_tokens_details': {'accepted_prediction_tokens': 0, 'audio_tokens': 0, 'reasoning_tokens': 0, 'rejected_prediction_tokens': 0}, 'prompt_tokens_details': {'audio_tokens': 0, 'cached_tokens': 0}}, 'model_name': 'gpt-4o-mini-2024-07-18', 'system_fingerprint': 'fp_709714d124', 'finish_reason': 'tool_calls', 'logprobs': None}, id='run-3ec69226-8a77-494d-8870-a87697cd97d0-0', tool_calls=[{'name': 'find_friends', 'args': {}, 'id': 'call_5i5UKPxA2mDv05h8Px2nxIBp', 'type': 'tool_call'}], usage_metadata={'input_tokens': 545, 'output_tokens': 12, 'total_tokens': 557, 'input_token_details': {'audio': 0, 'cache_read': 0}, 'output_token_details': {'audio': 0, 'reasoning': 0}})
ToolMessage(content="[{'name': 'Marie', 'email': 'Marie@example.com'}, {'name': 'Bohr', 'email': 'Bohr@example.com'}, {'name': 'Dirac', 'email': 'Dirac@example.com'}]", tool_call_id='call_5i5UKPxA2mDv05h8Px2nxIBp')
ToolMessage(content="[{'name': 'Marie', 'email': 'Marie@example.com'}, {'name': 'Bohr', 'email': 'Bohr@example.com'}, {'name': 'Dirac', 'email': 'Dirac@example.com'}]", tool_call_id='call_5i5UKPxA2mDv05h8Px2nxIBp')
AIMessage(content='', additional_kwargs={'tool_calls': [{'id': 'call_IyzZWED09oMG2tlIamFSdCz0', 'function': {'arguments': '{"venue_name": "Club Neon"}', 'name': 'call_venue'}, 'type': 'function'}, {'id': 'call_4XI7aFs432rkJOFJJ0oXpqng', 'function': {'arguments': '{"friend_emails": ["Marie@example.com", "Bohr@example.com", "Dirac@example.com"], "message": "Hi friends! You\'re invited to my birthday party on one of the following dates: March 15, 16, or 22. The party will be at Club Neon with dancing and live music. Let me know which date works for you!"}', 'name': 'email_friends'}, 'type': 'function'}], 'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 116, 'prompt_tokens': 647, 'total_tokens': 763, 'completion_tokens_details': {'accepted_prediction_tokens': 0, 'audio_tokens': 0, 'reasoning_tokens': 0, 'rejected_prediction_tokens': 0}, 'prompt_tokens_details': {'audio_tokens': 0, 'cached_tokens': 0}}, 'model_name': 'gpt-4o-mini-2024-07-18', 'system_fingerprint': 'fp_709714d124', 'finish_reason': 'tool_calls', 'logprobs': None}, id='run-ee35c5eb-c991-40bb-88d2-06ffc8e2306a-0', tool_calls=[{'name': 'call_venue', 'args': {'venue_name': 'Club Neon'}, 'id': 'call_IyzZWED09oMG2tlIamFSdCz0', 'type': 'tool_call'}, {'name': 'email_friends', 'args': {'friend_emails': ['Marie@example.com', 'Bohr@example.com', 'Dirac@example.com'], 'message': "Hi friends! You're invited to my birthday party on one of the following dates: March 15, 16, or 22. The party will be at Club Neon with dancing and live music. Let me know which date works for you!"}, 'id': 'call_4XI7aFs432rkJOFJJ0oXpqng', 'type': 'tool_call'}], usage_metadata={'input_tokens': 647, 'output_tokens': 116, 'total_tokens': 763, 'input_token_details': {'audio': 0, 'cache_read': 0}, 'output_token_details': {'audio': 0, 'reasoning': 0}})
Emailed Marie@example.com
Emailed Bohr@example.com
Emailed Dirac@example.com
ToolMessage(content='Friends have been emailed', tool_call_id='call_4XI7aFs432rkJOFJJ0oXpqng')
ToolMessage(content='Friends have been emailed', tool_call_id='call_4XI7aFs432rkJOFJJ0oXpqng')
AIMessage(content="Here's the summary of your birthday party plan:\n\n1. **Interests and Theme**: The party will focus on dancing, live music, and karaoke.\n2. **Date Selection**: You can choose from the available dates: March 15, March 16, or March 22, 2025.\n3. **Venue**: The party will be held at **Club Neon** in Downtown, which has a capacity of 100 guests.\n4. **Invitations**: Invitations have been sent to your friends Marie, Bohr, and Dirac, asking them to confirm their availability for one of the selected dates.\n5. **Venue Booking**: Club Neon is available for booking, and you can proceed with finalizing the details such as decorations, food, and activities once the date is chosen.\n\nYou are now set for an exciting birthday celebration!", additional_kwargs={'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 176, 'prompt_tokens': 804, 'total_tokens': 980, 'completion_tokens_details': {'accepted_prediction_tokens': 0, 'audio_tokens': 0, 'reasoning_tokens': 0, 'rejected_prediction_tokens': 0}, 'prompt_tokens_details': {'audio_tokens': 0, 'cached_tokens': 0}}, 'model_name': 'gpt-4o-mini-2024-07-18', 'system_fingerprint': 'fp_709714d124', 'finish_reason': 'stop', 'logprobs': None}, id='run-21aba564-7162-42e9-80d6-cd74f2aba421-0', usage_metadata={'input_tokens': 804, 'output_tokens': 176, 'total_tokens': 980, 'input_token_details': {'audio': 0, 'cache_read': 0}, 'output_token_details': {'audio': 0, 'reasoning': 0}})
Notice how the start of each line indicated what type of message has been generated. We have HumanMessage (our own prompts) AIMessage (returned from the model) and ToolMessage (tool results).
Also notice some output from the email tool itself:
Emailed Marie@example.com
Emailed Bohr@example.com
Emailed Dirac@example.com
Since we appended all of the state objects from graph.stream to a list called state_history, we can output the final summary like this:
print(state_history[-1]["summarize_result"]["messages"][-1].content)
Which returns my birthday plan!
Here's the summary of your birthday party plan:
1. **Interests and Theme**: The party will focus on dancing, live music, and karaoke.
2. **Date Selection**: You can choose from the available dates: March 15, March 16, or March 22, 2025.
3. **Venue**: The party will be held at **Club Neon** in Downtown, which has a capacity of 100 guests.
4. **Invitations**: Invitations have been sent to your friends Marie, Bohr, and Dirac, asking them to confirm their availability for one of the selected dates.
5. **Venue Booking**: Club Neon is available for booking, and you can proceed with finalizing the details such as decorations, food, and activities once the date is chosen.
You are now set for an exciting birthday celebration!
Best Practices
Like most aspects of AI agent design, planning capabilities can get quite complicated. It’s important to make the system as simple as possible, and no simpler. 😉
Here are some practices that can help constrain your design process:
-
Clear Goal Definition
- Specific objectives: Define exact targets and deliverables
- Measurable outcomes: Establish quantifiable success metrics
- Time-bound targets: Set clear deadlines and milestones
-
Resource Consideration
- Tool availability: Identify required software, APIs, and systems
- Time constraints: Account for processing limits and response times
- Cost limitations: Budget for API calls, compute resources, and storage
-
Error Handling
- Fallback options: Implement alternative approaches when primary methods fail
- Recovery strategies: Define procedures to handle exceptions and failures
- Plan adaptation: Adjust workflows based on unexpected outcomes or changes
Decision Making
Let’s break down what decision making is: It comes down to evaluating options and then selecting the best course of action based on defined criteria.
If an agent isn’t able to make good decisions, then it’s not going to be effective at all. In fact, it’s probably just going to cost us a lot of money.
Conclusion
Things can get complicated really quickly when designing AI agents. In case you missed it earlier, I’ll repeat some advice that I heard about good system design: “Make the system as simple as you can (and no simpler).”
Agents are a hot topic in 2025, probably because people can sense the value they are going to bring to the table.
I think it’s a bit early to expect too much from agents, but some day they will run the world.
The way I see it, we’re lucky to live in a time where there’s still a lot of (human) work needed to build out useful and reliable agentic systems.
Key Takeaways
🧩 Task decomposition helps agents break complex problems into manageable pieces.
📝 Planning capabilities enable systematic execution of multi-step tasks.
🤔 Decision making requires evaluating options against defined criteria.
✅ Best practices include clear goal definition, resource consideration, and error handling.
⚙️ Agent design should be as simple as possible while meeting requirements.
Next: AI Deployment & Productionization
Edit (2025-06): I’ve added an MCP section to the course! That’s what’s up next.
And with this final sprint through AI Agents, we’ve come to the end of our section on AI Engineering Concepts. Next up, we’ll look at an equally important and complicated topic: how to deploy and manage AI systems in production.
Comments (0)
No comments yet.