Skip to content

fix(tui): refuse empty truncation on prompt.submit to prevent silent session wipe (#70516) - #70718

Closed
webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:fix/70516-truncate-wipe-guard
Closed

fix(tui): refuse empty truncation on prompt.submit to prevent silent session wipe (#70516)#70718
webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:fix/70516-truncate-wipe-guard

Conversation

@webtecnica

Copy link
Copy Markdown
Contributor

Problem

Stale truncate_before_user_ordinal=0 from a desynced frontend causes replace_messages() to DELETE all session messages silently (observed: 308 messages lost). No log, no confirmation.

Fix

  • Empty-truncation guard: refuse truncation when truncated==[] unless confirm_empty_truncate=true is passed (error 4025)
  • Logging: every truncation logged at WARNING (session id, history N→M, ordinal)
  • Covers the exact wipe reported: ordinal=0 on an ordinary submit from stale frontend

Fixes #70516

…cript

P1: A stale truncate_before_user_ordinal from a desynced frontend
(e.g. ordinal=0 on an ordinary prompt.submit) causes replace_messages()
to silently DELETE all session messages — an unrecoverable data loss.

Changes in tui_gateway/server.py prompt.submit handler:
- Add guard: refuse empty truncation (truncated == []) unless the
  client explicitly passes confirm_empty_truncate=true.
- Log every truncation (history N -> M, ordinal=k) so future
  incidents are traceable in agent.log.

Fixes NousResearch#70516
@alt-glitch alt-glitch added type/bug Something isn't working comp/tui Terminal UI (ui-tui/ + tui_gateway/) sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state P1 High — major feature broken, no workaround duplicate This issue or pull request already exists labels Jul 24, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #70570. It covers the same empty prompt.submit truncation guard, uses strict confirmation parsing, and updates intentional Desktop first-turn flows.

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Closing as the fix has been merged to main in commit 819e01c by @HexLab98 (#70570), which implements the same guard using is_truthy_value() with desktop frontend coverage. The error code collision (4025) you would have hit was also fixed in 6de7c0f (changed to 4028). Thank you for the contribution — your PR correctly identified the root cause and the guard pattern.

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

Labels

comp/tui Terminal UI (ui-tui/ + tui_gateway/) duplicate This issue or pull request already exists P1 High — major feature broken, no workaround sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Desktop: stale truncate_before_user_ordinal on prompt.submit can silently wipe an entire session transcript

3 participants