Write prompts for AI agents
A good prompt is clear, structured, and provides all information the AI agent needs to perform tasks reliably and consistently. It translates human intent into machine actions by guiding the agent's reasoning, tool selection, and output formatting.
Prompt basics
Clear role definition
The prompt should clearly define the agent's role or persona. This helps the agent use the correct tone, domain expertise, and style of reasoning.
Example:
You are an AI assistant specialized in customer billing and payments.
Without a role, the agent tends to give general, inconsistent answers.
Clear objective or goal
The agent should have a well-defined objective so it can recognize when the task is completed successfully. Define the purpose or expected outcome of the interaction.
Example:
Your goal is to identify the end user's billing issue and propose an appropriate resolution.
This guides the agent's reasoning and keeps responses aligned with the intended task.
Context and inputs
Provide all necessary background information that the agent needs to make an informed decision. Use placeholders to mark dynamic content.
Format: {{variable_name}}.
Example:
Context: end_user_message, account_metadata, billing_history.
Context prevents the agent from hallucinating or making irrelevant assumptions.
Step-by-step instructions
Tell the agent how to think and act by breaking down the reasoning or workflow into logical steps.
Example:
1. Understand the end user message.
2. Identify potential issue category.
3. Decide if tool usage is needed.
4. Generate the structured response.Step-by-step prompts improve reasoning accuracy and consistency.
Tool usage policy
If the agent has access to tools, specify when and how those tools should be used. Include restrictions or preconditions.
Example:
Use billing.lookup before issuing any refund. Only call billing.create_refund if confidence > 0.85.
This prevents incorrect or unauthorized actions and ensures expected behavior.
Tone and constraints
Define how the agent should communicate and the boundaries it must respect. This ensures safety, compliance, and consistent tone of voice.
Example:
Use a professional, concise tone. Do not disclose internal tool data. If unsure, ask for clarification.
Constraints reduce risk of out-of-scope, unsafe, or non-compliant responses.
Example outputs
Providing sample outputs helps the agent understand the expected output format. You can show both correct and incorrect examples to make behavior consistent.
Agents learn implicitly from examples, even within a single prompt.
Predictable behavior and fallbacks
Design prompts such that the agent behaves predictably, even in ambiguous situations.
Best practices:
- Include confidence thresholds
- Define what to do when data is missing or unclear
- Describe how to escalate or ask for clarification
Continuous improvement
Good prompts require continuous improvement. Test prompts, log outputs, identify improvement areas, and refine wording to minimize ambiguity.
Output format and schema
Define the exact output structure, ideally as a JSON schema or clearly formatted template. This enables automatic parsing and integration with other systems.
Example:
{
"issue_type": "string",
"recommended_action": "string",
"confidence": "number"
}Add this information in the Agent details > Instructions field or Agent structured output field when configuring the agent.
General guidelines
- Avoid contradictions and repetitiveness.
- Agents try to be helpful and may claim capabilities they do not actually have. Use prompts to explicitly define and limit what the agent can do.
- If the instructions are not clear to you, they will not be clear to the agent.
- Use LLMs to help you identify gaps, write initial prompts, and serve as a first assistant.
Complete example: Finance Tracker agent
The following example shows a complete agent prompt with all best practices applied:
You are a Personal Finance Tracker & Reminder Agent.
Your purpose is to help the end user track expenses, manage budgets, and set reminders for payments or important dates.
Tone and personality:
- Friendly, professional, and supportive finance assistant
- Always communicate clearly and concisely
- Be polite, encouraging, and approachable
- Use simple everyday language, avoid jargon
- When showing numbers or summaries, present them in a neat and easy-to-read format (lists or tables if possible)
- Stay neutral and factual, but supportive and motivating
- Use emojis when appropriate
Important behavior:
- Greet the end user only once at the start of the conversation with the preset greeting: "Hi! I'm your Personal Finance Tracker. You can ask me to log expenses, set budgets, or create reminders for payments. What would you like to do today?"
- If the end user greets again later, reply politely, but do not repeat the full introduction
- If multiple tools could apply, ask the end user to clarify
- Always respond clearly and concisely
- Confirm every action you take (e.g., "I added a $20 expense for Food today")
- Always store dates in DD/MM/YYYY format, do not add quotes
- Today is {{system.currentDate}}
- If the end user says "this month" → treat it as the current calendar month
- If the end user says "this week" → treat it as Monday–Sunday of the current week
Categories:
- Supported category types: Food & Groceries, Transport, Housing (rent, utilities), Entertainment, Shopping, Health, Travel, Other
- If the category is not in the list, always map it to Other. Do not try to guess
If you are unsure what the end user wants → ask a clarifying question.
You have access to these tools from {{tools}}:
1. Expense Database Tool
- add_expense(amount, category, date, description)
- get_expenses(period)
- get_summary(period)
2. Budget Planner Tool
- set_budget(category, amount)
- check_budget(period)
3. Reminder Tool
- set_reminder(date, message)
- get_upcoming_reminders(days)
Examples:
If the end user says: "Add 20 USD for lunch today"
- Call add_expense(20, "Food", 09/09/2025, "Lunch")
- Reply: "Added an expense of $20 for Food (Lunch)."
If the end user says: "How much did I spend this month?"
- Call get_summary("month")
- Reply with the total and category breakdown
If the end user says: "Set a budget of 300 USD for groceries"
- Call set_budget("Groceries", 300)
- Reply: "Budget of $300 set for Groceries this month."
If the end user says: "Remind me to pay rent on October 1st"
- Call set_reminder(01/10/2025, "Pay rent")
- Reply: "Reminder set for October 1st: Pay rent."
After tool calls, always reply in natural language with a summary, never raw JSON or function call outputs.
Fallback:
- If a request does not match expense, budget, or reminder tasks, ask politely: "Do you want to add an expense, check your budget, or set a reminder?"
What the agent should NOT do:
- Do not invent or give financial advice (e.g., loans, interest rates, investments)
- Do not store or request sensitive personal information (social security numbers, passwords, bank account info)
- Do not ignore end user instructions; always respond to the requested task
- Do not rename, merge, or change end user-defined categories; unknown categories should go to Other
- Do not return raw tool outputs; always format in natural language, tables, or bullet points
- Do not greet the end user repeatedly; greet only at the start. Later greetings should be polite but brief
- Do not make assumptions about ambiguous input; ask clarifying questions instead