Skip to content

[Bug] Headroom 压缩标记出现在所有会话,但 headroom_retrieve 工具未注册给 cron/子代理会话,模型 20 连败 not found #101

Description

@minghaoran0910-cyber

问题描述

Headroom 上下文压缩层会把被压缩的长输出替换为 <<ccr:hash>> / [N items compressed to M. Retrieve more: hash=...] 标记,并且工具列表里附带一个 headroom_retrieve 工具用于取回原文。

headroom_retrieve 似乎只在部分会话(主 agent)中注册;子代理 / cron 会话的 transcript 里同样会出现这些压缩标记,工具却不可用。 模型看到标记里的 "Retrieve more: hash=…" 提示后会反复尝试调用,全部失败。

环境

  • OpenClaw: 2026.7.1-2-zh.1 (2d2ddc4)
  • OS: macOS (arm64), node v24
  • 多 agent 架构:主 agent + 若干 cron 子 agent(模型经本地 OpenAI-compatible 代理接入)

现象 / 证据

子 agent(一个投资日报 cron 会话)的 session jsonl 中:

  • headroom_retrieve 出现 21 次,其中 20 次对应工具返回 Tool headroom_retrieve not found
  • 模型连续重试 20 次后才放弃,最终输出:"I can't use the tool "headroom_retrieve" here because it isn't available. I need to stop retrying it and answer without that tool.",随后基于压缩摘要(而非原始数据)完成了任务
  • 同一 gateway 的主 agent 会话中 headroom_retrieve 正常注册、可调用

影响

  1. 每次 not-found 重试都消耗 token 和时延(本例 20 连败)
  2. 模型最终只能基于截断摘要作答,报告精度受损(需要原始行情数据的场景尤其明显)
  3. cron 场景每天自动发生,无人值守时是静默浪费

疑似根因

压缩标记的注入(写入 transcript / 工具结果)对所有会话生效,但 headroom_retrieve 工具的注册是按 agent 会话路径区分的——cron/子代理会话拿到了"提示",没拿到"钥匙"。

建议修复(任选其一或组合)

  1. 在会产生压缩标记的所有会话中一致注册 headroom_retrieve
  2. 当会话工具目录中不存在 headroom_retrieve 时,压缩层输出标记但去掉 "Retrieve more: hash=…" 的可调用暗示(改为"原文已不可检索")
  3. 提供配置项允许对子代理 / cron 会话关闭 headroom 压缩

本地临时缓解

已在子 agent 的 AGENTS.md 加入规则:"若工具列表没有 headroom_retrieve,看到压缩标记时禁止调用,直接重新执行原命令获取数据"。能止血,但属于 prompt 层 workaround,不保证模型服从。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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