fix(runtime): preserve imported session context - #2579
Merged
Merged
Conversation
M4n5ter
force-pushed
the
fix/external-session-continuity
branch
4 times, most recently
from
August 9, 2026 08:28
be54288 to
65c923a
Compare
M4n5ter
force-pushed
the
fix/external-session-continuity
branch
from
August 9, 2026 08:37
65c923a to
8e48337
Compare
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.
English
Summary
Imported external Sessions now prepare canonical AgentRun and RuntimeEvent history before the import is reported as successful. Each imported transcript turn receives a synthetic Run, while provider-specific reasoning and tool records remain visible in the transcript but are excluded from cross-provider model replay.
The root cause was a split history model: external imports persisted StoredMessages for rendering, but prior model context is reconstructed exclusively from canonical AgentRun ledgers. The imported conversation therefore appeared complete in Desktop while the next model request received no historical context.
The repair is owned by the shared Runtime layer rather than Desktop. New imports remain outside the public Session catalog and cannot execute until canonical history preparation commits. Startup recovery resumes or discards interrupted imports, while pre-existing orphaned transcripts are materialized per turn at the shared root-turn boundary before a new Run is admitted. Materialization is resumable after partial writes, and a durable Session marker removes repeat transcript scans after completion. Desktop, CLI, and TUI therefore consume the same canonical history without a client-specific fallback.
Verification
npm run buildnpm run lintnpm run format:checkgit diff --checkChecklist
Does this PR entail a change in behavior?
中文
概要
导入外部会话时,现在会在返回成功前准备好规范的 AgentRun 与 RuntimeEvent 历史。每个导入的对话轮次都会获得合成 Run;提供商特定的思考与工具记录仍保留在可见转录中,但不会进入跨提供商的模型重放。
根因是历史数据存在两套口径:外部导入只持久化了用于界面渲染的 StoredMessage,而模型的上文只从规范 AgentRun ledger 重建。因此 Desktop 中看起来完整的导入会话,在下一次模型请求中却没有历史上下文。
修复归属共享 Runtime 层,而不是 Desktop。新导入在规范历史准备提交前不会进入公共 Session 目录,也不能执行;启动恢复会继续或清理被中断的导入。已有的孤立转录会在新 Run 获准前,于共享 root-turn 边界按轮次完成物化。物化在部分写入后可继续重试,完成后由持久 Session 标记避免重复扫描转录。因此 Desktop、CLI 与 TUI 都消费同一份规范历史,不需要 client 特定 fallback。
验证
npm run buildnpm run lintnpm run format:checkgit diff --check检查清单
此 PR 是否包含行为变化?