DocsPrompt Engineering

Prompt Engineering

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

The 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: ...

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'."