Introduction to Reasoning › How to Prompt for Reasoning
Michael BrenndoerferJune 21, 20252 min read
AI Agent HandbookAll chapters Part 4 of 15Reasoning - Teaching the Agent to Think
Introduction to Reasoning › How to Prompt for ReasoningOne section · Sections in this chapter4 / 14 ↓
Sections in this chapter14
The good news is that prompting for reasoning is straightforward. You don't need special tools or complex setups. You just need to ask the model to think step by step.
Here are several ways to do this:
Direct Instruction
The simplest approach is to explicitly ask for step-by-step thinking:
Question: [Your question here]
Let's solve this step by step.Or:
Question: [Your question here]
Think through this carefully, showing your reasoning at each step.These phrases signal to the model that you want a methodical approach rather than a quick answer.
Example (GPT-5)
Let's see this in action with a math word problem:
In[2]:
Codefrom openai import OpenAI
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
## Without reasoning prompt
response_direct = client.chat.completions.create(
model="gpt-5",
messages=[
{
"role": "user",
"content": "If a train travels 60 miles in 45 minutes, how far will it travel in 2 hours at the same speed?",
}
],
)
## With reasoning prompt
response_reasoning = client.chat.completions.create(
model="gpt-5",
messages=[
{
"role": "user",
"content": """If a train travels 60 miles in 45 minutes, how far will it travel in 2 hours at the same speed?
Let's work through this step by step.""",
}
],
)
print("Direct answer:", response_direct.choices[0].message.content)
print("\nWith reasoning:", response_reasoning.choices[0].message.content)The direct version might give you the answer (160 miles) without explanation. The reasoning version will show the work:
Let's work through this step by step:
1. First, find the train's speed in miles per hour
- The train travels 60 miles in 45 minutes
- 45 minutes = 0.75 hours
- Speed = 60 miles $\div$ 0.75 hours = 80 miles per hour
2. Now calculate the distance for 2 hours
- Distance = Speed $\times$ Time
- Distance = 80 miles/hour $\times$ 2 hours = 160 miles
The train will travel 160 miles in 2 hours.Both answers are correct, but the reasoning version shows you how the agent arrived at the answer. This transparency builds trust and makes it easier to spot errors if they occur.