你的姓名 b0f368ef97 fix(compact): stop re-compaction thrash and post-compact 100% context meter
Two context-management fixes (CLI/sidecar side):

1. Re-compaction loop (方案1+2). Auto-compaction previously only circuit-broke
   on hard failures; a compaction that succeeded but left context still over
   threshold reset the failure counter and re-compacted every turn, burning a
   summary API call each time.
   - autoCompact.ts: isIneffectiveCompaction() — when truePostCompactTokenCount
     is still >= threshold, count it toward the existing circuit breaker instead
     of resetting to 0; query.ts now honours that count on the success path.
   - shouldThrottleAutoCompact() — suppress proactive autocompaction for a few
     turns after a compaction, unless at the hard blocking limit (so we never
     risk prompt-too-long by throttling).

2. Post-compact context meter stuck at ~100% (sessionService.ts). The transcript
   context estimate counted the entire pre-compact history plus the summarization
   call's huge input_tokens, pinning the indicator near full until the next turn.
   Now the estimate is scoped to messages after the latest compact_boundary, with
   a model fallback for the just-compacted/no-new-turn case. Non-compacted
   sessions are unchanged.

Tested:
- bun test src/services/compact/autoCompact.test.ts (12 pass; throttle + ineffective predicates)
- bun test src/server/__tests__/conversations.test.ts -t "context" (6 pass incl. new compact-boundary scoping case)
Not-tested: 4 pre-existing WebSocket runtime-restart integration tests fail in this env (CLI subprocess code 143); unrelated to these changes.
Confidence: high
Scope-risk: moderate
2026-06-09 13:48:40 +08:00

3.2 KiB
Raw Blame History

v0.5.5

新增

  • 更多内置 Agent。在 test-author / code-reviewer 之外,新增 debugger、security-reviewer、 refactor、migration、docs-writer、performance、commit-pr 等专职内置 Agent覆盖调试、安全审查、 重构、迁移、文档、性能和提交/PR 等常见工作流。项目级 game-developer Agent.claude/agents/ 覆盖 Unity/Unreal/Godot 与 Web 引擎,强制按已装引擎版本核对 API、优先查真实符号、API 不确定时查官方文档。
  • 编辑框 + 菜单新增"技能 / 插件"入口。点击后在编辑框上方弹出选择菜单(↑↓ 导航、Enter 选中、 Esc 关闭),选中即在光标处插入 @skill:<name> / @plugin:<name>,告诉 Agent 使用该技能/插件。

修复

  • AskUserQuestion 弹窗不再无声消失。当 AI 的提问卡片因回合结束(message_complete / error 被清空且用户未作答时(常见于模型发出残缺的问题调用),聊天里会留下一条可见记录,而不是一闪而过。
  • "立即发送"不再打断当前回合。队列里的"立即发送"改为直接发送该条消息,移除了之前强制 stop_generation 造成的 Request was abortedcode 143 重试循环。
  • "跟随系统"主题持久化。重启后不再被服务端保存的具体主题覆盖,本地选择的 system 会被尊重。
  • Read 工具空 pages 容错pages: "" 视为读全文件,避免模型传空字符串触发的反复校验报错。
  • Fork 化指向。仓库链接、检查更新源electron-updater publish + Tauri 端点)改为指向本 fork 706412584/cc-haha;设置→关于 新增"Fork 维护者"署名706412584原作者 NanmiCoder 署名与社交链接保留。
  • 修复上下文压缩抖动/死循环。此前自动压缩只对"压缩失败"做熔断,"压缩成功但结果仍超阈值"会被 当成成功并清零失败计数,导致每隔几句话就再压一次、空烧摘要 API。现在(方案1) 压缩后若仍超阈值 记为"无效压缩"并计入熔断,连续若干次后停止自动压缩;(方案2) 一次压缩后的若干轮内不再主动压缩 (触及硬阻塞上限时除外,避免 prompt-too-long
  • 修复压缩后上下文进度卡 100%。设置/编辑框的上下文进度在压缩完成后会停在 ~100% 不回落,直到 下一轮对话。根因是 transcript 估算路径未切到压缩边界之后(把压缩前全部消息 + 摘要调用的巨大 input 都算进去)。现在估算只统计最近一次压缩边界之后的消息,压缩完成即正确回落。

范围

  • 桌面端:desktop/src/stores/chatStore.tssettingsStore.tscomponents/chat/ChatInput.tsx、 新增 components/chat/SkillPickerMenu.tsx、5 个 i18n locale。
  • CLI/sidecarsrc/tools/AgentTool/(新增内置 Agent + 注册)、src/tools/FileReadTool/FileReadTool.ts
  • 持久化 schema 未改动。

验证

  • cd desktop && bun run linttsc --noEmit
  • desktop VitestchatStore 99 passed含 AskUserQuestion 丢弃提示、立即发送、队列用例)
  • bun test src/tools/AgentTool/builtInAgents.test.ts(内置 Agent 注册)
  • 本地 Windows x64 NSIS 打包 + package-smoke