Introduction
AI agents are no longer a futuristic concept—they are here, building software, automating workflows, and making decisions on their own. Whether you’re using LangChain for orchestration, AutoGPT for autonomous task completion, or CrewAI for multi-agent collaboration, the quality of your agents hinges on one thing: the prompts you feed them.
This guide collects 30 battle-tested prompts that I use daily in production systems. Each prompt is paired with a real-world example, an explanation of why it works, and tips for customization. You’ll find prompts for single-agent tasks, multi-agent coordination, debugging, and safety.
By the end, you’ll have a toolkit that saves hours of trial-and-error. Let’s dive in.
1. Prompts for LangChain Agents
LangChain agents combine LLMs with tools. The prompt defines the agent’s personality, reasoning style, and constraints.
1.1 Role-Based Task Decomposition
Prompt:
You are a senior software architect. Break down the following user request into a sequence of actionable steps. For each step, identify the required tool (e.g., Python REPL, web search, file system). Output as a numbered list.
Example: User says: "Find the latest research on LLM hallucinations and summarize it."
Why it works: The role (senior architect) forces the agent to think structurally. The explicit tool requirement prevents vague steps.
1.2 Context Injection for Stateful Agents
Prompt:
You are a customer support agent. The conversation history is below. Use it to answer the user’s latest query. If you need more context, ask a clarifying question. Do not repeat solutions already suggested.
History: {history}
User: {input}
Example: Used in a chatbot for a SaaS company. The agent remembers previous troubleshooting steps, avoiding repetition.
1.3 Tool Selection with Guardrails
Prompt:
You have access to these tools: {tool_names}. For the user request, choose the most appropriate tool. If multiple tools could work, explain your choice in one sentence. If no tool fits, say "I cannot complete this request with available tools."
Why it works: Prevents the agent from hallucinating tool usage. Forces transparency.
1.4 Chain-of-Thought with Confidence
Prompt:
Think step-by-step. After each step, rate your confidence (1-5). If confidence drops below 3, stop and ask for clarification.
Example: An agent doing financial analysis. When data is ambiguous, it pauses instead of producing wrong results.
1.5 Multi-Step Reasoning with Constraints
Prompt:
You are solving a math problem. Show all work. Constraint: never use floating-point arithmetic—only integers or fractions.
Why it works: Real-world use: calculating token costs where precision matters.
2. Prompts for AutoGPT Agents
AutoGPT agents run autonomously. Prompts here focus on goal-setting, iteration, and stopping conditions.
2.1 Goal Definition with Success Criteria
Prompt:
Your goal: {goal}. Define success criteria as a checklist. Execute tasks until all criteria are met. If you cannot meet a criterion after 3 attempts, mark it as failed and move on.
Example: Goal: "Create a marketing report for Q2." The agent checks: data collected, charts generated, PDF exported. It stops only when all are done.
2.2 Iterative Improvement Loop
Prompt:
You have generated output. Now generate three alternative versions. Compare them against the original using these metrics: {metrics}. Select the best version and output it.
Why it works: AutoGPT can run in loops. This prompt makes it self-improve without human intervention.
2.3 Resource Budgeting
Prompt:
You have a budget of 10 API calls. Plan which calls to make. After each call, update the remaining budget. When budget is zero, stop and summarize what you achieved.
Example: Agent scraping a website. It prioritizes pages with highest relevance scores.
2.4 Error Recovery Strategy
Prompt:
If a tool returns an error, log the error and try one alternative approach. If that also fails, explain the issue and ask for user input.
Why it works: Prevents infinite loops. AutoGPT without this can burn tokens on retries.
2.5 Context Window Management
Prompt:
You have a token limit of 4000 tokens per response. Keep your internal state concise. If you need to remember something, store it in a JSON file. Do not exceed the limit.
Example: Long-running research agent that summarizes intermediate findings to a file.
3. Prompts for CrewAI Multi-Agent Systems
CrewAI orchestrates multiple agents with different roles. Prompts need to define responsibilities and communication.
3.1 Agent Role Definition
Prompt:
You are the {role} agent. Your responsibilities: {responsibilities}. You communicate only through structured messages with fields: sender, receiver, message_type, payload.
Example: role: "Data Analyst", responsibilities: "Clean data, generate statistics, output to CSV".
3.2 Handoff Protocol
Prompt:
When your task is complete, send a message to {next_agent} with type "handoff" and payload containing your output. Wait for acknowledgment before starting a new task.
Why it works: Prevents race conditions where agents start working on incomplete data.
3.3 Conflict Resolution
Prompt:
If two agents provide conflicting outputs, do the following: 1) Log both outputs. 2) Check each against the original goal. 3) Select the one that better satisfies the goal. 4) Explain your decision in one sentence.
Example: In a content creation crew, the Writer and Editor may disagree on tone. This prompt makes the Manager agent resolve it.
3.4 Parallel Task Coordination
Prompt:
You are the orchestrator. Decompose the goal into parallel tasks. Assign each to an agent using a task message. Collect results. Merge them using these merge rules: {rules}.
Why it works: CrewAI supports parallel execution; this prompt makes it explicit.
3.5 Progress Reporting
Prompt:
Every 5 steps, generate a progress report in format: {step_number, task, status, remaining_estimated_steps}. Send to the user via the report channel.
Example: A research crew investigating a topic. The user gets updates every few minutes.
4. Prompts for Debugging and Observability
4.1 Self-Diagnosis
Prompt:
Review your last 5 actions. Identify any mistakes or inefficiencies. Output a list of improvements for the next iteration.
Why it works: Turns the agent into its own debugger.
4.2 Token Usage Logging
Prompt:
For each LLM call, log: model, input_tokens, output_tokens, cost. At the end, output a summary table.
Example: Used to monitor costs in a production LangChain app.
4.3 Edge Case Handling
Prompt:
List three edge cases that could break your current workflow. For each, propose a fallback behavior.
Why it works: Proactive safety. Agents designed this way fail gracefully.
5. Prompts for Safety and Ethical Constraints
5.1 Content Moderation
Prompt:
Before responding, check the output against this policy: {policy}. If it violates, replace with a safe alternative and log the violation.
Example: A customer-facing agent must avoid giving financial advice.
5.2 PII Redaction
Prompt:
Scan all inputs and outputs for PII (emails, phone numbers, SSNs). Replace with [REDACTED]. Keep a log of redacted fields.
Why it works: GDPR compliance without manual review.
5.3 Escalation Prompt
Prompt:
If the user requests something outside your defined scope, say "I cannot do that. Would you like me to escalate to a human?" Then escalate via {api_endpoint}.
Example: Used in legal document assistants.
6. Prompts for Specific Use Cases
6.1 Code Generation with Testing
Prompt:
Generate Python code for {task}. Then generate unit tests using pytest. Run the tests. If any fail, fix the code and re-run until all pass.
Why it works: Self-healing code generation.
6.2 Data Extraction from PDFs
Prompt:
Extract all tables from the PDF. For each table, output as CSV. If the PDF is scanned, first apply OCR. Log any rows that are incomplete.
Example: Automating invoice processing.
6.3 Real-Time Monitoring
Prompt:
Monitor the API endpoint {url} every 60 seconds. If response time exceeds 2 seconds, send an alert to {webhook}. Keep a moving average of response times.
Why it works: Turns an LLM into a simple monitoring agent.
7. Advanced: Meta-Prompts for Prompt Engineering
7.1 Prompt Optimization Prompt
Prompt:
Analyze this prompt: {prompt}. Suggest three improvements to make it more specific, reduce ambiguity, or add constraints. Output the improved prompt.
Why it works: AI helps you write better prompts for AI.
7.2 Few-Shot Example Generator
Prompt:
Generate 5 examples of good user queries for this system: {system_description}. Each example should include an ideal agent response.
Example: Used to build training data for a custom agent.
7.3 Prompt Template Builder
Prompt:
Create a reusable prompt template for {task_type}. Include placeholders for: {placeholders}. Add instructions for when to use each placeholder.
Why it works: Standardizes prompt engineering across a team.
8. How to Customize These Prompts
| Parameter | What to Change | Example Change |
|---|---|---|
| Role | Match domain expertise | "Senior Data Scientist" vs "Junior Developer" |
| Tools | List actual tools | "Python REPL, Web Search, Calculator" |
| Success Criteria | Define measurable outcomes | "Save to database, send email notification" |
| Constraints | Add business rules | "Never delete files, always confirm before write" |
| Tone | Adjust for audience | Formal for legal, casual for customer support |
Conclusion
Prompts are the operating system of AI agents. A well-crafted prompt can turn a generic LLM into a reliable, autonomous worker. The 30 prompts above cover the most common patterns I’ve encountered: role definition, tool selection, error handling, multi-agent coordination, safety, and debugging.
Start by copying one of these prompts into your LangChain, AutoGPT, or CrewAI project. Run it. Observe the output. Then tweak the parameters in the table above. Over time, you’ll develop a library of prompts that make your agents predictable, efficient, and safe.
For teams building multi-agent systems, ASI Biont supports seamless integration with CrewAI and LangChain through our API orchestration layer—more on that at asibiont.com/blog.
Comments