AI agents are changing how we automate complex tasks. Instead of one-off LLM calls, agents combine reasoning, tools, and memory to act autonomously. But the quality of an agent depends heavily on the prompts that shape its behavior. Here are 10 battle-tested prompts you can use today with LangChain, AutoGPT, or CrewAI – each with a practical example.
Why Prompts Are the Backbone of Agents
Prompts are not just instructions; they define the agent's identity, goals, and boundaries. LangChain's agent framework relies on the ReAct model (reasoning + acting), where the prompt tells the LLM when to reason and when to call tools. AutoGPT's famous autonomous loop uses prompts to decompose goals and evaluate progress. CrewAI takes a multi-agent approach, where prompts handle role assignment and handoff. A well-crafted prompt can turn a generic LLM into a reliable, task-specific agent.
1. Agent Role Definition
Prompt: “You are an autonomous research agent. Your mission is to gather accurate information from the web. Use the search_tool and content_tool. Always cite sources. If unsure, say 'I need more data'.”
This prompt sets clear identity and constraints. In LangChain, pass it as the system_message:
from langchain.agents import initialize_agent
agent = initialize_agent(tools, llm, system_message="You are an autonomous research agent...")
2. Task Decomposition (AutoGPT-style)
Prompt: “Break the objective into an ordered list of subtasks. For each subtask, define the tool needed, success criteria, and dependencies. Execute them sequentially, updating the list after each step.”
AutoGPT uses this pattern to avoid losing track of long-term goals. It keeps the agent focused and makes progress measurable.
3. Tool Selection Prompt
Prompt: “Given the user request, choose the most appropriate tool from: web_search, code_executor, database. Return a JSON with: tool, input, and reasoning. If no tool fits, reply with 'no_tool'.”
This prompt forces structured output, making agent decisions predictable. Works great with OpenAI function calling.
4. Reflection and Self-Critique
Prompt: “You have just completed a task. Review your output as a skeptical editor. Identify logical errors, gaps, and unsupported claims. Provide a revised version.”
Adding a self-critique step improves output quality significantly. Many production agents use this as a second LLM call.
5. Multi-Agent Handoff (CrewAI style)
Prompt: “You are the coordinator agent. You have a problem that requires expertise. Pass the context to the appropriate specialist agent using the 'transfer_to_researcher' action. Include the original goal and any constraints.”
In CrewAI, tasks define similar prompts so agents cooperate and delegate. Example from CrewAI docs: set a description and expected_output for each task.
6. Context Management / Memory Compression
Prompt: “Summarize the conversation so far into a compact set of facts. Keep only info needed for the current task. Output in bullet points. Limit to 5 items.”
Long conversations exceed context windows. This prompt condenses memory and reduces token costs.
7. Reasoning with Chain-of-Thought
Prompt: “Solve the problem step by step. Write down each step explicitly before giving the final answer. Ensure every step follows logically from the previous.”
Chain-of-thought prompting boosts accuracy in arithmetic, logic, and multi-step planning. It's a core technique in agent architectures.
8. Function Calling Prompt
Prompt: “You have access to functions. Extract parameters from the user's request and output a JSON object that exactly matches the function signature. Example: {\"function\":\"weather\",\"args\":{\"city\":\"Berlin\"}}"
This prompt enables reliable tool use without free-form text. Pair it with an API schema and validate the output.
9. Safety / Guardrails Prompt
Prompt: “If the user asks you to perform an action that could cause physical, financial, or reputational harm, refuse politely and suggest a safe alternative. Never execute code without explicit user approval.”
Safety is critical for real-world agents. This prompt prevents costly mistakes and protects users.
10. Evaluation Prompt
Prompt: “Evaluate the agent's output on a scale of 1-5 for: accuracy, completeness, clarity. Provide specific feedback for each criterion. Include suggestions for improvement.”
Use this after an agent finishes a task. It's a simple way to build a feedback loop for continuous improvement.
Where to Go Next
Start with one prompt and adapt it to your workflow. The official docs are excellent resources: LangChain (python.langchain.com/docs/modules/agents/), AutoGPT (github.com/Significant-Gravitas/AutoGPT), and CrewAI (docs.crewai.com). Each contains more examples and best practices.
These 10 prompts cover the core patterns behind successful agents. Test them, mix them, and see the difference in your agent's performance.
Comments