[Bug]: 超窗横幅硬编码「compression.enabled: false / enable compression in config.yaml」——Studio 接管压缩时把用户引向本来就正确的地方(v0.7.24 实测,关联 #1790)

Author: Afang17Created Sep 26, 2026Updated Sep 26, 2026

版本 / 环境

项 值
Ekko Studio (npm hermes-web-ui) v0.7.24
Hermes Agent v0.21.4 (2026.9.21)
部署 Ubuntu 22.04 自托管,hermes-web-ui 常驻 + agent-bridge worker,profile default
模型 deepseek-flash(Hermes 元数据窗口 1,000,000)
~/.hermes/config.yaml compression.enabled: true、threshold: 0.9、target_ratio: 0.4、protect_last_n: 30

现象

长会话里弹出这条 warn 横幅(非致命,但会一直挂着):

⚠️ Session context (~1,000,983 tokens) exceeds the model context window (~1,000,000 tokens)
with compression disabled (compression.enabled: false). Use /compact to compress history or
enable compression in config.yaml.

用户的第一反应必然是去 config.yaml 核对「启用压缩」——而那个开关本来就是开的。这条文案在 Studio 接管压缩的前提下 100% 会误导,且完全不可操作(config 里没有任何东西可改)。

根因(三层)

1) bridge 无条件关闭 Hermes 自带压缩(设计如此,见 #1790)

dist/server/agent-bridge/python/bridge_pool.py:517:

python
agent.compression_enabled = False
self._install_compression_hook(agent, session_id)

#1790 里维护者已确认这是有意为之(由 Studio 接管压缩)。但 Hermes 侧的护栏并不知道「被 host 接管」这件事,它只看到 compression_enabled == False。

2) 横幅文案是 Hermes 里的硬编码字面量,不读 config

  • 文案:hermes-agent/agent/status_output.py:124-139(AIAgent._warn_uncompressed_context_overflow),(compression.enabled: false) 和 enable compression in config.yaml 都是 f-string 里的固定文本。
  • 触发门:hermes-agent/agent/turn_preflight.py:212-219 —— not agent.compression_enabled and request_pressure_tokens > context_compressor.context_length。

所以这条提示的字面含义(「你的 config 里压缩是关的」)与事实相反:它只是「host 把这个 flag 关了」,与 config 无关。

3) 真正的问题是 run 内没有等价的上下文安全网(与 #1790 里的分析一致)

Studio 侧压缩是 run 边界/发消息前触发的。一次长 run(大量 tool 调用)中间可以把 prompt 顶过模型窗口,此时没有任何东西会压缩,只有 Hermes 这条误导横幅作为唯一提示。

实测证据

(a) config 确实是开的(用 Hermes 自己的加载路径,不是肉眼看 YAML):

bash
$ ./venv/bin/python -c "from hermes_cli.config import load_config_readonly as L; \
    print(L()['compression']['enabled'])"
True

(b) 确实有一次请求超过了模型窗口——读 Hermes 持久化的 usage anchor(provider 实报的上一次 prompt,非估算):

bash
$ sqlite3 ~/.hermes/state.db "select model_config from sessions where id='mue7umn6eubll8'"
{"_usage_anchor": {"prompt_tokens": 1013724, "completion_tokens": 2095, "base_count": 358, ...}}
  • 会话:mue7umn6eubll8(profile default,模型 deepseek-v4-flash),读取时间 2026-09-25 23:05 CST
  • prompt_tokens = 1,013,724,而窗口是:
bash
>>> from agent.model_metadata import get_model_context_length
>>> get_model_context_length("deepseek-flash", provider="deepseek")
1000000
  • 横幅里的 1,000,983 与之同量级(锚点 + 增量估算),时间点也吻合(当晚 23:00–23:05)
  • 该会话的 transcript 里没有 overflow 报错 —— 说明 provider 实际接受了这个 1.01M 的请求,「元数据窗口 1,000,000」这个换算基准本身也偏保守,值得一并复核

(c) Studio 侧压缩本身是工作的,只是晚了一步(run 结束后才发生):

bash
$ sqlite3 ~/.hermes-web-ui/hermes-web-ui.db \
  "select session_id,last_message_index,message_count_at_time,updated_at,length(summary) \
   from chat_compression_snapshots where session_id='mue7umn6eubll8'"
mue7umn6eubll8|1427|1478|2026-09-25 23:40:05|22978
  • 23:02 横幅出现 → 23:40 才完成一次压缩(summary 22,978 chars),之后 anchor 回落到 369,641
  • 也就是说:压缩能力没问题,缺的是「run 进行中」这道闸

期望行为 / 建议

  1. bridge 侧抑制或改写这条 notice(最小改动,解决用户被误导这一半):compression_enabled = False 是 bridge 自己设的,那它应该同时把这些基于该 flag 的 Hermes notice 挡掉或替换成 Studio 自己的口径(例如「上下文接近模型窗口 → 请手动压缩 / 新开会话」)。bridge 里已有 _suppress_bridge_platform_hint() 这类「压制 Hermes 输出」的先例,实现路径是现成的。
  2. 上游协同:status_output.py 那句文案假定了「flag=False ⟺ config 里关着」,对任何 host 接管压缩的集成都是错的,建议 Hermes 上游中性化(或在 host 接管时提供静音开关)。
  3. 承接 #1790 的产品边界:如果 Studio 是 compression owner,就需要 run 内(每次 provider call 前)按实际/校准后的 request size 做一次判定,而不是只在用户发下一条消息时判。

关联

  • #1790(compression_enabled 被 bridge 覆盖 / Studio 接管压缩)——本 issue 是它的「用户可见症状」面:那条横幅会把用户引向已经正确的 config
  • #1977(固定开销 + overflow 误判)

备注

横幅只有 warn 级别、不阻塞对话,所以不是 P0;但它是唯一提示,且指向一个用户无法修复的地方,建议按误导性文案处理。

Source: EKKOLearnAI/hermes-studio