15 Prompts for Building AI Agents: LangChain, AutoGPT, and CrewAI
Introduction
Imagine a software system that doesn't just wait for commands but actively plans, executes subtasks, and collaborates with other digital workers to achieve a complex goal. This is the reality of AI agents in 2026. Unlike simple chatbots that answer one question at a time, an AI agent can decompose a request like "Find the best price for a flight to Tokyo and book it" into a sequence of actions: search, compare, select, and execute. The magic behind this capability lies not just in the underlying large language model (LLM), but in the prompts that orchestrate its behavior.
In this article, we'll dive into 15 battle-tested prompts for building AI agents using three leading frameworks: LangChain, AutoGPT, and CrewAI. These prompts are the recipes that turn a raw LLM into a tool-using, memory-retaining, and collaborative agent. We'll walk through real-world examples—from a customer support triage bot to a multi-agent marketing team—complete with code snippets and results. Whether you're a builder or a product manager, these prompts will give you a practical foundation for agent development.
Why Prompts Are the Core of Agent Architecture
An AI agent is essentially a loop: perceive → think → act. The LLM inside the agent receives a system prompt that defines its role, available tools, and constraints. Then, each user query is wrapped in a conversation history and a task description. The quality of these prompts directly determines whether your agent will hallucinate, get stuck in loops, or actually solve problems.
For example, a poorly written prompt might cause a LangChain agent to call a calculator tool for a text summarization task. A well-crafted prompt, on the other hand, guides the agent to first reason about which tool is appropriate, then execute, and finally summarize the result. Let's look at how this works in practice.
15 Prompts for AI Agents
1. LangChain: ReAct Agent with Tool Selection
Prompt pattern: "You are an agent with access to the following tools... Use a step-by-step approach."
from langchain.agents import create_react_agent
from langchain_core.prompts import PromptTemplate
prompt = PromptTemplate.from_template(
"""You are an AI assistant that can use external tools to answer questions.
You have access to the following tools: {tools}.
Use the following format:
Question: the input question
Thought: you should always think about what to do
Action: the action to take, should be one of [{tool_names}]
Action Input: the input to the action
Observation: the result of the action
... (this Thought/Action/Action Input/Observation can repeat N times)
Thought: I now know the final answer
Final Answer: the final answer to the original input question
Begin!
Question: {input}
Thought: {agent_scratchpad}"""
)
Real-world use case: A customer support bot for an e-commerce platform. When a user asks "Where is my order?", the agent thinks: "I need to look up the order status. I'll use the 'order_lookup' tool." It calls the tool, gets the status, and returns a human-friendly answer. This pattern reduces hallucination by forcing the agent to externalize its reasoning (the "Thought" step).
2. LangChain: Conversation Buffer Memory
Prompt pattern: "Use the following pieces of context to answer the question at the end."
from langchain.memory import ConversationBufferMemory
memory = ConversationBufferMemory(return_messages=True)
# In the prompt, include: {chat_history}
Real-world use case: A legal research assistant. The user asks, "What are the key clauses in contract A?" Then, "How do they compare to contract B?" The memory prompt ensures the agent remembers the first answer and can compare without re-querying. Without this, the agent would treat the second question as isolated.
3. AutoGPT: Goal Decomposition
Prompt pattern: "You are an autonomous agent. Your goal is: {goal}. Break it down into subgoals."
Goal: "Generate a weekly social media content plan for a new SaaS product."
Subgoal 1: Research trending topics in the SaaS space.
Subgoal 2: Draft 5 post ideas.
Subgoal 3: Create images using DALL-E.
Subgoal 4: Schedule posts in Buffer.
Real-world use case: A marketing team uses AutoGPT to automate their content calendar. The agent uses web search (tool) for trending topics, then generates text and image prompts. The prompt ensures the agent doesn't try to do everything at once but sequences tasks logically.
4. AutoGPT: Constraint Enforcement
Prompt pattern: "You must adhere to these constraints: {constraints}. If you cannot complete the task, explain why."
Constraints:
- You can only use tools from the allowed list: web_search, file_write, python_repl.
- Do not generate more than 500 words total.
- You must verify all facts with at least two sources.
Real-world use case: A research agent that must produce a short, fact-checked report. Without constraints, AutoGPT might write a novel or hallucinate. This prompt keeps it focused and reliable.
5. CrewAI: Role Definition for Multi-Agent Systems
Prompt pattern: "You are a {role}. Your goal is {goal}. You work with {collaborators}."
from crewai import Agent
researcher = Agent(
role='Senior Researcher',
goal='Find the latest trends in AI regulation in the EU',
backstory='You are a policy expert with 10 years of experience.',
tools=[web_search_tool],
verbose=True
)
writer = Agent(
role='Content Writer',
goal='Write a compelling blog post based on the researcher findings',
backstory='You specialize in simplifying complex policy topics.',
tools=[file_write_tool],
verbose=True
)
Real-world use case: A content production pipeline. The researcher agent gathers data, the writer agent synthesizes it. The prompt defines each agent's expertise and prevents overlap. For example, the writer won't try to search the web—it trusts the researcher's output.
6. CrewAI: Task Delegation Prompt
Prompt pattern: "Delegates work to {other_agent}. Provide context and expected output."
Task: "Summarize the key points from the researcher's report into a 3-paragraph draft."
Agent: writer
Context: The report is about GDPR updates in 2026.
Real-world use case: In a multi-agent system for due diligence, the coordinator agent delegates "financial analysis" to a finance agent and "legal review" to a legal agent. The prompt ensures each sub-task is clearly scoped.
7. Tool-Use Prompt for LangChain (Calculator)
Prompt pattern: "You have a calculator tool. For any arithmetic, use it. Do not compute in your head."
from langchain.tools import tool
@tool
def calculator(expression: str) -> float:
"""Evaluates a mathematical expression."""
return eval(expression)
# In the system prompt: "Always use the calculator tool for math. Never compute manually."
Real-world use case: A financial analysis agent that calculates ROI. Without this prompt, the LLM might hallucinate a result like "ROI = 23.5%" based on vague reasoning. With the prompt, it calls the calculator tool with actual numbers.
8. Error Recovery Prompt
Prompt pattern: "If a tool returns an error, try a different approach. If all approaches fail, say 'I cannot complete this task because...'"
Real-world use case: An agent that queries a database API. If the API returns a 500 error, the agent might retry with a simpler query or fall back to cached data. This prevents the agent from crashing or repeating the same failed call infinitely.
9. Multi-Step Reasoning Prompt (Chain-of-Thought)
Prompt pattern: "Let's think step by step. Outline your reasoning before taking any action."
Question: "What is the population of the capital of France multiplied by 2?"
Thought: First, I need to find the capital of France. That's Paris. Then find its population. Then multiply by 2.
Action: web_search
Action Input: "Paris population 2026"
Observation: 2.1 million
Thought: Now multiply 2.1 million by 2.
Action: calculator
Action Input: 2100000 * 2
Observation: 4200000
Final Answer: 4,200,000
Real-world use case: Any agent that requires multi-step logic, like travel planning (find destination → check weather → find flights → book).
10. Tone and Style Prompt for Agent Output
Prompt pattern: "Respond in a {tone} tone. Use {style} formatting."
Tone: professional, concise
Style: bullet points, no more than 3 sentences per point
Real-world use case: An internal reporting agent that generates daily status updates for executives. The prompt ensures the output is skimmable and actionable.
11. LangChain: Agent with Custom Tool Descriptions
Prompt pattern: "Tool descriptions must clearly state when to use them."
@tool
def send_email(recipient: str, subject: str, body: str) -> str:
"""Use this tool to send an email. Only use when the user explicitly asks to send an email."""
# implementation
Real-world use case: An assistant that can both search the web and send emails. Without a good description, the agent might call send_email to store a note. The prompt clarifies the tool's purpose.
12. AutoGPT: Feedback Loop Prompt
Prompt pattern: "After each action, evaluate progress toward the goal. If stuck, ask for human input."
Progress: 2 of 5 subgoals completed.
Next: Create images.
Evaluation: On track.
Real-world use case: A long-running AutoGPT task like "Build a competitor analysis report." The agent periodically checks its own progress and can pause if it hits a dead end (e.g., a paywalled source).
13. CrewAI: Context Sharing Prompt
Prompt pattern: "When passing context to another agent, include: summary, key facts, and open questions."
Context for writer:
- Summary: Competitor X launched a new feature.
- Key facts: Price $99/mo, available in US only.
- Open questions: How does it compare to our feature?
Real-world use case: A multi-agent system for product analysis. The researcher passes structured context to the writer, ensuring the final report is coherent.
14. Safety and Guardrails Prompt
Prompt pattern: "If the user asks for illegal or harmful actions, refuse politely. Do not output code that could be used for hacking."
Real-world use case: A customer-facing agent. Without this, a user could trick the agent into generating malicious scripts. The prompt acts as a first line of defense.
15. Output Formatting Prompt
Prompt pattern: "Return the result as a JSON object with keys: 'status', 'data', 'error'."
{
"status": "success",
"data": {"population": 2100000},
"error": null
}
Real-world use case: An API agent that other systems call programmatically. Ensuring structured output makes integration seamless.
Real-World Case Study: Multi-Agent Customer Support
Let's tie these prompts together with a concrete example. A mid-size e-commerce company built a support system using CrewAI with three agents:
- Triage Agent (prompt: role-based, constraint enforcement, tone)
- Order Agent (prompts: tool-use, error recovery, multi-step reasoning)
- Escalation Agent (prompt: context sharing, output formatting)
Problem: The company received 500+ support tickets daily. Manual triage took hours.
Solution: The Triage Agent, prompted to classify issues (order status, return, complaint) using a classification tool. It then delegates to the Order Agent (which uses order lookup and calculator tools) or Escalation Agent (which formats a summary for human agents).
Result: 70% of tickets resolved fully by agents. Average response time dropped from 4 hours to 2 minutes. The system used prompt #8 (error recovery) to handle API failures gracefully.
Conclusion
Prompts are the unsung heroes of AI agent development. They define not just what an agent says, but how it thinks, acts, and collaborates. The 15 prompts we've covered—from LangChain's ReAct pattern to CrewAI's role definitions—form a toolkit for building agents that are reliable, safe, and effective in real-world applications.
As you build your own agents, remember: iterate on prompts as much as you iterate on code. A well-crafted prompt can turn a fragile prototype into a production-ready assistant. Start with these patterns, adapt them to your domain, and watch your agents evolve from simple chatbots to autonomous digital workers.
ASI Biont supports integration with LangChain and CrewAI through its API orchestration layer — learn more at asibiont.com/courses.
Comments