ReAct = Reason + Act: the agent thinks, calls a tool, reads the result, thinks again. Turn on the model's reasoning so it plans between tool calls instead of guessing.
Why: ReAct is the loop you already built, with explicit reasoning between steps so the model decides its next action from what it just observed. When: it shines on multi-step tasks where each tool result changes the plan. Where: your loop already does the act/observe — this lesson adds the reason.
Thought: I need yesterday's sales before I can compare.
Action: get_sales(date="yesterday")
Observation: $12,400
Thought: Now I need last Tuesday's to compare.
Action: get_sales(date="2026-06-23")
Observation: $9,800
Thought: Up 27%. I can answer now.
Answer: Sales rose 27% versus last Tuesday.Why: adaptive thinking lets the model reason before and between actions, which sharply improves multi-step tool use. When: enable it for agents that chain tools or plan. Where: keep appending the full response.content each turn — the thinking blocks must travel back with the conversation.
response = client.messages.create(
model="claude-opus-4-8",
max_tokens=2048,
thinking={"type": "adaptive"}, # the model reasons between tool calls
tools=tools,
messages=messages,
)
# response.content may now include "thinking" blocks before the tool_use.
# Your text_of() helper already skips them; appending the whole
# response.content (as the loop does) carries them back correctly.Why: a short system prompt tells the model to gather facts with tools before answering, instead of guessing from memory. When: add it whenever the agent answers from prior knowledge when it should be checking. Where: the system prompt sets standing behaviour for the whole run.
SYSTEM = (
"You are a research agent. Use the provided tools to gather facts "
"before answering. Do not guess values you can look up. When you "
"have enough information, give a concise final answer."
)
response = client.messages.create(
model="claude-opus-4-8",
max_tokens=2048,
system=SYSTEM,
thinking={"type": "adaptive"},
tools=tools,
messages=[{"role": "user", "content": "How did sales change week over week?"}],
)