Skip to content

[business-logic] preExecuteReadOnlyTools runs the whole batch's read-only calls BEFORE the sequential loop, but the mutation-invalidation family (speculator/memo/commandCache) has no counterpart for the preExecuted map - an [edit_file X, read_file X] verification batch hands the model pre-edit content with no snapshot annotation, provoking duplicate edits; output_compress layer-2 folds any 5 lines sharing a 10-char prefix (i.e. same directory) into 2+1+marker, deterministically discarding unique grep matches in violation of its own preserves-all-unique-information header contract, with no error exemption and no recovery advisory unlike the size guard; the pre-executed path never runs user hooks (PreToolUse veto fires after I/O already happened); overseer's readOnlyTools table is missing 13 real read-only tools so allReadOnly stall detection systematically under-fires #1475

Description

@topcheer

文件行号

internal/agent/parallel_tools.go L94(判定条件仅 speculativeSafeTools——不检查批内是否含写工具)+ L223-237(usePreExecutedWithPermission 直接返回 pre.result 无陈旧标注——对照 memo 命中路径 agent.go:3046-3048 有 "[cached...]" 前缀)+ L171-237(无任何 hook 调用;grep 实证 RunPreHooks/RunPostHooks 在 internal/agent/ 仅 agent_tool.go 5 处);agent.go L2885(preExecuted 创建——全文件仅 2 处出现:2885 创建/3053 读取,零失效路径)vs L3099-3117(写工具失效清 speculator/memo/commandCache 却漏掉 preExecuted);internal/agent/output_compress.go L30/L35(prefixSimilarThreshold=5/minPrefixLen=10)+ L70-96(keep first 2+last 1+marker)+ L18 契约 "preserves all unique information — only redundancy is collapsed";agent.go:4097-4100(压缩接线无 !IsError 豁免、无 advisory——对照 L4106 size guard 有门控+L4112 truncation advisory);internal/agent/overseer.go L114-136(readOnlyTools 22 项)vs L344-350(allReadOnly 要求全部在表内)

问题

案 A(High,核心机制·陈旧读):preExecuted 预执行结果不随批内 mutation 失效——[edit_file X, read_file X] 验证性读返回编辑前内容且无标注

  • 预执行在顺序循环之前并发执行批内全部 speculativeSafeTools(含 read_file);循环内写工具执行后失效 speculator/memo/commandCache 三个缓存——preExecuted 局部 map 完全不在失效范围
  • 消费序:idx=0 edit 成功失效三缓存 → idx=1 memo/speculator 未命中(本批首次)→ preExecuted[1] 命中返回编辑前内容且无任何标注 → 模型误判编辑失败 → 重复编辑(old_text 不匹配失败或双改)
  • 同理影响 [run_command "gofmt -w X", grep ...];batch_coupling 警告与陈旧结果互相矛盾(警告说有依赖、结果却假装新鲜)
    :批含 mutatesSourceTree/mutating run_command 时跳过对同文件(保守:全部)预执行;或对写工具之后消费的 pre-executed 结果追加 snapshot 标注。

案 B(Med-High,探针实证·确定性丢数据):output_compress 层 2 折叠把"同目录"误判为"冗余"——唯一信息行永久丢失

  • 10 字符公共前缀(项目路径天然满足 internal/agent//Volumes/n)+ ≥5 行即折叠 keep 2+1+marker——探针实证:6 行 grep files_with_matches 输出折叠后 3 个不同文件名(唯一信息)被确定性丢弃,重跑同样折叠、无恢复手段
  • 直接违背 L18 头部契约 "preserves all unique information";接线处无 !IsError 豁免(关键错误输出同样被吞中间行)且无 truncation advisory 类恢复指引——对照 size guard 两者都有
    :层 2 要求公共前缀后高度同质(如去路径尾部后全等);或折叠加 advisory+原文留存。

案 C(Med,契约不一致·非确定性合规):预执行路径完全绕过用户 hooks——PreToolUse 否决权失效、PostToolUse 审计/脱敏静默缺失

  • 顺序路径 agent_tool.go:379-382 有 RunPreHooks(!Allowed 可否决)+4 处 RunPostHooks;预执行路径零 hook 调用
  • speculativeSafeTools 含 read_file/git_show——可读 .env/任意历史版本(含曾提交的 secret);用户 PreToolUse hook 阻止敏感路径时 I/O 已发生、内容已返回模型;PostToolUse hook 侧脱敏/审计按"工具是否恰好落并行批"而异——非确定性合规执行
  • 缓解:内置 redactSecrets(agent.go:3076)对预执行结果生效、permission policy 未绕过
    :usePreExecutedWithPermission 中镜像调用 RunPreHooks(!Allowed 丢弃结果——与 permission deny 语义一致)/RunPostHooks。

案 D(Med-Low,漏报·有兜底):overseer readOnlyTools 表与真实工具集脱节——stall 检测系统性欠触发

  • 表 22 项缺失 code_search/lsp 六件(workspace_symbols/implementation/code_actions/incoming/outgoing/prepare_call_hierarchy)/debug_log/runtime/task_list/task_get/code_health/ci_status——这些在其他启发式表中活跃使用(unverified_claim.go:60/tool_result_redundancy.go:78/adaptive_effort.go:77)且均在系统提示词清单
  • allReadOnly 要求全部在表内——混入任一未列即 false → stallThreshold=15 永不触发;兜底:spam>6 与 drift=20(晚 5 次且文案错位);researchProductiveTools 含 code_search 却不在 readOnly 表——多表维护不同步
    :readOnlyTools/speculativeSafeTools/researchProductiveTools 收敛为单一共享来源或加同步测试。

干净项

output_compress 层 1 exact-dup 无损/marker 歧义防护/5000 行放行;overcorrection_cascade #1170/#27/#278 在位(lint 成功输出立 trivial 锚点误报为 Low 附注);overseer research mode 阈值放宽/error escalation 下限自洽;panic_safety #239/#142 在位(safego.Recover 限定名不识别与行偏移复燃为 Low 潜伏附注);parallel_tools memo/speculator 预检查/权限语义对齐/#1281/wg 回填顺序/批上限 3/context 节流均无问题。

严重程度

High + Med-High + Med + Med-Low


独立复核确认:preExecuted 全文件 2 处出现 grep 实证、消费序推演、探针测试实证丢行(324→185 字节/3 文件名丢失)、RunPreHooks 调用点对照 grep、speculativeSafeTools 全清单、readOnlyTools 缺失工具逐一 grep、drift/spam 兜底机制定位。四案共享模式:并行/缓存优化路径未完整镜像顺序路径的安全契约 + 机械启发式误伤语义唯一信息。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions