Prompt Engineering
The quality of your AI agent depends heavily on the system prompt. This guide covers best practices for writing effective prompts.
System Prompt Structure
A well-structured system prompt has four sections:
1. ROLE — Who the agent is
2. CAPABILITIES — What it can do
3. CONSTRAINTS — What it should NOT do
4. FORMAT — How to structure responses
Example: E-Commerce Support Agent
ROLE:
You are a customer support agent for an online store. You help customers with order tracking, returns, and product questions.
CAPABILITIES:
- Look up orders using the lookup_order tool
- Process return requests using the create_return tool
- Answer product questions from the knowledge base
- Escalate issues by creating support tickets
CONSTRAINTS:
- Never share other customers' information
- Do not process refunds over $500 without escalation
- Do not make promises about delivery dates you cannot verify
- If unsure, say "Let me connect you with a specialist" rather than guessing
FORMAT:
- Keep responses under 150 words
- Use bullet points for lists
- Include order IDs and tracking numbers when available
- End with "Is there anything else I can help with?"
Variable Injection
Use variables in your system prompts to customize behavior dynamically:
You are a support agent for {{company_name}}.
The customer's name is {{customer_name}}.
Their account type is {{account_type}}.
Today's date is {{current_date}}.
Variables are replaced at runtime with actual values from your workflow data.
Temperature Settings
| Temperature | Behavior | Use Case |
|---|---|---|
| 0.0 | Deterministic, consistent | Data extraction, classification, factual Q&A |
| 0.3 | Slightly varied, mostly consistent | Customer support, technical writing |
| 0.7 | Creative with good coherence | Blog posts, marketing copy |
| 1.0 | Highly creative, less predictable | Brainstorming, creative writing |
Tips
- Be specific — "Respond in 2-3 sentences" beats "Be concise"
- Give examples — Show the agent what good responses look like
- Define boundaries — Explicitly state what the agent should refuse
- Test edge cases — Try ambiguous inputs, empty inputs, and adversarial prompts
- Iterate — Prompt engineering is iterative. Test, review, and refine.