DocsOverview

Prompt Engineering

BEST_PRACTICES

Techniques to get the most reliable, accurate, and safe outputs from your agents.

Anatomy of a Good Prompt#

A System Prompt isn't just a persona. It's the "Operating System" for your agent. It should define constraints, output formats, and fallback behaviors.

# 1. Identity You are a Senior Data Analyst for AKIOS Financial. # 2. Capabilities You can query the SQL database using the 'sql_tool'. You can visualize data using the 'chart_tool'. # 3. Constraints (CRITICAL) - NEVER modify data, only read. - If the user asks for personal data, refuse politely. - Always output markdown tables for data. # 4. Tone Professional, concise, objective.

Advanced Techniques#

Chain Of Thought (CoT)

Encourage the model to "think" before answering. This significantly improves reasoning on math and logic tasks.

prompt.txt
Bad: "What is 15% of 850?"

Good: "Calculate 15% of 850. Think step-by-step."

Few Shot Prompting

Give examples of input/output pairs. This is the single most effective way to fix formatting errors.

prompt.txt
Extract the entities from this text.

Example 1:
Input: "Apple released the iPhone 15 in Cupertino."
Output: { "org": "Apple", "product": "iPhone 15", "loc": "Cupertino" }

Example 2:
Input: "Tesla built a factory in Berlin."
Output: { "org": "Tesla", "product": "factory", "loc": "Berlin" }

Current Task:
Input: ...

Tool Specific Instructions

Give the model specific guidance on when and how to use each tool. Include parameter descriptions and usage examples.

prompt.txt
Available Tools:
- calculator: For mathematical computations. Input: {expression: "string"}. Examples: "2+2", "sqrt(16)", "15% of 850"
- search_web: For current information. Input: {query: "string"}. Use for recent events, prices, or time-sensitive data.
- read_file: For accessing local files. Input: {path: "string"}. Only use when explicitly asked for file contents.

Tool Usage Guidelines:
1. Use calculator for any math, even simple arithmetic
2. Use search_web for questions about current events or data that changes
3. Never guess - if you don't know something, use a tool to find out
4. Explain your tool usage: "I'll calculate that using the calculator tool"

Output Format Specification

Define exact output formats, especially for structured data. Use JSON Schema or clear formatting rules.

prompt.txt
Always respond with valid JSON in this exact format:
{
  "answer": "string - the final answer",
  "confidence": "high|medium|low",
  "sources": ["array of sources used"],
  "next_steps": ["array of recommended actions, if any"]
}

Example Response:
{
  "answer": "The meeting is scheduled for 3 PM EST",
  "confidence": "high", 
  "sources": ["calendar API", "user confirmation"],
  "next_steps": ["Send calendar invite", "Prepare agenda"]
}

Error HAndling Instructions

Teach the model how to handle errors gracefully and when to ask for clarification.

prompt.txt
Error Handling:
- If a tool fails, explain what went wrong and suggest alternatives
- If user input is unclear, ask specific clarifying questions
- If you cannot complete a task, explain why and what information you need
- Never make up information or pretend to know something you don't

Examples:
Bad: "I don't know"
Good: "I need more context. Are you asking about the weather in Tokyo today, or historical weather patterns?"

SAFETY_&_GUARDRAILS_INTEGRATION#

Integrate safety instructions directly into your prompts to work with AKIOS guardrails.

PII Redaction Awareness

prompt.txt
Privacy Protection:
- Never output personal information like names, emails, phone numbers, or addresses
- If user provides sensitive data, acknowledge receipt but do not repeat it
- Use placeholders like "[REDACTED]" for sensitive information in responses
- Inform users that their data is protected and not stored permanently

Content Safety Guidelines

prompt.txt
Content Guidelines:
- Do not generate harmful, offensive, or inappropriate content
- Refuse requests that violate ethical standards
- If asked for dangerous information, provide educational warnings
- Redirect inappropriate requests to safe alternatives

Refusal Examples:
- "I cannot assist with that request as it violates safety guidelines"
- "That topic involves harmful content. Can I help you with something else?"

Multi Step Reasoning Patterns#

For complex tasks, break down the reasoning process into clear steps.

Research Then Answer Pattern

prompt.txt
For research questions:
1. Identify what information you need
2. Use appropriate tools to gather data
3. Analyze and synthesize the information
4. Provide a clear, structured answer
5. Cite your sources

Example: "To answer your question about climate change impacts, I'll:
1. Search for recent scientific studies
2. Check government reports
3. Analyze the data trends
4. Provide evidence-based conclusions"

Verification Pattern

prompt.txt
Always verify critical information:
- Cross-reference multiple sources
- Check dates and context
- Look for conflicting information
- Provide confidence levels

Verification Steps:
1. Gather information from primary sources
2. Cross-check with secondary sources  
3. Identify any discrepancies
4. Note confidence level in response

Model Specific Optimizations#

GPT 4 / GPT 4 Turbo

  • • Excellent at complex reasoning
  • • Handles long contexts well
  • • Good at following detailed instructions
  • • Use for analytical and creative tasks

Claude / Claude Instant

  • • Strong at safety and ethics
  • • Good at following guardrails
  • • Excellent at structured output
  • • Use for safe, compliant applications

Gemini / Palm

  • • Fast and cost-effective
  • • Good at conversational tasks
  • • Strong multimodal capabilities
  • • Use for simple automation

LOCAL_MODELS_(LLAMA,_MISTRAL)

  • • Privacy-focused (no API calls)
  • • Customizable and fine-tunable
  • • May need more specific prompts
  • • Use for offline, secure applications

Handling Hallucinations#

THE_'I_DON'T_KNOW'_RULE

Explicitly instruct the model to admit ignorance.

Add this to your System Prompt to reduce made-up facts:

"Answer ONLY based on the context provided. If the answer is not in the context, say 'I do not have enough information to answer that'."