Skip to content

feat(spill): P1.1 大输出 tool_result 补齐 tail 预览 (closes #83) - #84

Merged
dahai80 merged 1 commit into
mainfrom
feat/spill-tail-preview-p11
Aug 20, 2026
Merged

dahai80 merged 1 commit into
mainfrom
feat/spill-tail-preview-p11

Conversation

@dahai80

@dahai80 dahai80 commented Aug 20, 2026

Copy link
Copy Markdown
Owner

背景

enhance-0819.md §P1.1 Spill 策略 (DSH #8) 要 head/tail 预览 + disk locator。

审计结论: spill 机制已在 fusion-code 存在 (命名 persist 非 spill)。memory 旧记录 "grep spill=0 确实缺" 为误判 — fusion-code 用 persist 命名, grep literal CC 术语漏掉。真 gap 收窄为 tail-only 预览: generatePreview 原 head-only, spec 要 head/tail。

改动

generatePreview 截断时产 head + tail:

  • head 60% / tail 40% 预算, head 略多 (前导上下文通常更值)
  • 两者各按行边界切 (避免半行)
  • 总 head+tail 字节 ≤ 原 maxBytes → 不膨胀上下文
  • 非截断 (content ≤ maxBytes) 时 tailPreview=undefined → buildLargeToolResultMessage 旧行为 byte-identical (向后兼容)

文件

  • src/utils/toolResultStorage.ts: PersistedToolResult 加可选 tailPreview?; generatePreview 产 head+tail; buildLargeToolResultMessage 拼 head+省略标记+tail; persistToolResult 透传
  • src/tools/BashTool/BashTool.tsx: persisted-output 字面量透传 tailPreview
  • src/tools/PowerShellTool/PowerShellTool.tsx: 同 Bash
  • src/__tests__/services/tools/toolResultStoragePreview.test.ts: 新增 9 case (head+tail 不重叠/行边界/字节预算/向后兼容)

不动 (Rule 3 surgical)

  • 预算预留 selectFreshToReplace: pre-persist 减全 size, 已近似 (注释 "previews ~2K"), tail +~0.8KB 在误差内
  • Read (Infinity 跳 persist) — 故意
  • MCP spill (mcpOutputStorage.ts) — 独立路径
  • B 参数分档 (≤3B→4KB 等): 运行时无 B-param resolver, 代码按 context window 分档; 需跨仓 fusion-mlx 加 param-count 字段 → 单独 issue 延后

验证

  • bun run typecheck → 0 errors
  • bun test src/__tests__/ tests/ → 449 pass, 0 fail
  • bun run build + bun run build:dev:full → pass
  • bunx biome check → prod 文件 0 新增 lint (既有 baseline 不动); test 文件 0 error/warning
  • git diff -w 确认无 whole-file reformat churn

实益

MLX 日志工作流: 错误/stack trace 在输出尾部, 原 head-only 看不到; tail 补齐后模型直接见尾部错误 + locator 读回全文。

Closes #83

Co-Authored-By: Claude Fable 5 [email protected]

审计确认 spill 机制已存在 (persist 命名), 真 gap = tail-only 预览。
generatePreview 原 head-only, spec §P1.1 要 head/tail。截断时产
head(60%)+tail(40%), 按行边界切, 总字节 ≤ 原 budget, 不膨胀上下文。
非截断时 tailPreview=undefined, buildLargeToolResultMessage 旧行为
byte-identical (向后兼容)。

- toolResultStorage.ts: PersistedToolResult 加 tailPreview?;
  generatePreview 产 head+tail; buildLargeToolResultMessage 拼 head+省略+tail;
  persistToolResult 透传 tailPreview
- BashTool/PowerShellTool: persisted-output 字面量透传 tailPreview
- 新增 toolResultStoragePreview.test.ts (9 case)

typecheck 0; 449 test pass; build + build:dev:full pass。

Closes #83

Co-Authored-By: Claude Fable 5 <[email protected]>
@dahai80
dahai80 merged commit 0edbc1f into main Aug 20, 2026
1 check passed
@dahai80
dahai80 deleted the feat/spill-tail-preview-p11 branch August 20, 2026 12:02
dahai80 added a commit that referenced this pull request Aug 20, 2026
追 CC 2.1.196→2.1.234 Tier-1 特性批量落地 (13 PR):

变更自 v0.4.22:
- WS1 DirectoryAdded hook + Notification agent_* 类型 (#73)
- WS2 堆叠 slash-skill 调用, 最多 5 前导 (#74)
- LSP+filecache 内存泄漏 cap, 对齐 CC 2.1.208 (#76)
- skill body-defer 懒加载, item 9 (#78)
- SessionStart source "fork" 区分 fork 与 resume (#80)
- P2.1 子代理护栏 — 并发/会话/深度三限 (#82)
- P1.1 大输出 tool_result tail 预览 (#84)
- P4.1 --ax-screen-reader 入口点对齐 — env 别名 + settings key (#86)
- item 13 WebSearch per-session 搜索次数上限 (#88)
- P4.2 §6 /doctor FUSION_* vs ANTHROPIC_* 环境变量冲突检测 (#90)
- P4.2 #1+#3 /doctor MLX 网关连通 + 模型加载探测 (#92)
- item 4 MCP 工具自动后台化 FUSION_MCP_AUTO_BACKGROUND_MS (#94)
- item 22 审计日志凭证脱敏 (#96)

- package.json: version 0.4.22 → 0.4.23

Co-authored-by: Claude Fable 5 <[email protected]>
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.

P1.1 Spill — tail 预览补齐 (persist 机制审计, 真 gap=tail-only)

1 participant