Skip to content

fix(agents-server-ui): hide empty reasoning blocks and interleave them with run items#4570

Merged
kevin-dp merged 1 commit into
kevin/reasoning-contentfrom
kevin/fix-reasoning-blocks
Jun 11, 2026
Merged

fix(agents-server-ui): hide empty reasoning blocks and interleave them with run items#4570
kevin-dp merged 1 commit into
kevin/reasoning-contentfrom
kevin/fix-reasoning-blocks

Conversation

@kevin-dp

Copy link
Copy Markdown
Contributor

Summary

Two fixes for the reasoning-stream UI added in #4508 (note: that feature is on kevin/reasoning-content, not yet on main, so this PR targets the feature branch):

  1. No more empty thinking blocks. Some models report that they reasoned but never expose the tokens (e.g. OpenAI codex models) — pi-adapter.ts deliberately opens a reasoning row on thinking_start even when no delta ever arrives, so the UI rendered a blank live block that settled into an empty ▸ Thought row. AgentResponseLive now filters out rows with no content client-side. Anthropic redacted rows (encrypted set) are kept and still render their placeholder, and a genuinely-streaming block appears as soon as its first delta lands. Persistence is untouched — empty rows are still recorded (they can carry the encrypted payload that must round-trip to the model).

  2. Reasoning blocks interleave with the response instead of stacking at the top. Previously all of a run's reasoning rows rendered in one <ReasoningSection> above every text/tool-call item, so in multi-step tool-using runs step-3 thinking appeared above step-1 output. Reasoning rows already carry the same _timeline_order as text/tool-call rows, so AgentResponseLive now merges both streams into one ordered render list — each block renders at the position the model emitted it (think → write → call tool → think → …). On an order tie (legacy rows without _timeline_order), reasoning sorts before output.

Implementation

  • ReasoningSectionReasoningBlock: the component now renders a single entry; expand/collapse state is lifted to AgentResponseLive (keyed by row key) so it still survives the block unmounting/remounting, same as before.
  • ReasoningEntry gains an order field (same TimelineOrder space as run items).
  • New LiveRenderEntry union + compareLiveRenderEntries comparator; item-vs-item ties keep delegating to compareLiveRunItems.
  • The .root width wrapper in ReasoningSection.module.css is gone — blocks are now direct children of the AgentResponse root, which applies the same width treatment, so they align with text items.
  • The streaming flag for the last text item now compares against lastItem by identity instead of array index (the index no longer maps 1:1 once reasoning entries are interleaved).

Test plan

  • pnpm typecheck clean in agents-server-ui
  • pnpm test in agents-server-ui (88 passed)
  • Manual: codex-model run shows no empty thought block; multi-step Anthropic extended-thinking run shows blocks interleaved between text/tool calls

🤖 Generated with Claude Code

…m with run items

Two fixes for the reasoning stream UI:

- Models that report reasoning without exposing the tokens (e.g.
  OpenAI codex models) open a reasoning row on thinking_start that
  never receives a delta. Filter contentless rows out client-side so
  no empty 'Thought' block renders. Encrypted (Anthropic redacted)
  rows are kept and still render their placeholder.
- Reasoning blocks now interleave with the run's text / tool-call
  items by _timeline_order instead of all stacking above the whole
  response — in multi-step tool-using runs each block renders where
  the model emitted it (think, write, call tool, think, ...).

ReasoningSection becomes ReasoningBlock (one block per row) with
expand/collapse state lifted to AgentResponseLive so it survives
remounts, same as before.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Electric Agents Desktop Builds

Build artifacts for commit dfaaa62.

Platform Status Artifact
macOS Apple Silicon Passed DMG
macOS Intel Passed DMG
Windows x64 Building Installer
Linux x64 Passed AppImage / deb

Workflow run

@kevin-dp kevin-dp merged commit c813bcd into kevin/reasoning-content Jun 11, 2026
21 of 22 checks passed
@kevin-dp kevin-dp deleted the kevin/fix-reasoning-blocks branch June 11, 2026 14:26
@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 34.03%. Comparing base (ee2b9d4) to head (dfaaa62).
⚠️ Report is 1 commits behind head on kevin/reasoning-content.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
.../agents-server-ui/src/components/AgentResponse.tsx 0.00% 22 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (ee2b9d4) and HEAD (dfaaa62). Click for more details.

HEAD has 24 uploads less than BASE
Flag BASE (ee2b9d4) HEAD (dfaaa62)
unit-tests 11 3
packages/start 1 0
typescript 11 3
packages/agents-mcp 1 0
packages/y-electric 1 0
packages/electric-ax 1 0
packages/agents 1 0
packages/agents-runtime 1 0
packages/experimental 1 0
packages/typescript-client 1 0
Additional details and impacted files
@@                     Coverage Diff                      @@
##           kevin/reasoning-content    #4570       +/-   ##
============================================================
- Coverage                    57.95%   34.03%   -23.93%     
============================================================
  Files                          369      224      -145     
  Lines                        40622    19080    -21542     
  Branches                     11506     6775     -4731     
============================================================
- Hits                         23541     6493    -17048     
+ Misses                       17006    12552     -4454     
+ Partials                        75       35       -40     
Flag Coverage Δ
packages/agents ?
packages/agents-mcp ?
packages/agents-mobile 75.49% <ø> (ø)
packages/agents-runtime ?
packages/agents-server 75.06% <ø> (+0.20%) ⬆️
packages/agents-server-ui 6.22% <0.00%> (-0.01%) ⬇️
packages/electric-ax ?
packages/experimental ?
packages/start ?
packages/typescript-client ?
packages/y-electric ?
typescript 34.03% <0.00%> (-23.93%) ⬇️
unit-tests 34.03% <0.00%> (-23.93%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown
Contributor

Electric Agents Mobile Build

Local mobile checks ran for commit dfaaa62.

The EAS Android preview build was skipped because the mobile-eas-build label is not present.
Add the mobile-eas-build label to this PR to produce an installable preview build.

Workflow run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant