Skip to content

fix(session): keep history when tool ids collide across sessions - #560

Merged
vastsa merged 2 commits into
mainfrom
fix/outbox-unique-message-id
Sep 17, 2026
Merged

vastsa merged 2 commits into
mainfrom
fix/outbox-unique-message-id

Conversation

@vastsa

@vastsa vastsa commented Sep 17, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #523: closing and reopening dropped later conversation turns.

Provider toolCallIds (e.g. call_421522) were used as globally unique messages.id. A cross-session collision failed SQLite after the JSONL write, paused the FIFO persistence outbox, and later assistant/tool rows from every session never landed.

  • Host remaps a colliding id to {sessionId}:{id} before writing JSONL
  • Leftover JSONL from a failed UNIQUE is acknowledged without appending a second line
  • Orphan restore remaps colliding ids before rebuilding the index
  • Outbox treats UNIQUE constraint failed: messages.id as an ack and keeps draining

Test

  • cargo test -p host-core append_message_
  • cargo test -p host-core orphaned
  • node --test apps/desktop/test/persistence-outbox.test.mjs

Provider toolCallIds were used as globally unique messages.id. A
collision failed SQLite after the JSONL write, paused the FIFO
persistence outbox, and dropped later assistant/tool rows after quit.

Remap a colliding id to {sessionId}:{id} before the transcript write,
and treat UNIQUE constraint failed: messages.id as an outbox ack so
one poison entry cannot stall every later session.

Fixes #523
A failed UNIQUE append already wrote the original id to JSONL. Replaying
it must not append a remapped second line. Orphan restore remaps
colliding ids before rebuilding the index so D318 cannot UNIQUE-fail
and stall the outbox.
Copilot AI lite review requested due to automatic review settings September 17, 2026 17:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@vastsa
vastsa merged commit 0aef791 into main Sep 17, 2026
4 checks passed
@vastsa
vastsa deleted the fix/outbox-unique-message-id branch September 17, 2026 17:52
veyliss pushed a commit to veyliss/PI-Desktop that referenced this pull request Sep 18, 2026
PR vastsa#550 rewrote the accepted D409 row and the ADR 0239 decision text in
place. The log is append-only for accepted decisions, so restore both and
record the change as D446 with an ADR 0239 amendment section, marking
D409 and the ADR index row as amended. D444 and D445 were taken by
PR vastsa#560 and PR vastsa#563 while this branch was in review.

Align spec 02-agent-runtime §5e and the error-code table with the
narrowed contract (first reply only, tool batch and steering revoke it,
provider retry keeps it, accepted silence stays out of model context),
add the session-completion suite to the E2E routing index, and mirror
every change in the zh-CN pages.

This branch was successfully deployed

1 active deployment
Preview — 7bdfb857 Deployed Sep 17, 2026 by vercel[bot]
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.

[Bug] 关闭再次打开,前期的对话历史记录丢失

2 participants