Conversation
…livery turns Two defects compound to silently drop assistant/tool transcripts: 1. The persistence outbox treats every append failure as transient and re-queues the head forever. A permanently-rejected entry (for example a steering message the host provenance check refuses) stalls the whole FIFO queue; once it fills to MAX_ENTRIES, every later message is discarded. 2. Steering (Alt+Enter) into a session-collaboration delivery turn builds a user message whose turn_id already owns a claimed delivery. prepare_append then rejects it as "transcript input does not match its session delivery", producing exactly the poison entry above. Fix the outbox to drop permanently-rejected (poison) messages and keep draining, while still pausing on transient failures. Fix provenance to accept steering input into its owning delivery turn without stamping it with the delivery's agent origin, and to still reject steering that targets another session.
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.
问题
两个缺陷叠加,导致会话的 assistant/tool 消息静默丢失:会话只剩 user 消息,AI 回复全部消失。
证据(真实复现现场)
持久化 outbox
session-message-outbox.json打满到MAX_ENTRIES=1024,队首卡了一条被 host 永久拒绝的 steering 消息:日志中该队首消息被反复重试、永不丢弃,队列从此停滞:
受影响会话
f96c5113-7d28-45df-86e7-3d40b35e66c1在 SQLite 里只剩 6 条 user 消息,49 条 assistant + 73 条 tool 消息全部丢失。根因
缺陷 1:outbox 把永久错误当 transient
apps/desktop/electron/main/persistence-outbox.ts的flushLoop对任何 append 错误都return保留队首、等下次重试。永久性、消息级错误(provenance/validation/permission)也会无限重试,毒消息永远卡在队首,FIFO 不再前进。缺陷 2:provenance 拒绝合法的 steering 输入
在 session-collaboration 的 delivery turn 运行中按 Alt+Enter(steering),
agent-ipc.ts构造一条steering: true的 user 消息,其turn_id已被begin_turn认领为 delivery。crates/host-core/src/session_collaboration/provenance.rs的prepare_append要求该turn_id名下的 user 消息必须与 delivery 的content逐字一致、且无附件,否则拒绝。而 steering 的 content 是用户新输入,必然不匹配 → 产生毒消息。修复
1. outbox:丢弃毒消息、继续 drain(止血)
persistence-outbox.ts的flushLoop三分支:UNIQUE constraint failed: messages.id)→ 丢弃继续 drain(已有)PERMISSION_DENIED/INVALID_ARGUMENT/INVALID_PARAMS/NOT_FOUND: session)→ 丢弃继续 drain(新增)新增
isPoisonMessageError正则判定。队列不再会被单条毒消息永久卡死。2. provenance:接受 delivery turn 内的 steering(治本)
provenance.rs的prepare_append识别steering == Some(true):session_message保持None)PERMISSION_DENIED)steering 是用户对已有 turn 的追加输入,不是 delivery 本身,本就不应套用 delivery 的 content/attachment 契约。这样既不再产生毒消息,也保持了对伪造/跨 session 输入的保护。
测试
apps/desktop/test/persistence-outbox.test.mjs:新增poisoned provenance message does not stall later outbox entries (D597),7/7 通过。crates/host-core/src/session_collaboration/tests.rs:新增steering_input_persists_without_inheriting_delivery_origin,验证 steering 落库且不继承 agent origin、跨 session steering 仍被拒;cargo test -p host-core session_collaboration12/12 通过。