feat(context/runtime): 落地 Compact M1(micro/manual + transcript 持久化)并补齐配置、事件、TUI 与测试#127
Closed
wynxing wants to merge 5 commits into
Closed
feat(context/runtime): 落地 Compact M1(micro/manual + transcript 持久化)并补齐配置、事件、TUI 与测试#127wynxing wants to merge 5 commits into
wynxing wants to merge 5 commits into
Conversation
- Runtime 层新增 Run/Compact 串行互斥,避免并发写会话冲突\n- TUI 层新增 compact busy 状态,阻止 compact 期间重复触发发送/新会话\n- compact summary 截断改为按 rune 计数,避免中文多字节字符被截断\n- 清理乱码注释并为 internal/context(含 compact)补充中文 UTF-8 注释\n- 补充回归测试:UTF-8 截断、Run/Compact 串行化、TUI busy 状态
- 新增 context.compact 配置结构、默认值、校验与克隆逻辑\n- 支持 compact 配置的 YAML 持久化与兼容加载(含 micro_enabled 缺省回退)\n- 补充 compact 配置相关单元测试与 round-trip 验证\n- 扩展 runtime compact 事件类型与触发模式常量\n- 忽略 compact transcript 目录,避免本地产物入库
- 新增 my-changes.patch 作为迁移与回溯参考\n- 与功能代码提交解耦,便于后续审阅与维护
- compact 阈值与字符统计统一改为 rune 语义,避免中文按字节误判\n- discoverRuleFilesWithFinder 遇到目录读取错误时改为显式返回错误\n- 补充与更新对应测试用例,覆盖 rune 阈值/字符统计及错误传播行为
新增 manual 后继续 tool 回合与 manual+micro 组合集成测试;同步 README、配置指南与事件流文档中的 compact 说明。
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
minorcell
added a commit
that referenced
this pull request
Apr 4, 2026
feat(context/runtime): 落地 manual compact(拆分自 #127)并补齐配置、TUI、事件与测试
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 在
up/main基础上落地 Compact M1 能力,并补齐配置、事件、TUI 入口与测试覆盖。主要改动
internal/context/compact)Run(mode, input),覆盖micro与manual两种模式micro compact:仅替换“超出保留窗口且超阈值”的旧 tool result,占位符为[Previous tool used: <tool_name>]manual compact:支持keep_recent/full_replace策略,按 span 保护assistant(tool_calls)+tool_result边界transcript_id/transcript_pathdone或in_progress,并遵循max_summary_chars限制internal/runtime)micro compactCompact(...)入口并回写 sessioninternal/config)context.compact.*配置项与默认值/校验/加载持久化:micro_enabledtool_result_keep_recenttool_result_placeholder_min_charsmanual_strategymanual_keep_recent_spansmax_summary_charsinternal/tui)/compact命令/compact与 compact 机制说明docs/guides/configuration.md补充 compact 配置字段与/compact说明docs/runtime-provider-event-flow.md补充 compact 事件、命令链路与指标字段测试与验证
/compact命令与状态分支go test ./...close #120