10 Prompts for Building AI Agents: LangChain, AutoGPT, and CrewAI
Introduction
AI agents are transforming how we automate complex workflows. Whether you're building a single autonomous agent with AutoGPT or orchestrating a multi-agent system with CrewAI, the quality of your prompts determines success. According to the LangChain documentation (langchain.com/docs), well-structured prompts can improve task completion rates by over 40%. This guide provides 10 ready-to-use prompts for three leading frameworks: LangChain, AutoGPT, and CrewAI. Each prompt includes an explanation, a usage example, and a code snippet to copy-paste into your projects.
1. LangChain: Conversational Retrieval Agent Prompt
Task: Create a retrieval-augmented generation (RAG) agent that answers questions based on a custom knowledge base.
Explanation: This prompt instructs an agent to use a vector store for context retrieval, then generate a concise answer. It's ideal for customer support or internal documentation tools.
Usage example: Deploy this agent in a helpdesk chatbot that pulls answers from product manuals.
from langchain.agents import AgentExecutor, create_react_agent
from langchain.prompts import PromptTemplate
from langchain.tools import Tool
from langchain_openai import ChatOpenAI
# Define a tool for retrieval
retrieve_tool = Tool(
name="KnowledgeBase",
func=lambda q: "Your knowledge base result here",
description="Retrieves information from the knowledge base."
)
# Prompt template
prompt = PromptTemplate(
input_variables=["input", "agent_scratchpad", "intermediate_steps"],
template="""You are an AI assistant with access to a knowledge base. Use the KnowledgeBase tool to find relevant information. Answer concisely. If you don't know, say you don't know.
User question: {input}
{agent_scratchpad}"""
)
llm = ChatOpenAI(model="gpt-4", temperature=0)
agent = create_react_agent(llm, [retrieve_tool], prompt)
agent_executor = AgentExecutor(agent=agent, tools=[retrieve_tool], verbose=True)
print(agent_executor.invoke({"input": "What is the return policy?"}))
2. LangChain: Multi-Tool Orchestration Prompt
Task: Create an agent that can call multiple APIs (e.g., weather, calendar, email) based on user intent.
Explanation: The prompt defines a persona and a set of tools, teaching the agent to reason about which tool to use.
Usage example: A personal assistant that checks weather, schedules meetings, and sends reminders.
from langchain.agents import Tool, AgentExecutor, create_react_agent
from langchain.prompts import PromptTemplate
prompt = PromptTemplate(
input_variables=["input", "agent_scratchpad"],
template="""You are a helpful assistant with access to tools: get_weather, schedule_meeting, send_email. Decide which tool to use based on the user request. Provide a friendly response.
User: {input}
{agent_scratchpad}"""
)
3. LangChain: Chain-of-Thought Prompt for Complex Reasoning
Task: Make the agent think step-by-step before acting.
Explanation: Chain-of-thought prompting improves accuracy on math, logic, and planning tasks (Wei et al., 2022).
Usage example: A financial analyst agent that calculates investment returns.
prompt = PromptTemplate(
input_variables=["input"],
template="""You are a financial analyst. Think step by step. First, identify the variables. Then, apply the formula. Finally, output the result.
Question: {input}
Step 1:"""
)
4. AutoGPT: Goal-Oriented Task Decomposition Prompt
Task: Decompose a high-level goal into sub-tasks.
Explanation: AutoGPT uses a loop: think, act, observe. This prompt instructs it to break down "plan a marketing campaign" into research, content creation, and scheduling.
Usage example: Automating market research for a new product.
# Pseudo-code for AutoGPT prompt
system_prompt = """You are AutoGPT. Your goal: {goal}. Break this goal into 5 sub-tasks. For each sub-task, provide a command to execute (e.g., browse_web, write_file). Continue until the goal is complete.
Goal: Plan a digital marketing campaign for a SaaS product.
Sub-task 1: Research competitors using browse_web.
Sub-task 2: Write blog post outline using write_file.
..."""
5. AutoGPT: Memory and Reflection Prompt
Task: Make the agent remember past actions and reflect on them.
Explanation: Include a memory section in the prompt to avoid repetition and improve coherence.
Usage example: A research agent that reads multiple sources and summarizes findings.
system_prompt = """You are AutoGPT with memory. Here is your history: {memory}. Reflect on what you have done so far. What is the next logical step? Do not repeat actions."""
6. AutoGPT: Constrained Action Prompt
Task: Limit the agent's actions to a whitelist (e.g., only search and write).
Explanation: Prevent dangerous or unintended actions by restricting the tool set.
Usage example: An agent that only reads web data and writes to a local file.
system_prompt = """You are AutoGPT. Allowed actions: google_search, write_to_file. Forbidden actions: delete_file, execute_command. Stay within these boundaries."""
7. CrewAI: Role-Based Agent Prompt (Researcher)
Task: Define a researcher agent in a multi-agent crew.
Explanation: CrewAI allows role assignment (e.g., researcher, writer). This prompt sets the researcher's persona.
Usage example: A content creation crew where one agent researches, another writes.
from crewai import Agent
researcher = Agent(
role='Researcher',
goal='Find the latest trends in AI',
backstory='You are a data scientist with 10 years of experience.',
llm='gpt-4',
verbose=True
)
8. CrewAI: Task Delegation Prompt
Task: Create a manager agent that delegates tasks to other agents.
Explanation: The manager decides which agent handles which subtask based on their roles.
Usage example: A project management crew that assigns coding tasks to a developer agent.
manager = Agent(
role='Manager',
goal='Coordinate tasks among team members',
backstory='You are a seasoned project manager.',
allow_delegation=True
)
9. CrewAI: Sequential Task Chain Prompt
Task: Define a sequence of tasks that agents execute one after another.
Explanation: Use Task objects with dependencies to create a pipeline.
Usage example: A news aggregation pipeline: scrape → summarize → publish.
from crewai import Task, Process
task1 = Task(description='Scrape news articles', agent=researcher)
task2 = Task(description='Summarize articles', agent=writer)
crew = Crew(agents=[researcher, writer], tasks=[task1, task2], process=Process.sequential)
10. Hybrid Prompt: LangChain + CrewAI for Multi-Agent RAG
Task: Combine LangChain's RAG with CrewAI's orchestration.
Explanation: Use LangChain for retrieval within a CrewAI agent to answer questions from a database.
Usage example: A multi-agent customer support system where one agent retrieves data, another writes responses.
from langchain.tools import Tool
from crewai import Agent
retrieve_tool = Tool(
name="Retrieve",
func=lambda q: "data from DB",
description="Retrieves customer info."
)
support_agent = Agent(
role='Support Agent',
goal='Answer customer queries using retrieved data',
tools=[retrieve_tool]
)
Conclusion
These 10 prompts cover the three major frameworks: LangChain for flexible tool use, AutoGPT for autonomous goals, and CrewAI for multi-agent collaboration. The key is to match the prompt style to your task—use chain-of-thought for reasoning, role-based prompts for teams, and constrained prompts for safety. Start by copying the examples above, then tweak them for your specific data and workflows. The full source code for these examples is available on GitHub (github.com/langchain-ai/langchain). Happy building!
Last updated: July 2026
Comments