Advanced Prompt Frameworks for Logic and Reasoning: CoT, ToT, and ReAct Explained
Chain-of-Thought, Tree-of-Thoughts, and ReAct compared, with templates for math, coding, and multi-step logic tasks.
Chain-of-Thought, Tree-of-Thoughts, and ReAct compared, with templates for math, coding, and multi-step logic tasks.
Most people treat prompting like ordering food: state what you want, wait for the output, adjust if it's wrong. That works fine for simple tasks like rewriting an email or summarizing a paragraph. But once you ask a model to solve a multi-step math problem, debug a piece of code, or plan a sequence of actions, a single-shot instruction often produces a confident, fluent, and completely wrong answer.
The problem isn't that the model "doesn't know" the answer. It's that you never asked it to think. Modern language models generate text token by token, and if you demand the final answer immediately, the model has no room to work through intermediate steps. It jumps straight to a guess dressed up as certainty.
This is where reasoning frameworks come in. Chain-of-Thought (CoT), Tree-of-Thoughts (ToT), and ReAct aren't just prompting tricks. They're structured ways of shaping the model's internal process, forcing it to reason step by step, explore multiple paths, or interleave thinking with real-world actions. Understanding when and how to use each one is one of the highest-leverage skills you can build if you rely on AI for anything involving logic, math, coding, or planning.
These frameworks originated from academic research papers (CoT from Google Research, ToT from Princeton and Google DeepMind, ReAct from Princeton and Google) but they translate directly into everyday prompts you can write today, no fine-tuning or special tools required.
Left to its own devices, a language model tends to produce the most statistically likely next token given everything before it. For a factual recall question, that's often fine. For a reasoning task, it means the model may skip straight to a plausible-sounding conclusion without actually verifying whether that conclusion follows logically from the premises.
Consider a simple example:
A store had 23 apples. They sold 15 and then received a new shipment of 40. How many apples do they have now?
A model rushing to an answer might miscalculate or apply the wrong operation order, especially as problems get longer or involve more steps. But if you ask the model to work through the problem step by step before answering, accuracy improves dramatically. That single instruction, "think step by step," is the seed of everything covered in this article.
Chain-of-Thought prompting asks the model to externalize its reasoning process before producing a final answer. Instead of jumping to a conclusion, the model writes out the intermediate steps, much like a student showing their work on a math test.
When a model generates reasoning tokens before the answer, those tokens become part of the context that informs the final answer. Each step conditions the next, so errors are less likely to compound silently. It also gives you, the user, visibility into how the model arrived at its answer, which makes mistakes easier to spot and correct.
CoT is most effective for:
You are solving a {{problem_type}} problem.
Problem:
{{problem_statement}}
Think through this step by step. Break the problem into smaller parts, solve each part, and show your reasoning before giving the final answer. Do not skip steps.
Final answer format: {{answer_format}}
You are solving a math word problem problem.
Problem:
A warehouse has 340 boxes. Every day, 28 boxes are shipped out and 15 new boxes arrive. After how many full days will the warehouse have fewer than 100 boxes?
Think through this step by step. Break the problem into smaller parts, solve each part, and show your reasoning before giving the final answer. Do not skip steps.
Final answer format: State the number of days and the exact box count on that day.
If the model's reasoning is correct but the final answer is wrong, that's usually a formatting or arithmetic slip, not a logic failure. Ask it to double-check the last step specifically instead of re-running the whole chain.
Chain-of-Thought is linear: one reasoning path from start to finish. But many real problems don't have a single obvious path. Sometimes the first approach you try is a dead end, and you need to backtrack and try something else. That's exactly what humans do when solving a tricky puzzle, and it's what Tree-of-Thoughts asks the model to simulate.
In a ToT prompt, you instruct the model to:
ToT shines in problems where the first reasonable-looking step can lead you astray, and where there is real value in comparing alternatives before committing. Good candidates include:
For a task like "what's 15 + 27," ToT is overkill and just wastes tokens. Save it for genuinely branching problems.
You are solving a {{problem_type}} problem that may have multiple possible approaches.
Problem:
{{problem_statement}}
Follow this process:
1. Propose {{number_of_branches}} distinct approaches or first steps.
2. For each approach, briefly evaluate its likelihood of success and any risks.
3. Select the most promising approach and continue reasoning through it in detail.
4. If you hit a dead end, explicitly backtrack and try the next best approach.
5. State your final answer only after you are confident in the reasoning path.
You are solving a logic puzzle problem that may have multiple possible approaches.
Problem:
Four friends, Ana, Ben, Cara, and Dan, each ordered a different drink: coffee, tea, juice, and water. Ana does not drink coffee or tea. Ben sits next to whoever drinks tea. Cara drinks juice. Dan does not drink water. Who drinks what?
Follow this process:
1. Propose 3 distinct approaches or first steps.
2. For each approach, briefly evaluate its likelihood of success and any risks.
3. Select the most promising approach and continue reasoning through it in detail.
4. If you hit a dead end, explicitly backtrack and try the next best approach.
5. State your final answer only after you are confident in the reasoning path.
ToT prompts consume more tokens than CoT because the model is generating and evaluating multiple branches. Reserve it for problems where a wrong first guess is costly to correct later.
CoT and ToT both operate purely inside the model's "head." ReAct (Reasoning and Acting) adds a crucial third ingredient: the ability to interact with the outside world between reasoning steps. Instead of reasoning all the way to a final answer in one pass, the model alternates between three moves:
This loop repeats until the model has enough information to produce a final answer. ReAct is the backbone of most modern AI agents, because it's how a model can look things up, verify facts, run calculations, or interact with an API rather than relying solely on what it already "knows."
Pure reasoning frameworks like CoT and ToT are only as good as the model's internal knowledge. If a math problem requires an exact numeric computation, a language model reasoning purely in text can still make arithmetic errors. If a coding task requires knowing whether a function actually runs without errors, the model can't know that just by thinking harder. ReAct solves this by letting the model reason about what it needs, fetch or compute that information through an action, and then continue reasoning with verified data instead of a guess.
You are solving a {{task_type}} task. You have access to the following actions: {{available_actions}}.
Task:
{{task_description}}
Use this loop until you reach a final answer:
Thought: reason about what you know and what you need next.
Action: choose one action and specify its input.
Observation: [this will be provided after the action runs]
Repeat as needed. When you have enough information, respond with:
Final Answer: {{final_answer_format}}
You are solving a data verification task task. You have access to the following actions: run_python_code, search_documentation.
Task:
Confirm whether the following Python function correctly returns the second largest unique number in a list, and fix it if it doesn't: def second_largest(nums): return sorted(set(nums))[-2]
Use this loop until you reach a final answer:
Thought: reason about what you know and what you need next.
Action: choose one action and specify its input.
Observation: [this will be provided after the action runs]
Repeat as needed. When you have enough information, respond with:
Final Answer: State whether the function is correct, and provide a corrected version if needed.
ReAct works best when you actually give the model real tools to call, such as a code execution environment or a search function. Without real tools, the "Action" step becomes just another reasoning step, which reduces ReAct to a more verbose version of CoT.
| Framework | Structure | Best for | Token cost | Requires tools |
|---|---|---|---|---|
| Chain-of-Thought (CoT) | Single linear reasoning path | Arithmetic, straightforward logic, step-by-step explanations | Low to moderate | No |
| Tree-of-Thoughts (ToT) | Multiple branches evaluated and pruned | Puzzles, planning with several viable options, ambiguous problems | Moderate to high | No |
| ReAct | Alternating reasoning and real-world actions | Tasks needing external facts, code execution, or verification | Moderate to high | Yes |
These frameworks aren't mutually exclusive. A ReAct loop often contains Chain-of-Thought reasoning inside each "Thought" step, and a Tree-of-Thoughts process can call ReAct-style actions to verify which branch is actually correct. Think of them as building blocks rather than competing methods.
Rather than memorizing rules, it helps to ask three questions before you prompt.
Does this problem have one clear path, or several plausible ones? If there's a single logical sequence of steps, like solving an equation or explaining a process, Chain-of-Thought is usually enough. If there are multiple reasonable first moves and picking the wrong one leads to a dead end, lean toward Tree-of-Thoughts.
Does the model need information it doesn't already have? If the task depends on current data, exact computation, or verification against a real system such as running code or checking documentation, ReAct is necessary. Reasoning alone cannot substitute for actually checking.
How much does a wrong answer cost you? For low-stakes tasks, a simple CoT prompt is usually fast and good enough. For high-stakes tasks, such as a financial calculation, production code, or a decision that's expensive to reverse, it's worth paying the extra token cost of Tree-of-Thoughts or a ReAct loop with verification steps.
When in doubt, start with plain Chain-of-Thought. It's cheap, fast, and solves the majority of reasoning failures caused by the model rushing to an answer. Only escalate to ToT or ReAct when you notice the model consistently picking a plausible-but-wrong first step, or when the task genuinely requires outside information.
In real workflows, these techniques often stack. A common and effective pattern for complex coding or analysis tasks looks like this:
You don't need to name these frameworks explicitly in your prompt for them to work, but being explicit does help, especially with less capable models. Naming the structure you want ("propose three approaches," "alternate between thought and action," "show your reasoning before answering") gives the model an unambiguous scaffold to follow instead of leaving the structure implicit and hoping it infers your intent.

Asking for reasoning but not reading it. If you ask a model to think step by step and then only glance at the final answer, you're missing the main benefit. The reasoning trace is where errors surface. Read it, especially on important tasks.
Overusing Tree-of-Thoughts for simple problems. Branching adds latency and cost. If a task doesn't have genuine forks in the road, ToT just adds noise.
Using ReAct without real actions. If you describe an "Action" step but the model can't actually execute it (no code runner, no search tool, no API), you're not really doing ReAct. You're doing CoT with extra formatting.
Not constraining the output format. Reasoning frameworks tend to produce longer outputs. If you need a clean final answer for downstream use (a JSON object, a single number, a short recommendation), always specify the exact format you want at the end of the prompt, separate from the reasoning section.
Assuming more reasoning always means more accuracy. Beyond a certain point, additional reasoning steps can introduce their own errors or drift off topic. Keep the scope tight and specific to the problem at hand.
Before you write your next reasoning-heavy prompt, run through this short list:
Getting comfortable with these three frameworks won't make a model infallible, but it will dramatically reduce the kind of confident, subtly wrong answers that plague single-shot prompting. The goal isn't to make your prompts longer for the sake of it. It's to give the model the same structure a careful human problem-solver would use: think before answering, consider more than one path when it matters, and check your work against reality when reasoning alone isn't enough.
You don't strictly need those exact labels, but using clear, consistent markers helps the model separate its reasoning from its actions and makes the output easier to parse, especially if you're building this into an automated workflow rather than a one-off chat.
Yes, for simple factual or single-step questions, CoT adds unnecessary length without meaningfully improving the answer. It's most valuable on problems with several dependent steps, where skipping the reasoning genuinely increases the risk of error.
Not quite. ToT specifically asks the model to branch, evaluate, and prune paths during the reasoning process itself, including backtracking from dead ends. Simply generating several final answers and comparing them afterward is a related but less structured technique.
The underlying principles apply broadly, but effectiveness varies by model. Larger and more capable models tend to follow structured reasoning instructions more reliably, while smaller models may need more explicit, few-shot examples to produce consistent step-by-step reasoning.
It depends on the use case. For internal debugging, audits, or tasks where trust matters, showing the reasoning trace is valuable. For consumer-facing products, you often want to run the reasoning framework internally and present only a clean, formatted final answer to avoid overwhelming the user.

Best Prompt Frameworks for AI in 2026 (With Templates & Examples)

Everyday Prompt Frameworks: RTF, RACE, and CRAFT Explained

Example-Based Prompting: Zero-Shot, One-Shot, and Few-Shot Explained

Prompt vs Skill: Key Differences Every AI User Must Know

Beyond the Vibe Check: How to Measure AI Prompt ROI