AlgoViz

Reasoning, acting and critique

medium 6 min

Search, critique and tool-grounded action produce different artifacts.

Video lesson · Chapter 1 of 4

The train that arrives too late

0:00 / 3:18

Theory

Read or listen first. About 2 min.

What it is

Search, critique and tool-grounded action produce different artifacts. Search supplies alternatives, critique proposes weaknesses and a tool supplies observations about the environment. Independent checks decide which candidates actually satisfy the goal.

Why it exists

Keep observable actions, constraints and source evidence in the trace. These artifacts are useful for debugging even when a model offers no faithful account of its internal reasoning.

One tool observation changes the plan

Candidate route → Timetable (request schedule). Timetable → Verified choice (deliver observation). Verified choice → Candidate route (test alternative)
Candidate route → Timetable (request schedule). Timetable → Verified choice (deliver observation). Verified choice → Candidate route (test alternative)

Inside this chapter

Chapter sources
Types of Reasoning in Agents
Decomposition, analogy, search and verification serve different reasoning tasks. A numerical question benefits from a checked calculation; an ambiguous request may need clarification. Evaluate an observable decision or artifact rather than assuming that a longer explanation reflects a better reasoning process.

Different sub-problems in one run need different kinds of support. A rule question is settled by the rules and the facts, a number by a calculation, an ambiguity by asking. Judge each by the artifact it produces (the rule cited, the computed figure, the user's answer) rather than by how long or fluent the explanation is.

Example. Deduce eligibility from explicit rules, then check a numeric amount with a calculator. These tasks require different evidence even within the same run.

Match the reasoning to its evidence

  • Deduction

    Eligible for a refund? Apply the written rules to the order facts.

  • Calculation

    Refund amount: compute with a calculator tool, not in prose.

  • Clarification

    "Cancel it" with two open orders: ask which one.

  • Search

    Several routes possible: generate and compare candidates.

  • Verification

    Check the chosen answer against the constraint and source.

Chain-of-Thought (CoT)
Decomposing a decision into checkable steps can expose a unit mistake or a missing constraint. Ask for assumptions, supporting evidence and a verifiable result. A generated narrative is not a faithful audit of internal model computation and should not be treated as one.

Asking for intermediate steps helps when each step is something you can check: a stated assumption, a cited value, a unit. It is not a faithful window into how the model computed its answer, so do not treat the written chain as an audit log. Use it to surface claims, then verify the claims that matter with code or sources.

Example. A proposed total looks right but mixes cents and dollars. Ask for the units and independently recompute before accepting it.

Units written out expose the error

LineAs writtenUnitIn cents
Item price1250cents1250
Shipping4.99dollars499
Model's total1254.99mixedinvalid
Recomputed total1749cents17.49 USD
Asking for units per line made the mix of cents and dollars visible; an independent recomputation settled it.
ReAct Pattern (Reason + Act)
An action–observation cycle connects decisions to evidence from the environment. After a catalog lookup returns “discontinued,” the next action could query approved substitutes. Log the tool arguments and returned record so the proposed substitute can be checked independently of the model’s description.

ReAct interleaves short reasoning with tool actions and feeds each observation back in. The useful debugging question is whether the next action actually responds to the last observation. A run that receives "cancelled" and then re-checks the same train, or presents the old itinerary anyway, is ignoring its evidence.

Example. The first lookup reports a cancelled train. Inspect whether the next action consults alternatives or merely repeats the old itinerary.

Another example. A catalogue agent looks up SKU 881, sees discontinued, then queries the approved-substitutes table and returns SKU 902 with that table row attached.

Each observation steers the next action
  1. 1Plancheck the booked train
  2. 2Acttimetable lookup for 08:05
  3. 3Observe08:05 cancelled
  4. 4Planneed an alternative
  5. 5Actsearch trains arriving by noon
Repeat: back to Plan

Log the arguments and the returned records, so the chosen alternative can be checked without trusting the model's summary.

Tree-of-Thoughts (ToT)
A thought tree explores alternative intermediate states. A search policy chooses which branch to expand, and a scoring function estimates progress. Save the best feasible state when the budget runs out. Poor evaluators can prune a correct path early, making wider search expensive without helping.

Tree search keeps several partial solutions alive instead of committing to the first. Three choices drive cost and quality: how many children to generate, how to score them, and which to expand next. A weak scorer is the main risk, because it can prune the only feasible path at depth one. Always keep the best fully checked state found so far, so an exhausted budget still returns something valid.

Example. At depth two and branching factor three, count the root, three children and nine grandchildren before budgeting evaluator calls.

Score, prune and expand the best branch

Illustrative scores. Depth 2 with branching 3 would visit 13 states if nothing were pruned; here only 7 are generated.
Self-Reflection & Critique
A critique is a proposal about what might be wrong. Give it an external reference, executable constraint or relevant document, then verify the revision. If a critic and writer share the same mistaken assumption, exchanging more messages can reinforce the error.

A critique is only a hypothesis about a flaw. It becomes useful when tied to something external: a document, a test, a constraint that code can evaluate. When the critic is the same model with the same context, it tends to share the writer's blind spots, so rounds of mutual agreement can make a wrong answer sound more settled.

Example. A critic calls an answer “unclear.” Ask which source-backed claim is wrong, then test whether the revision actually corrects that claim.

Another example. A coding agent's self-review says the function "looks correct". Running the failing unit test is the critique that counts.

Turn a vague critique into a checked fix

The checker uses the source, not the critic's opinion, to decide whether the revision worked.

How it works

Step through the idea, or press Play.

Step 1 of 3

Candidate route. Train A or train B

Understand it

Worked example

One tool observation changes the plan

  1. 1

    Train A or train B

    The itinerary must arrive before noon. A proposed route is only a candidate until its live timetable is checked.

  2. 2

    Train A arrives 12:15

    A trustworthy observation rules out A. A search process can retain B instead of repeatedly justifying A.

  3. 3

    Train B arrives 11:40

    Confirm B’s timetable and the original constraint. The trace can expose the evidence and final comparison without depending on a model’s private reasoning.

How fast a full search tree grows

N(d)=∑i=0dbiN(d)=\sum_{i=0}^{d} b^i
With branching factor b = 3 and depth d = 2, exhaustive expansion visits 1 + 3 + 9 = 13 states, including the root. Pruning can reduce work and can also discard a feasible path.

Follow the handoffs

Keep observable actions, constraints and source evidence in the trace. These artifacts are useful for debugging even when a model offers no faithful account of its internal reasoning.

Candidates against the noon constraint

CandidateArrival (live timetable)Before 12:00?Status
Train A12:15noruled out by observation
Train B11:40yesverified choice
The table is the trace: evidence and comparison, with no reliance on the model's private reasoning.

Summary

The whole topic in one minute.

Reasoning patterns propose candidates. An independently checked constraint decides feasibility.

Keep observable actions, constraints and source evidence in the trace. These artifacts are useful for debugging even when a model offers no faithful account of its internal reasoning.

Sources