Sub topic 3
Prompting Reasoning Models
Assume you can call an LLM API, understand tokens and output limits, and read basic Python. This chapter focuses on prompt design, effort selection, and measurement.
Prompting reasoning models
A reasoning model uses extra inference-time compute to work through a difficult task before producing its answer. Give it the goal, constraints, relevant data, and required output format. Avoid asking it to “think step by step” or to reveal private chain-of-thought. Instead, request a concise explanation, checks, or a list of assumptions.
For example:
response = client.responses.create(
model="o4-mini",
reasoning={"effort": "medium"},
input=(
"Review this SQL migration. Identify correctness risks and propose "
"a safer revision. Return: risks, revised SQL, and assumptions."
),
)A clear task lets the model spend its reasoning on the problem rather than interpreting vague instructions.
Choosing when to reason and how much
Use low effort for extraction, rewriting, classification, and familiar transformations. Use higher effort for multi-step calculations, code debugging, planning, ambiguous requirements, and tasks where an incorrect answer is expensive.
| Task type | Starting choice | Why |
|---|---|---|
| Format or summarize text | Low | Few dependent steps |
| Debug unfamiliar code | Medium | Requires tracing causes |
| Design a migration plan | High | Many constraints and failure modes |
Treat effort as a tunable parameter, not a quality guarantee. Higher effort usually increases latency and reasoning-token usage. It can also reduce the tokens available for the final output when both share a limit.
Overthinking and diminishing returns
More reasoning does not always improve an answer. A model may spend extra compute exploring irrelevant possibilities, repeat checks, or produce a less direct response. This is overthinking. Keep the prompt focused, define a stopping condition, and require only the output your application needs.
Measure effort on your task
Build a small test set of representative prompts with expected properties or answers. Run every case at each effort level, then compare accuracy, latency, and cost.
import time
def compare_efforts(ask, cases, efforts=("low", "medium", "high")):
results = {}
for effort in efforts:
correct = 0
start = time.perf_counter()
for prompt, expected in cases:
answer = ask(prompt, effort)
if expected.lower() in answer.lower():
correct += 1
results[effort] = {
"accuracy": correct / len(cases),
"seconds_per_case": (time.perf_counter() - start) / len(cases),
}
return resultsUse provider usage fields to inspect reasoning-token counts when they are available. Choose the lowest setting that passes your quality threshold.
Exercise
Why should a prompt request checks or assumptions instead of asking for hidden chain-of-thought?
Show answer
Checks and assumptions improve verifiability without requiring the model to expose private internal reasoning.