Skip to content

fix(session): defer text part creation until first delta - #2193

Open
wqymi wants to merge 1 commit into
mainfrom
fix/empty-text-part-cleanup
Open

fix(session): defer text part creation until first delta#2193
wqymi wants to merge 1 commit into
mainfrom
fix/empty-text-part-cleanup

Conversation

@wqymi

@wqymi wqymi commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Problem

The engine creates empty text parts at text-start time. When a model opens multiple text-starts but some have no actual content (empty text block before tool call), empty shell parts (len=0) are left in the database.

Fix

Defer text part creation to the first text-delta:

  • text-start: only create in-memory currentText, no updatePart or stepPartIds.push
  • text-delta: first delta triggers DB insert + stepPartIds registration (empty parts never created)
  • text-end: empty text discarded (never persisted)
  • cleanup: empty text discarded (never persisted)

Impact

  • Empty text parts no longer exist in the database
  • Consumers that read text parts (TUI, history reconstruction, etc.) are naturally compatible
  • stepPartIds error cleanup path is safe (unpersisted ids are not in the list)

Tests

  • typecheck passes
  • max-mode tests pass
  • copilot chat model tests pass
  • auto-overflow tests pass

@wqymi
wqymi force-pushed the fix/empty-text-part-cleanup branch 11 times, most recently from dd24b74 to cbadf8c Compare August 22, 2026 06:19
@wqymi
wqymi force-pushed the fix/empty-text-part-cleanup branch from cbadf8c to bca3b65 Compare August 22, 2026 06:20
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