Sub topic 10
Prompting reasoning models
This chapter assumes you have called an LLM API from Python, that you know what tokens and max output tokens are, and that you have written prompts for standard chat models. It also assumes you know that a reasoning model spends hidden reasoning tokens before it answers. Here you will learn how to change your prompts to fit that behavior.
Why prompts that worked before can hurt
Many prompting habits come from standard chat models. Those models often did better when you wrote "think step by step" or showed worked examples, because the visible answer was the only place where intermediate steps could happen.
A reasoning model already produces a chain of thought before it answers. That changes what the prompt needs to do:
- The model plans, checks and revises on its own. The prompt does not need to supply a procedure.
- The effort level or thinking budget controls how long the model thinks. The prompt should not try to control this.
- The prompt matters most for the things the model cannot work out alone: the goal, the constraints, the facts, and the format of the final answer.
A useful rule is to describe the destination and let the model choose the route. Hard-coded routes tend to be worse than what the model would have found, and they can constrain it.
Principles that hold up
State the goal and the success criteria
Say what a correct answer looks like. A reasoning model can check its own work against a criterion, but only if you give one.
Weak prompt:
Look at this schedule and tell me about problems.Stronger prompt:
Find every pair of meetings in the schedule below that overlap in time for the same person. List each conflict as "person: meeting A vs meeting B". If there are no conflicts, answer "none".The second prompt defines the task, the unit of output and the empty case. The model can verify its answer against that definition during reasoning.
Skip the step-by-step instruction
Compare these two prompts:
- "Think step by step, then list each step, then give the answer."
- "Give the answer."
The first adds instructions that the model's internal reasoning already covers. At best it adds output tokens you pay for. At worst it pushes the model to write a long visible explanation that does not match what it reasoned.
If you want an explanation in the answer, ask for one by its purpose and size: "Give the answer, then a two-sentence justification a customer could read." That is a request about the output. It is not a request to reveal the chain of thought.
Supply the facts the model needs
Reasoning does not create missing information. If the answer depends on a policy, a table or a date, include it in the prompt. A model that reasons for a long time about facts it lacks will often produce a confident, well-argued wrong answer.
Use delimiters to separate instructions from data
When the prompt contains documents, logs or user text, mark where each part starts and ends. Plain tags work well:
Task: classify the support ticket.
<ticket>
...ticket text here...
</ticket>
<categories>
billing, bug, feature_request, other
</categories>
Answer with exactly one category name.Delimiters also reduce the chance that text inside the data is read as an instruction. Treat any untrusted text this way.
Specify the output format exactly
The final answer is where format rules apply. Give the schema, the allowed values and what to do in edge cases. Fixing the format in the prompt also makes automatic checking easier, which matters in the evaluation chapter later in this tutorial.
Use few-shot examples sparingly
Examples are still useful for a format or style that is hard to describe. For reasoning problems, start with none. A set of worked examples can anchor the model to the method shown in them. If zero-shot results are weak, add one or two examples that show the format and the kind of input, and check whether accuracy actually improves.
Keep the prompt shorter and flatter
Long prompts with many nested rules give the model more to reconcile. Rules that contradict each other cost reasoning tokens and can lower quality. Remove rules you added to fix problems that older models had.
Where the instructions go
Both major APIs let you put standing instructions apart from the user task.
- In the OpenAI Responses API, the
instructionsparameter holds high-level guidance for the call. Reasoning models in the o-series also accept a developer message, which plays the role a system message plays for older chat models. - In the Anthropic Messages API, use the
systemparameter.
Put stable rules there (role, output format, policy) and put the specific task and data in the user message. This keeps the per-request prompt small and makes prompts easier to compare across effort settings.
The following program sends the same task with a prescriptive prompt and with a goal-oriented one, and prints the reasoning tokens used by each. It uses the OpenAI Responses API and needs an OPENAI_API_KEY in the environment.
from openai import OpenAI
client = OpenAI()
TASK_DATA = """Meetings:
- Ana: Standup 09:00-09:30
- Ana: Design review 09:15-10:00
- Ben: Planning 10:00-11:00
- Ben: Interview 11:00-11:30
"""
PRESCRIPTIVE = (
"Think step by step. First list every meeting, then compare every pair "
"one at a time, writing out your reasoning for each pair, then give the "
"final answer.\n\n" + TASK_DATA
)
GOAL_ORIENTED = (
"Find every pair of meetings that overlap in time for the same person. "
"Meetings that only touch at an endpoint do not overlap. "
"Answer with one line per conflict in the form "
"'person: meeting A vs meeting B', or the single word 'none'.\n\n"
+ TASK_DATA
)
def run(label, prompt):
response = client.responses.create(
model="o4-mini",
reasoning={"effort": "low"},
input=prompt,
)
details = response.usage.output_tokens_details
print(f"--- {label} ---")
print(response.output_text)
print("reasoning tokens:", details.reasoning_tokens)
print("total output tokens:", response.usage.output_tokens)
run("prescriptive", PRESCRIPTIVE)
run("goal oriented", GOAL_ORIENTED)Expect the goal-oriented prompt to produce a shorter visible answer. Reasoning-token counts vary between runs, so do not decide from one call. The next chapters show how to measure a difference properly.
The goal-oriented prompt also states the boundary case about endpoints. Ben's Planning ends at 11:00 and his Interview starts at 11:00, so a model without that rule has to guess. Edge-case rules like this one are the kind of detail a prompt should supply.
Deciding what to change in a prompt
The key branch is the third one. When quality is limited by depth of thought, the control is the effort setting or budget, not extra wording.
Multi-turn conversations and tool use
Prompting also involves how you carry state between calls.
- With the OpenAI Responses API, reasoning items are part of the response. In multi-step flows with tool calls, you can chain calls using
previous_response_id, so the platform can reuse the earlier reasoning context. Check the current documentation for how your model handles it. - With Anthropic extended thinking, a turn that ends in a tool call returns thinking blocks. When you send the tool result back, you must include the thinking block from that assistant turn unchanged. Dropping or editing it can cause an error or lose the earlier reasoning.
In ordinary chat history, you do not need to paste the earlier reasoning into later user messages. Keep the visible answers and the facts that later turns need.
Common mistakes
| Mistake | Effect | Fix |
|---|---|---|
| Adding "think step by step" by habit | More output tokens and a possible style mismatch, with little gain | Remove it. Raise effort if depth is the problem. |
| Dictating a full procedure | The model follows your method even if a better one exists | State the goal and the checks instead. |
| Leaving out edge-case rules | The model guesses, and guesses vary between runs | Write the rule into the prompt. |
| Asking the model to print its raw reasoning | Unreliable. Providers may summarize or hide it | Ask for a short justification as part of the answer. |
| Mixing data and instructions | Instructions inside data get followed | Wrap the data in delimiters. |
| Reusing a long prompt tuned for an older model | Contradictory or stale rules | Rebuild from the goal and test. |
| Tuning wording on a single sample | You chase noise | Run a set of cases and compare scores. |
A short workflow for prompt changes
- Write the shortest prompt that states the goal, the facts and the output format.
- Run it on a small set of real cases at a fixed effort level.
- Read the failures. Classify each as missing facts, wrong format, ambiguous rule or insufficient depth.
- Fix the cause in the prompt for the first three. For the fourth, change the effort or budget.
- Re-run the same cases and compare. Keep a change only if the measured result improves.
The same cases and the same scoring must be used before and after a change. Otherwise you cannot tell a prompt effect from sampling variation.
Exercise
A teammate's prompt for a reasoning model reads: "Think step by step, show all your work, then decide whether the invoice should be approved." Rewrite it in two or three sentences using the principles from this chapter, and name two things you added or changed. Assume invoices are approved if the total is under 1,000 and the vendor is on the approved list.
Show answer
Example rewrite: "Decide whether the invoice should be approved. Approve it only if the total is under 1,000 and the vendor appears in <vendors>; otherwise reject it. Answer with 'approve' or 'reject' followed by a one-sentence reason. <invoice>...</invoice> <vendors>...</vendors>". Changes: the step-by-step instruction was removed because the model already reasons internally, and the approval rule, the vendor list, the output format and delimiters around the data were added. Any answer that states the goal, supplies the rules and facts, fixes the format and drops the procedure is correct.
Exercise
A reasoning model gives shallow, wrong answers on a hard scheduling problem, even though your prompt states the goal, the facts and the format clearly. Which control should you try first, and why is adding more instructions unlikely to be the best first move?
Show answer
Raise the effort level or thinking budget. The prompt already supplies the goal, facts and format, so the limit is depth of thought, which the effort setting controls. More instructions would add length and possible contradictions without giving the model more thinking time.