---
sidebar_position: 7
question: Which prompting patterns belong in a system prompt?
kind: guide
---

# System prompt techniques

Three ways to structure a prompt, and how an ABI agent's prompt uses the last one.

## Chain of Thought (CoT)

Chain of Thought prompting encourages the model to break down complex problems into step-by-step reasoning, making the thought process explicit and transparent.

**Structure:**
- Present the problem
- Request step-by-step thinking
- Ask for explicit reasoning at each step
- Conclude with the final answer

**Example:**
```text
Problem: A store sells apples for $2 per pound and oranges for $3 per pound. If I buy 4 pounds of apples and 2 pounds of oranges, how much do I spend in total?

Let me think through this step by step:
1. First, I'll calculate the cost of apples: 4 pounds × $2/pound = $8
2. Next, I'll calculate the cost of oranges: 2 pounds × $3/pound = $6
3. Finally, I'll add both costs together: $8 + $6 = $14

Therefore, the total cost is $14.
```

**When to use:**
- Complex mathematical problems
- Multi-step reasoning tasks
- Debugging logical errors
- Planning and decision-making scenarios

## Few-Shot Learning

Few-Shot Learning provides the model with a few examples of the desired input-output pattern before presenting the actual task, helping establish the expected format and style.

**Structure:**
- Provide 2-5 examples of input-output pairs
- Maintain consistent formatting across examples
- Present the actual task using the same format
- Let the model infer the pattern

**Example:**
```text
Task: Convert these sentences to a more professional tone.

Example 1:
Input: "Hey, can you get back to me ASAP about this?"
Output: "I would appreciate your prompt response regarding this matter."

Example 2:
Input: "This is totally wrong and needs to be fixed right now."
Output: "There appears to be an error that requires immediate attention."

Example 3:
Input: "Thanks a bunch for helping me out with this stuff."
Output: "Thank you for your assistance with these matters."

Now convert this sentence:
Input: "Can you double-check this thing before we send it out?"
Output: "Could you please review this document before distribution?"
```

**When to use:**
- Establishing specific output formats
- Teaching new writing styles or tones
- Pattern recognition tasks
- Classification problems
- When you need consistent formatting across responses

## ROC-T-TOC

**Structure:**
- Role: Define who the agent is, their function and expertise (Example: 'Email summarizer assistant')
- Objective: Clearly state the overall objective or goal to achieve/solve. Acts as the guiding star for all tasks
- Context: Provide additional context and relevant background information
- Tools: List available tools with their expected inputs and outputs
- Tasks: Lay out clear step-by-step tasks the agent will execute
- Operating Guidelines: Specify how the agent should execute each task. Include which tools to use. Define how to interact with users. Outline process steps
- Constraints: Define rules. Specify expected formats. Outline off-topic areas

## In an ABI agent

The prompt that `abi new agent` scaffolds follows this structure, with one XML-style tag per part: `<role>`, `<objective>` and `<constraints>`. Add `<context>`, `<tools>`, `<tasks>` and `<operating_guidelines>` when the agent needs them:

```python title="agents/ReviewerAgent.py"
SYSTEM_PROMPT = """<role>
You are Reviewer, a careful reviewer.
</role>

<objective>
Help the user review their documents.
</objective>

<operating_guidelines>
- Use review_document to read a document before you comment on it.
</operating_guidelines>

<constraints>
- Answer briefly and factually.
- Say so when you do not know.
</constraints>
"""
```

The model gets each tool's name and description with the request, so the prompt does not need to list them. Tool descriptions are part of the prompt: the model chooses a tool from its name and description, so write them as the question or action they answer. Where to change a prompt is [Edit prompt & model](/capabilities/build/agents/edit-prompt-and-model).
