Skip to content

[Bug]: TUI: streamed text replaced with shorter text on finalize after tool calls #15452

@ghost

Description

When the assistant writes text → calls a tool → writes more text, the TUI initially shows the full streamed response correctly. But when the response finalizes, the displayed text gets replaced with a shorter version — the pre-tool-call text disappears.

Steps to reproduce:

  1. Open openclaw tui
  2. Ask something that triggers tool calls mid-response (e.g. a question requiring web search + explanation)
  3. Watch the streamed text — it's correct and detailed
  4. On finalize, the text is replaced with a shorter version (pre-tool text lost)

Expected: Finalized text matches the full streamed text.

Actual: Finalized text drops content written before tool calls.

Analysis: Traced through the TUI source:

  • tui-event-handlers.ts calls streamAssembler.ingestDelta() on deltas (correct, accumulates all text blocks)
  • On final, calls streamAssembler.finalize() which rebuilds from the final message payload
  • The final chat event's message appears to contain fewer text content blocks than what was streamed —
    specifically, text blocks written before tool calls seem to be dropped from the final payload
  • The TUI rendering (chat-log.ts, tui-stream-assembler.ts) is correct — it faithfully displays whatever it
    receives. The issue is upstream in how the chat final is assembled after multi-block tool-use turns.

Environment: macOS, Node v25.6.0, anthropic/claude-opus-4-6, terminal TUI

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions