优化 tool result 存储与 session 状态恢复#36
Open
GateJustice wants to merge 1 commit into
Open
Conversation
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.
摘要
本 PR 重构了 MiniCode 的 tool-result / session / compact 相关主链路,重点解决两类问题:
同时,本 PR 还补齐了结构化 tool result 落盘、shell 类大输出的更大预览、过期 session 清理联动,以及相关测试覆盖。
变更内容
Tool result 落盘与替换
tool_result.content超过阈值时,完整内容落盘到本地tool-results目录。<persisted-output>标记 + 文件路径 + preview。(<toolName> completed with no output)。ContentReplacementState记录seenIds / replacements,保证 replay 时 replacement 稳定。结构化内容落盘
.json落盘。.txt落盘。shell 类大输出策略
run_command/bash/local_bash使用更大的 preview。Session 与 compact
mkdir/readLastEventUuid/appendFile/logicalParentUuid。compact_boundary查找逻辑。loadSession/loadContextCollapseState/loadContentReplacementState复用同一份活动 JSONL snapshot。loadSessionRuntimeState(),resume 时一次性恢复 messages、content replacement state 和 context collapse state。清理联动
sessionArtifactsDir,包含tool-results。clearSession()也会删除对应 artifacts。测试与校验
loadSessionRuntimeState的恢复测试。测试计划
npm run checknpm test -- --runInBand test/session.test.ts test/tool-result-storage.test.ts test/snip-compact.test.ts风险与回滚
风险
回滚
src/utils/tool-result-storage.ts中的 replacement / persistence 逻辑。src/session.ts/src/tty-app.ts中的 runtime state 合并恢复。src/session-paths.ts的路径约束与目录结构。Notes for Reviewers
src/session.ts中 read / write / resume 逻辑是否仍保持 parent 链正确。src/utils/tool-result-storage.ts中 structured content / shell preview / batch budget 的边界行为。loadSessionRuntimeState()是否真正消除了 resume 的重复扫描。tool-results产物。part of #1