๐Ÿ“š Expert

8. Agentic Prompting

Learn to create AI agents that can plan, use tools, and complete complex multi-step tasks autonomously.

What is Agentic AI?

Agentic AI refers to systems where the AI can take actions, use tools, and make decisions to accomplish complex goals. Instead of just generating text, agents can interact with the real world.

๐Ÿš€ The Evolution: Prompt โ†’ Response has become Prompt โ†’ Plan โ†’ Act โ†’ Observe โ†’ Repeat

The Agent Loop

๐Ÿค” Think - Analyze the task and plan next steps
โ†“
๐Ÿ”ง Act - Execute an action or use a tool
โ†“
๐Ÿ‘€ Observe - Process the results
โ†“
๐Ÿ”„ Iterate - Repeat until goal is achieved

Core Components of Agent Prompts

1. ๐ŸŽฏ Goal Definition

Clearly define what success looks like.

## Your Goal Find the best-rated Italian restaurant within 2 miles of downtown Seattle that: - Has outdoor seating - Is open for dinner tonight - Has a rating of 4.5+ stars - Can accommodate a party of 6

2. ๐Ÿ”ง Available Tools

Define what tools the agent can use.

## Available Tools ### search_restaurants(query, location, filters) Search for restaurants matching criteria. Returns: List of restaurants with ratings, distance, and details. ### check_availability(restaurant_id, party_size, date, time) Check if a restaurant can accommodate a reservation. Returns: Available time slots or "unavailable" ### make_reservation(restaurant_id, party_size, date, time, name, phone) Book a reservation. Returns: Confirmation number or error message ### get_reviews(restaurant_id, limit) Fetch recent reviews for a restaurant. Returns: List of reviews with ratings and text

3. ๐Ÿ“‹ Planning Instructions

Guide how the agent should approach problems.

## Planning Guidelines 1. Break down complex tasks into smaller steps 2. Before using a tool, explain WHY you're using it 3. After each action, evaluate if you're closer to the goal 4. If stuck, try a different approach 5. Ask for clarification if requirements are ambiguous ## Thinking Format Before each action, think through: - What do I know so far? - What do I still need to find out? - What's the best next action?

4. ๐Ÿšซ Constraints & Safety

Define boundaries for agent behavior.

## Constraints - Maximum 10 tool calls per request - Do not make reservations without user confirmation - Do not access personal financial information - If unsure, ask the user rather than guessing - Always explain your reasoning ## Error Handling - If a tool fails, try once more with modified parameters - If still failing, explain the issue to the user - Never make up information if a tool doesn't return results

ReAct Pattern (Reasoning + Acting)

The most popular agentic prompting pattern. The agent explicitly states its thoughts before taking actions.

ReAct Example:
User: Book me a table for 4 at a good sushi place tonight. Thought: I need to find sushi restaurants nearby first. Let me search for options. Action: search_restaurants("sushi", "user_location", {"rating": "4+", "cuisine": "Japanese"}) Observation: Found 5 restaurants. Top rated: "Sushi Master" (4.8 stars, 0.5 miles) Thought: "Sushi Master" looks great. Let me check if they have availability for 4 people tonight. Action: check_availability("sushi_master_123", 4, "2024-12-02", "19:00") Observation: Available slots: 18:30, 19:00, 20:30 Thought: Perfect! 19:00 works. Let me confirm with the user before booking. Response: I found "Sushi Master" - a highly rated sushi restaurant (4.8โญ) just 0.5 miles away. They have availability tonight at 6:30 PM, 7:00 PM, or 8:30 PM for 4 people. Which time works best for you?

Multi-Agent Collaboration

Complex tasks can be broken down across specialized agents.

๐Ÿ“Š
Research Agent

Gathers and analyzes information

โœ๏ธ
Writer Agent

Drafts and refines content

๐Ÿ”
Critic Agent

Reviews and provides feedback

๐ŸŽฏ
Coordinator

Manages workflow between agents

Building Reliable Agents

โœ“
Include examples of tool usage

Show exactly how tools should be called and what outputs look like.

โœ“
Implement fallback strategies

What should the agent do when tools fail or return unexpected results?

โœ“
Add self-reflection prompts

"Before finalizing, review your work and check for errors."

โœ“
Set iteration limits

Prevent infinite loops with max attempts for each subtask.

Complete Agent Prompt Template

# AGENT IDENTITY You are a Travel Planning Agent that helps users plan trips. # GOAL Help the user plan their perfect trip by researching destinations, finding accommodations, and creating itineraries. # AVAILABLE TOOLS 1. search_destinations(interests, budget, duration) - Find matching destinations 2. search_hotels(location, dates, guests, budget) - Find accommodations 3. search_activities(location, interests) - Find things to do 4. check_weather(location, dates) - Get weather forecast 5. calculate_budget(items[]) - Sum up trip costs # PLANNING APPROACH 1. First, understand user preferences (destination type, budget, dates, interests) 2. Research 2-3 destination options 3. For chosen destination, find accommodations and activities 4. Create a day-by-day itinerary 5. Calculate total estimated budget 6. Present plan for user approval # RESPONSE FORMAT Always structure your responses as: **Thinking:** [Your reasoning] **Action:** [Tool to use, if any] **Result:** [What you learned] **Next Step:** [What you'll do next] # CONSTRAINTS - Stay within user's stated budget - Consider travel time between activities - Include a mix of activities (not just tourist spots) - Always check weather before recommending outdoor activities - Ask for confirmation before finalizing bookings # BEGIN User: I want to plan a 5-day trip to Japan with my partner. Budget is around $3000.
๐Ÿ”‘ Key Takeaway: Agentic prompts require clear goals, well-defined tools, explicit reasoning patterns, and robust safety constraints. The future of AI is agents that can act autonomously while staying aligned with user intentions.
๐Ÿงช

Try It Yourself

Practice what you learned with our interactive tools.

โœจ Open Magic Optimizer
๐Ÿ’ก

Pro Tips

  • โ€ข Be specific with your instructions
  • โ€ข Use examples when possible
  • โ€ข Iterate and refine your prompts

Sign in to track your progress

Sign in to Complete