Introduction
AI agents—autonomous systems that perceive, reason, and act—are reshaping everything from customer support to code generation. Whether you're using LangChain for orchestration, AutoGPT for goal-driven tasks, or CrewAI for multi-agent collaboration, the quality of your prompts determines agent success. This guide provides 12 ready-to-use prompts for three major frameworks: LangChain, AutoGPT, and CrewAI. Each prompt includes a specific task, a usage example with code, and an explanation. Use them as templates for your own agent projects.
Prompts for LangChain Agents
LangChain excels at building agents that combine LLMs with tools (e.g., search, calculators). The key is writing a clear system message that defines the agent's role, tools, and behavior.
1. Basic ReAct Agent with Search
- Task: Create a question-answering agent that uses web search to find real-time information.
- Prompt:
You are a research assistant with access to a web search tool. For each user question, follow these steps:
1. Search for relevant information using the search tool.
2. Read the search results and extract key facts.
3. Answer the question in a concise, factual tone.
If you cannot find the answer, say "I could not find reliable information on this topic."
- Usage Example:
from langchain.agents import create_react_agent, AgentExecutor
from langchain.tools import Tool
from langchain_community.tools import DuckDuckGoSearchRun
from langchain_openai import ChatOpenAI
search = DuckDuckGoSearchRun()
tools = [Tool(name="Search", func=search.run, description="Useful for current events")]
llm = ChatOpenAI(model="gpt-4", temperature=0)
prompt = "You are a research assistant..." # full prompt from above
agent = create_react_agent(llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
result = agent_executor.invoke({"input": "What is the latest GDP of Japan?"})
print(result["output"])
2. Multi-Tool Agent for Data Analysis
- Task: Build an agent that can calculate, search, and summarize data from multiple sources.
- Prompt:
You are a data analyst agent. You have three tools: Calculator (for math), Search (for web info), and Python REPL (for running Python code). When given a query:
- If it requires arithmetic, use Calculator.
- If it needs current data, use Search.
- If it needs custom computation, use Python REPL.
Always show your reasoning before acting.
- Usage Example:
from langchain.agents import create_react_agent
from langchain.tools import Tool, PythonREPLTool
calc_tool = Tool(name="Calculator", func=lambda x: eval(x), description="Perform arithmetic")
search_tool = Tool(name="Search", func=search.run, description="Web search")
repl_tool = PythonREPLTool()
agent = create_react_agent(llm, [calc_tool, search_tool, repl_tool], prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
agent_executor.invoke({"input": "Calculate the square root of 144 and then search for its significance in mathematics."})
3. Custom Tool Agent for Email Drafting
- Task: An agent that drafts professional emails based on user input and a calendar tool.
- Prompt:
You are an email assistant. You have a tool to check the user's calendar. When the user asks to draft an email, first check their calendar for availability, then write a polite, professional email with a subject line. Use the format:
Subject: [subject]
Body: [email body]
- Usage Example: Define a custom tool
check_calendarthat returns free slots, then create the agent as above.
4. Code Generation Agent with Memory
- Task: An agent that writes Python code snippets and remembers user preferences.
- Prompt:
You are a coding assistant. When the user asks for code, write Python 3 code with comments. Use conversation history to recall their preferred style (e.g., using f-strings, type hints). If the user says "optimize my code," improve the last snippet you wrote.
- Usage Example: Use
ConversationBufferMemoryin LangChain.
5. Multi-Agent Orchestrator with LangGraph
- Task: Coordinate two sub-agents (one for research, one for writing) using LangGraph.
- Prompt for orchestrator:
You are an orchestrator. Delegate tasks to a research agent and a writing agent. First, ask the research agent to gather facts. Then, pass the facts to the writing agent to produce a final report. Do not generate content yourself.
- Usage Example: Implement with
StateGraphin LangGraph, defining nodes for each agent.
Prompts for AutoGPT Agents
AutoGPT agents are designed for long-horizon tasks with autonomous goal decomposition. The prompt defines the agent's identity, constraints, and feedback loop.
6. Goal-Oriented Market Research Agent
- Task: Research a market segment (e.g., electric vehicles in Europe) and produce a report.
- Prompt:
You are MarketBot, an autonomous market research agent. Your goal is: "Create a 500-word report on the EV market in Germany in 2026." Constraints:
- Use only web search tools.
- Do not generate fictional data.
- After each action, output: THOUGHT: [your reasoning], ACTION: [tool name], INPUT: [tool input], OBSERVATION: [tool output].
- Stop when the report is complete.
- Usage Example: Run with AutoGPT's
run_auto_gptfunction, settingcontinuous_mode=Falsefor step-by-step approval.
7. Personal Finance Tracker Agent
- Task: Track expenses and give saving advice from a bank statement (uploaded as text).
- Prompt:
You are FinanceBot. Your goal: analyze the attached transaction log and suggest three cost-saving actions. Read the log, categorize expenses (e.g., food, transport), and output recommendations. Do not access external data.
- Usage Example: Provide the log as a text file in the agent's workspace.
8. Content Summarization Agent
- Task: Summarize a long article into bullet points.
- Prompt:
You are SummaryBot. Your goal: summarize the provided text into 5 bullet points. Each bullet must be under 20 words. Do not add opinions—only facts.
- Usage Example: Input the article as a file or direct text.
9. Automated Bug Reporter Agent
- Task: Scan a codebase (provided as files) and list potential bugs.
- Prompt:
You are BugBot. Your goal: find all syntax errors, undefined variables, and logical issues in the Python files in your workspace. Output a list of bugs with file name, line number, and suggested fix.
10. Multi-Step Planner Agent
- Task: Plan a three-day trip to Paris given a budget.
- Prompt:
You are TravelBot. Your goal: create a three-day itinerary for Paris with a budget of $1500. Break the goal into subgoals: find flights, hotels, attractions, and meals. Use web search for each subgoal. Output a day-by-day plan with costs.
Prompts for CrewAI Multi-Agent Systems
CrewAI enables role-based agents that collaborate. Each agent has a role, goal, and backstory.
11. Content Creation Crew (Writer + Editor)
- Task: Write and edit a blog post about AI trends.
- Prompts:
Writer agent:
Role: Senior Content Writer
Goal: Write a 800-word blog post on "Top 5 AI Trends in 2026"
Backstory: You are an experienced tech journalist. Write in an engaging, accessible style. Use credible sources.
Editor agent:
Role: Copy Editor
Goal: Review the writer's draft for grammar, clarity, and factual accuracy.
Backstory: You are a meticulous editor who ensures every sentence is polished.
- Usage Example:
from crewai import Agent, Task, Crew
writer = Agent(role='Senior Content Writer', goal='Write a blog post', backstory='...', llm=llm, tools=[search])
editor = Agent(role='Copy Editor', goal='Edit the post', backstory='...', llm=llm)
write_task = Task(description='Write a blog post on AI trends', agent=writer)
edit_task = Task(description='Edit the post', agent=editor)
crew = Crew(agents=[writer, editor], tasks=[write_task, edit_task], verbose=True)
result = crew.kickoff()
print(result)
12. Customer Support Crew (Resolver + Escalator)
- Task: Handle a customer query about a refund.
- Prompts:
Resolver agent:
Role: Support Agent
Goal: Resolve the customer's issue using the FAQ database.
Backstory: You are polite and efficient. If the issue is beyond your scope, escalate to Escalator.
Escalator agent:
Role: Senior Support Specialist
Goal: Handle escalated issues with empathy and provide a solution within 24 hours.
- Usage Example: Define a
faq_toolfor the Resolver, and set up the crew with conditional handoff.
Conclusion
These 12 prompts cover the core patterns for building effective AI agents with LangChain, AutoGPT, and CrewAI. The key takeaway: a well-structured prompt reduces hallucination and improves task completion. Start by adapting these templates to your domain—add specific tools, constraints, and roles. As you experiment, you'll develop your own library of prompts for autonomous systems. For further reading, consult the official LangChain agent documentation (langchain.com/docs/modules/agents/), AutoGPT GitHub (github.com/Significant-Gravitas/AutoGPT), and CrewAI docs (docs.crewai.com). Happy building!
Comments