fix(tui): keep reasoning-only assistant turns visible on session resume#44402
Closed
AIalliAI wants to merge 1 commit into
Closed
fix(tui): keep reasoning-only assistant turns visible on session resume#44402AIalliAI wants to merge 1 commit into
AIalliAI wants to merge 1 commit into
Conversation
A thinking-only assistant turn (reasoning present, empty visible text) is persisted with its reasoning fields and stays recallable from the transcript, but `_history_to_messages` dropped it as "empty" before its reasoning was attached. On desktop/TUI resume or reload the turn therefore vanished from the session view while the agent could still recall it from a fresh session -- exactly the "messages disappear when the LLM uses its thinking block, but a new session can recall them" symptom reported on NousResearch#44022. Keep an assistant turn when it carries reasoning, even with empty text, so the desktop "Thinking…" disclosure has something to render. Genuinely empty turns (no text, no reasoning, no tool calls) are still filtered out. Refs NousResearch#44022 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
|
Verification review — this PR looks correct. Checked:
Looks good to merge. |
Contributor
Author
|
Requesting maintainer review — this is ready to land from my side. Standalone fork CI is pending first-run approval here; the rollup branch in #44061 carrying this session's batch is fully green on upstream CI (all test shards, typecheck, e2e). |
This was referenced Jun 13, 2026
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On the desktop/TUI app, an assistant turn that produced only a thinking/reasoning block (extended-thinking turns, thinking-only recovery responses) disappears from the session view on resume/reload — while the turn is still in the transcript DB, so a new session can recall "what was said." This is the second symptom reported on #44022 (scorpio-dot's comment):
Root cause
tui_gateway/server.py::_history_to_messagesdrops any message whose coerced text is empty before the assistantreasoningfields are attached:A reasoning-only assistant turn has empty
contentbut non-empty reasoning, so it is filtered out of the resume payload entirely. The turn is still persisted (gateway/session.pystores the reasoning fields), which is why recall from a fresh session works — the asymmetry is display-only, on the history→messages serialization path used by desktop/TUI resume and reload.Fix
Keep an assistant turn when it carries any reasoning content, even with empty visible text, so the desktop's reasoning ("Thinking…") disclosure has something to render. Genuinely empty turns (no text, no reasoning, no tool calls) are still filtered out, and tool-call-only turns are unaffected.
Tests
test_history_to_messages_keeps_reasoning_only_assistant_turn— a reasoning-only turn survives with itsreasoningfield intact.test_history_to_messages_still_drops_empty_assistant_without_reasoning— empty/whitespace turns with no reasoning are still dropped.Both pass; full
tests/test_tui_gateway_server.pyshows no new failures (one pre-existing unrelatedbrowser_managefailure present onmainas well).Scope
This is the display/serialization half of #44022's reports. The separate "resume fails with No LLM provider configured" provider-restore bug is addressed by #44062 (the complete restore-side fix) / #44151, and the persist-side by #44109. Using
Refs #44022rather thanFixesso the provider bug isn't auto-closed.Refs #44022
🤖 Generated with Claude Code