Skip to content

fix(runtime): preserve imported session context - #2579

Merged
M4n5ter merged 1 commit into
mainfrom
fix/external-session-continuity
Aug 9, 2026
Merged

M4n5ter merged 1 commit into
mainfrom
fix/external-session-continuity

Conversation

@M4n5ter

@M4n5ter M4n5ter commented Aug 9, 2026

Copy link
Copy Markdown
Member
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

  • Storage full suite: 774 passed, 12 skipped, 0 failed
  • Runtime full suite: 3,272 passed, 9 skipped, 0 failed
  • Runtime Host full suite: 780 passed, 0 failed
  • Focused Runtime and Runtime Host regressions passed
  • npm run build
  • npm run lint
  • npm run format:check
  • git diff --check

Checklist

  • Tests cover canonical model replay, transcript ordering, interrupted repair, and failed-import cleanup
  • Lint, format, build, and affected suites pass

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No
中文

概要

导入外部会话时,现在会在返回成功前准备好规范的 AgentRun 与 RuntimeEvent 历史。每个导入的对话轮次都会获得合成 Run;提供商特定的思考与工具记录仍保留在可见转录中,但不会进入跨提供商的模型重放。

根因是历史数据存在两套口径:外部导入只持久化了用于界面渲染的 StoredMessage,而模型的上文只从规范 AgentRun ledger 重建。因此 Desktop 中看起来完整的导入会话,在下一次模型请求中却没有历史上下文。

修复归属共享 Runtime 层,而不是 Desktop。新导入在规范历史准备提交前不会进入公共 Session 目录,也不能执行;启动恢复会继续或清理被中断的导入。已有的孤立转录会在新 Run 获准前,于共享 root-turn 边界按轮次完成物化。物化在部分写入后可继续重试,完成后由持久 Session 标记避免重复扫描转录。因此 Desktop、CLI 与 TUI 都消费同一份规范历史,不需要 client 特定 fallback。

验证

  • Storage 全量:774 通过,12 跳过,0 失败
  • Runtime 全量:3,272 通过,9 跳过,0 失败
  • Runtime Host 全量:780 通过,0 失败
  • Runtime 与 Runtime Host 定点回归通过
  • npm run build
  • npm run lint
  • npm run format:check
  • git diff --check

检查清单

  • 测试覆盖规范模型重放、转录顺序、中断后重试与导入失败清理
  • lint、format、build 与相关测试套件通过

此 PR 是否包含行为变化?

  • 是——已在概要中说明

@M4n5ter
M4n5ter force-pushed the fix/external-session-continuity branch 4 times, most recently from be54288 to 65c923a Compare August 9, 2026 08:28
@M4n5ter
M4n5ter force-pushed the fix/external-session-continuity branch from 65c923a to 8e48337 Compare August 9, 2026 08:37
@M4n5ter
M4n5ter merged commit 99731ef into main Aug 9, 2026
11 checks passed
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