File size: 3,054 Bytes
116524e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Prompt Engineering

ACE uses specialized prompt templates for each role. The framework includes multiple prompt versions with different trade-offs.

## Default Prompts

`ace` ships with v2.1 prompts built in. All three roles (`Agent`, `Reflector`, `SkillManager`) use them by default — no extra imports needed.

!!! tip "Recommendation"
    The built-in v2.1 prompts work well out of the box. Only provide custom prompts when you need domain-specific instructions.


## Overriding Prompts

Pass a `prompt_template` string to any role constructor:

```python

from ace import Agent, Reflector, SkillManager



agent = Agent("gpt-4o-mini", prompt_template="Your custom agent prompt ...")

reflector = Reflector("gpt-4o-mini", prompt_template="Your custom reflector prompt ...")

skill_manager = SkillManager("gpt-4o-mini", prompt_template="Your custom skill manager prompt ...")

```

## Template Variables

### Agent Prompt

| Variable | Description |
|----------|-------------|
| `{skillbook}` | Current skillbook in markdown format |
| `{question}` | The input question |
| `{context}` | Additional context |
| `{reflection}` | Optional reflection from a previous attempt |

### Reflector Prompt

| Variable | Description |
|----------|-------------|
| `{skillbook}` | Current skillbook in markdown format |
| `{question}` | The original question |
| `{agent_output}` | The agent's response |
| `{ground_truth}` | Expected answer |
| `{feedback}` | Environment feedback |

### SkillManager Prompt

| Variable | Description |
|----------|-------------|
| `{skillbook}` | Current skillbook in markdown format |
| `{reflection}` | Reflector's analysis |
| `{question_context}` | Description of the task domain |
| `{progress}` | Current training progress |

## Custom Prompts

You can provide your own prompt templates. They must include the required template variables:

```python

custom_agent_prompt = """

Skillbook: {skillbook}

Question: {question}

Context: {context}



Generate a JSON response with:

- reasoning: Your step-by-step thought process

- skill_ids: List of skillbook IDs you used

- final_answer: Your answer

"""



agent = Agent(llm, prompt_template=custom_agent_prompt)

```

## Formatting Skillbook for External Agents

Integration runners inject the skillbook into external agent prompts using a wrapper function:

```python

from ace import wrap_skillbook_context



context = wrap_skillbook_context(skillbook)

# Returns formatted strategies with usage instructions

```

## Troubleshooting

| Problem | Solution |
|---------|----------|
| JSON parse failures | Increase `max_tokens`, use Instructor, or try v2.1 prompts |
| Empty skill_ids | Agent not citing skills — check skillbook has content |

| Poor answer quality | Switch to v2.1 prompts or try a larger model |



## What to Read Next



- [Full Pipeline Guide](full-pipeline.md) — use prompts in a complete pipeline

- [The Skillbook](../concepts/skillbook.md) — what goes into `{skillbook}`