Chapter 9

Read reasoning blocks, tool cards, and diffs

Pi Agent can show more than a final answer: collapsible reasoning blocks, tool cards, and red-and-green code diffs. This chapter explains what each type records, when to inspect it, and when it is safe to move on. By the end, you will be watching the agent work rather than treating its answer as a black box.

Why learn to inspect these blocks?

Remember the extra elements around the AI's answer when you started your first conversation in Chapter 7? The collapsible gray block, white card, and red-and-green correction-like display are not decoration or bugs. They distinguish Pi Agent from a conventional chat page: they expose available reasoning information and the record of what the agent did.

Reading them lets you:

  • Inspect available reasoning information when an answer takes a wrong turn.
  • When the AI says it read configuration.yaml, open the tool card to confirm which file it read and what the tool returned.
  • Review a diff line by line before accepting or retaining a configuration change—your final human checkpoint before allowing the agent to alter your home setup.

These records improve visibility, but they do not make an action safe automatically. A tool can run before you read its card, depending on the active guardrails. The goal is to recognize each block immediately and know whether to expand it while understanding the permissions your Session has.

Concept:The formal names are reasoning block, tool call card, and inline diff. pi-web and its documentation use these English terms, so learning them also makes troubleshooting easier.

Three special blocks at a glance

Start with this overview. The remaining sections add detail to this mental model:

BlockIn one lineAppearanceSource
Reasoning block
Reasoning
Reasoning data the provider makes availableGray, collapsed by default, with a ▶ controlOnly supported reasoning model and API combinations
Tool card
Tool call
What an external tool attempted or didWhite card labeled with the tool nameBuilt-in tools or tools added by Skills
Inline diff
Inline diff
Which file lines an edit removes and addsInterleaved red and green linesFile-edit activity
Memory aid:A reasoning block is model output, a tool card is an action record, and a diff is a file-change record. Each step is more concrete and deserves closer review.
Reasoning, tool-call, and diff blocks in a Pi Agent Session
Figure 9-1A real Session can place a gray reasoning block above the final answer, show a tool call as a white card, and render a diff in red and green. Each can be expanded for details.

Reasoning blocks explained

Reasoning blocks are the easiest of the three to miss because they are commonly collapsed.

What they look like

A gray block may be labeled “Thinking” or its localized equivalent and include a disclosure control such as ▶ or +. It commonly appears above the final answer. Expanding it reveals whatever reasoning text or summary the provider and route make available.

When they appear

Only a supported reasoning model and route can produce one. Chapter 12 explains the trade-offs. This quick reference helps identify what a route may expose:

ModelProviderpi-web thinkingFormatVisible content
A compatible GLM reasoning route with <think> tags or reasoning_contentZ.ai / GLMzaiReasoning content when the endpoint returns it
DeepSeek-R1 / R1-0528 with reasoning_contentDeepSeekdeepseekContent supplied by the route
Compatible Claude models using extended or adaptive reasoningAnthropicThe SDK uses a built-in thinking block; normally leave the Models field blankVisible content may be a summary, not private chain of thought
Compatible Qwen3 / QwQ routesAlibaba Cloud or OpenRouterqwen or qwen-chat-templateRoute-dependent reasoning text
OpenAI o1 / o3 / o4-mini and GPT-5 reasoning routesOpenAISelect openai when the route requires itNo private chain of thought—you may see reasoning_tokens usage data or supported summaries
Kimi K2-Instruct on GroqMoonshot / GroqDo not select thinkingFormat for this non-reasoning routeNone; an Instruct route is not a Thinking route

Do not infer capabilities from a family name alone. Models such as GLM-4-Flash, GPT-4o, Claude Haiku 3.5, and Kimi K2-Instruct are non-reasoning examples in the source material; on OpenRouter, check the exact current model page and route.

Correction:Valid pi-web thinkingFormat values are openai / openrouter / together / deepseek / zai / qwen / chat-template / qwen-chat-template / string-thinking / ant-ling—there is no native and no none. A direct Anthropic route uses the SDK's type: "thinking" content block through @anthropic-ai/sdk, so this Models field has no effect and should be left blank.

What an expanded block contains

It may show provider-exposed reasoning about the answer—for example, identifying a 10:00 p.m. lighting trigger, choosing light.turn_off, and considering presence conditions. It may be a long passage, a short summary, or only metadata; do not assume it is the model's private chain of thought.

When to read it

  • The final answer is strange or conflicts with your constraints.
  • You want to inspect the stated analysis framework, such as how a lighting request was divided into trigger, condition, and action.
  • You want to see whether an important condition appears in the available reasoning summary.

When to skip it

  • The task is low risk and the final answer is easy to verify.
  • You asked a simple lookup question.
  • You will not use the result.

Why a reasoning model may show no block

Check three possibilities:

  1. The Chapter 6 reasoning option is not enabled—where a model entry exposes a reasoning checkbox, it controls whether pi-web renders reasoning as a separate block.
  2. The provider's thinkingFormat is wrong—this is a provider-level field. Use openai only for an applicable direct OpenAI-compatible route, zai for GLM, deepseek for DeepSeek, or qwen for a compatible Qwen route; a direct Anthropic route normally leaves it blank. The wrong parser may fail to separate reasoning_content. For OpenRouter, follow the exact model route's current documentation.
  3. You selected a non-reasoning model under the provider—for example, a catalog may include both reasoning and non-reasoning variants, while a Groq Kimi K2 listing may be Instruct rather than Thinking. Confirm the exact model ID.

Tool call cards explained

A tool card is the most important of the three because it records something the agent actually attempted or did.

What they look like

A white card labeled “Tool: xxx” or “Calling xxx” includes a summary of the input parameters and output result. Expand it for complete details. Depending on the version, a card can show “Running…,” success, or failure.

When they appear

They appear when the agent needs to act rather than only generate prose—for example, reading a file, running a shell command, or querying an enabled service. Available tools depend on the active agent and installed Skills; Chapter 16 explains how Skills add capabilities. A model's own knowledge is not a live web search.

Common tool names: Seven pi coding agent built-ins

The core Pi Agent package, @earendil-works/pi-coding-agent, includes these seven lowercase tools:

ToolPurposeShould you expand it?
readRead a fileRecommended: confirm the correct file and scope
writeCreate or replace a complete fileAlways; confirm both path and content
editReplace a matched section and produce an inline diffAlways; review the complete diff
bashRun a shell commandRecommended, especially for rm, mv, and sudo
grepSearch file contentsUsually optional unless the results look wrong
findFind paths by patternUsually optional; check the search root
lsList a directoryUsually optional, though paths may be sensitive
Version note:Names such as read_file / write_file / web_fetch / search belong to other agent systems unless a Skill explicitly adds them. The baseline pi coding agent does not use those names and has no built-in web-fetch tool. Web access requires a Skill built around a tool such as curl or playwright, or an appropriate bash: curl ... command. Extra tool names are defined by the Skill and are not part of these seven.

What an expanded card contains

It contains the actual arguments—such as the read path or the bash command—and the returned file content, command output, or grep matches. This is stronger evidence of an attempted action than the model's narrative.

When to read it

  • When the AI says it read a file, expand the corresponding read card and verify the path and result.
  • For write / edit, always expand the card. Confirm the path; for edit, also verify that old_string really comes from the original file.
  • For a bash card, inspect the command for dangerous patterns such as rm -rf, chmod 777, or curl | sh.
  • If the conclusion differs from what you expected, inspect the raw tool output.
Warning:A failed tool result can still be followed by confident prose. Expand a red error card, verify that no partial change occurred, and decide whether a retry is safe.

Inline diffs: Your file-change checkpoint

An inline diff requires close review because it records a proposed or executed file change. It is a review aid, not proof that the change is safe or waiting for approval.

What it looks like

Deleted lines appear in red with -; added lines appear in green with +. Unchanged white lines provide context, much like a GitHub pull-request diff.

When it appears

It can appear when the agent proposes or performs an edit to a known file. For example, after reading configuration.yaml, it can show the MQTT integration lines that differ. A standalone code sample has no baseline and may not produce a diff.

What you can inspect

Review the complete patch, not only the first visible lines. Controls such as “Show details,” “Apply,” “Copy,” or “Compare HEAD” depend on the pi-web version, active guardrails, and repository state.

When to read it

Every time.Also inspect the associated tool card to determine whether the edit already ran.

Three ways to handle a diff

  1. Option A: Manually copy a reviewed final version

    This is the most conservative option. If your pi-web version offers Copy (the i18n.copy label), it may also offer Show details / Hide details for the complete patch and Compare HEAD for a Git comparison. Compare the result with the original configuration.yaml, preserve YAML indentation, and apply only the reviewed portion.

  2. Option B: Ask the agent to use edit or write

    The agent may call edit for an exact local replacement or write to replace a complete file. Prefer edit when an exact local change is appropriate, but remember that you must watch the tool card: verify the path, the full content, and whether the action already ran. Use this only within approved guardrails.

  3. Option C: Reject it and request a different approach

    If the direction is wrong or a line must remain, state exactly what to preserve and what to change. The agent can generate a new diff, which you must review again from the beginning.

Danger:Before changing configuration.yaml / automations.yaml / scripts.yaml / .storage/, back up and verify the restore process. Chapter 12 covers how to assess a proposed change, but no snapshot replaces syntax validation and safe testing.

Worked example: A lighting automation

Suppose you ask a suitable current model to add a 10:00 p.m. living-room lighting automation. The Session has file tools and the home-assistant-best-practices Skill, which provides Home Assistant guidance but no new tool. It encourages the agent to use edit rather than write over the complete automations.yaml. The response may follow this sequence:

#BlockContentsYour review
1Reasoning blockAvailable reasoning may identify a 22:00 trigger, a light.turn_off action, and a light.living_room target, then consider whether a condition is needed.Optional; inspect the approach, but do not treat it as evidence
2Tool card: readInput: path: /config/automations.yaml; Output: existing file contentConfirm that /config/automations.yaml is the intended path and enough of the file was read
3Tool card: edit plus an inline diffInput: path: /config/automations.yaml, old_string: ..., and new_string: ...; the card renders the added automation entry with its alias, triggers, and actionsAlways review—confirm light.living_room, indentation, unchanged content, and that old_string exists in the original file
4Output: success in the same edit cardEdit resultConfirm whether it succeeded; an error can mean old_string did not match, while success still does not validate Home Assistant syntax
5Final answerA summary that a rule was added to automations.yaml, plus current validation and reload guidanceValidate the configuration and test the automation safely
Tip:The pi coding agent edit tool requires an exact old-text match. This limits accidental broad replacement and can reject hallucinated context, making it safer than write for a local edit. It does not prove the replacement is correct.

If you read only “Done,” you miss the path, entity ID, exact YAML, and whether the tool succeeded. The diff and tool result let you catch mistakes before relying on the automation.

Concept:Pi Agent's transparency supports human review: it exposes available reasoning, actions, and file changes. It does not replace least privilege, backups, validation, or testing.

How these blocks affect context and cost

All three can affect token usage, although billing details vary by provider and route:

BlockPotential token useWho pays
Reasoning blockMay add hundreds or thousands of tokensYour account, according to the route's output or reasoning pricing
Tool inputDepends on the request; a large read can add substantial contextIt may count as input when sent to the model on the next turn
Tool outputSame principleSame principle
DiffDepends on the changed fileGenerated changes may count as output

Use these three practical controls alongside Chapter 12:

  1. Use reasoning only when the task benefits from it.For simple lookups and low-risk tasks, choose a current lower-cost non-reasoning model from your provider or OpenRouter catalog.
  2. Before asking the agent to read a file, decide whether it needs the whole file.If only one range matters, request that range instead of loading thousands of irrelevant lines from automations.yaml into context.
  3. Start a new Session when the conversation becomes too long.Old reasoning blocks and tool output can be carried into later context. Watch the contextUsage indicator if your version displays % used / contextWindow tokens. The documented baseline has no universal warning thresholds, so follow your exact route's limit rather than treating 60% as a guaranteed cutoff or waiting for a provider rejection.

Hide reasoning without confusing display and billing

Some people find reasoning blocks distracting. The documented pi-web 0.8.4 baseline does not provide a guaranteed global UI switch that directly hides every reasoning block; it commonly collapses them by default. Interface controls vary by version, and hiding a block does not prove that the provider stopped reasoning or billing. Two practical choices are:

  • Return to Chapter 6 and change the model entry's reasoning setting only if the exact route supports it—the display and API behavior are route-specific. On OpenRouter, verify the selected model's documented reasoning settings and whether it returns reasoning_content.
  • Select a non-reasoning model—choose a current non-reasoning model ID from your provider or OpenRouter catalog. This avoids assuming that a hidden display also avoids reasoning usage.
Warning:If an online guide mentions a “Show reasoning blocks” switch, it may describe another fork or release. The baseline for this guide, 0.8.4, does not guarantee that switch. Check the installed version and the current @agegr/pi-web documentation.

A useful compromise is to keep one Session for deliberate analysis and another for quick, low-risk questions. Choose current OpenRouter model IDs for each role instead of relying on region-specific defaults.

Common block problems

  1. A reasoning block will not expand

    Wait for generation to finish. If it still will not expand, reload the page and try a private window without extensions. Press F12 and inspect the browser Console for a real JavaScript error.

  2. A tool card reports an error

    Expand the card and read the output field named isError. Common causes include an incorrect /config/automations.yaml path, a bash command with a nonzero exit, or an edit old_string that did not match. Verify whether a partial action occurred before asking the agent to retry.

  3. A copied diff breaks YAML indentation

    Compare whitespace against the original because tabs and spaces can look alike. Ask for a complete reviewed file only when whole-file replacement is appropriate; do not use write / edit merely to avoid understanding the diff.

  4. A selected reasoning model shows no block

    Check the provider's thinkingFormat. A later direct GLM route may require zai as described in Chapter 6; for OpenRouter, verify the exact model's current reasoning support and route configuration. Open a new Session after changing provider settings.

  5. A tool remains on “Running…”

    Inspect the exact tool. A long bash command such as find / or ffmpeg, or a very large read, may take time. The baseline pi coding agent has no built-in web_fetch tool, though a Skill can add one. Use Cancel if available; otherwise follow the installed version's recovery guidance and check the resulting isError state.

  6. No diff appears; the agent shows only code

    A diff needs an original file or baseline. If you did not provide the actual automations.yaml, ask the agent to read and compare the reviewed file before editing.

Blocks FAQ

Is a long reasoning block better?
Not necessarily. Length does not prove accuracy; a long block may reflect useful decomposition or unproductive uncertainty. Evaluate the final answer, assumptions, evidence, and result, and compare another suitable current model when needed.
Can I trigger a tool card myself?
You cannot directly press a button to trigger it, but you can ask the model to use an available tool—for example, “Use read to inspect /config/configuration.yaml.” The baseline tools are read/write/edit/bash/grep/find/ls, and a Skill may add others. Check the Skills panel rather than assuming an <available_tools> XML panel exists; Chapter 14 explains how Skills attach capabilities to the agent.
Can I completely trust code in a diff?
No. Review it yourself.Check entity IDs such as light.living_room rather than the misspelled light.liveing_room, reject an unintended path such as /, and verify current Home Assistant syntax—for example, whether the specific context expects service: or action:. Also inspect indentation and unintended deletions, then validate and test safely.
Can I expand every block at once?
The baseline does not guarantee an Expand all control. You can search for “Thinking” with Ctrl+F, or press F12 and run document.querySelectorAll('details').forEach(d => d.open = true) in devtools if your version uses <details>. This is version-dependent and can expose sensitive content on screen, so expand only what you need.
Can reasoning blocks serve as my notes?
You can use a GLM or Claude reasoning block to inspect an approach and capture a study note. Do not cite it directly as factual evidence, because provider-visible reasoning may contain assumptions, corrections, errors, or only a summary. The decomposition can be useful even when individual statements are not.
Does a failed tool call cost API usage?
A failed local command is not itself a provider request, but the original request and any later model turn that includes the error can consume tokens. Check the provider or OpenRouter usage record instead of assuming failure is free.
What if I cannot read YAML indentation in a diff?
Ask the agent for a plain-English, line-by-line explanation of what changes and why. Do not apply it until you understand the target, behavior, validation steps, and rollback plan.
Can I hide tool cards and show only conclusions?
Tool activity remains visible when the interface records it. You can ask for an answer without tools, but that removes verification. For Home Assistant changes, allow inspection only within approved guardrails and review the resulting card.