Skip to content

[Bug][omp] OMP ≥ 18.18 sends Claude turns as Anthropic message threads → bili omp and the omp native lane never compress (fix: PI_ANTHROPIC_MESSAGE_THREADS=0) | OMP 18.18 起 Claude 走 message threads,每轮只发最新一条 → bili omp 不压缩 #6088

Open

Description

@qiangu2020

(ai: anthropic/claude-opus-5-5)

Description

Since OMP (oh-my-pi) 18.18, Claude requests to the official endpoint use Anthropic message threads (beta message-threads-2026-08-12). After the first turn each request carries only the newest message(s); Anthropic keeps the rest server-side. bili therefore never sees the conversation: each turn arrives as a 1–2 message request, is forked into a |sub: session, and nothing is ever folded. There is no error anywhere; the session just never compresses.

OMP decides this per request in packages/ai/src/providers/anthropic-threads.ts (wantsAnthropicThreads): a caller's statefulResponses wins, otherwise PI_ANTHROPIC_MESSAGE_THREADS, otherwise the model policy, which applies only when the base URL is the official one. bili omp routes Claude through PI_PROXY_ANTHROPIC (src/launcher.ts, omp branch, env.PI_PROXY_ANTHROPIC = origin), so the model's base URL stays official and threads stay on. Nothing in bili sets PI_ANTHROPIC_MESSAGE_THREADS (code search finds no hits on master).

Repro. One omp -p session with three one-word turns, model claude-opus-5-5 (subscription login), Claude routed to a running bili via PI_PROXY_ANTHROPIC=http://127.0.0.1:<port>:

run bili session requests messages in the bili session |sub: forks
OMP default (threads on) 01a1c38f-aa16-… 1 2 2
PI_ANTHROPIC_MESSAGE_THREADS=0 01a1c38f-cdc6-… 3 6 0

The stock launcher showed the same on 2026-11-09: bili omp 0.1.213 with OMP 18.18.3 logged request: 1 msgs on turn 2 by default, and request: 3 msgs (cache hit 99%) with PI_ANTHROPIC_MESSAGE_THREADS=0.

With the variable set, long OMP sessions compress normally again, and OMP subagents (run in-process) also arrive with their full history: a probe with one main session and three subagents produced four bili sessions with full history each and no |sub: forks.

Suggested fix

  1. Launcher: in the omp branch, next to env.PI_PROXY_ANTHROPIC = origin, set env.PI_ANTHROPIC_MESSAGE_THREADS = "0" when the user has not set it. An explicit user value still wins.
  2. Native lane (extension only, no launcher): OMP reads the variable at request time ($env is Bun.env), so agent/omp.js / omp-native.js could set process.env.PI_ANTHROPIC_MESSAGE_THREADS ??= "0" on load. Untested.
  3. Diagnostics: a request carrying the message-threads-2026-08-12 beta could log one clear warning, e.g. "OMP message threads are on; bili cannot compress this session; set PI_ANTHROPIC_MESSAGE_THREADS=0".

Related: #3744 (threads on Claude Desktop). For OMP there is a simple client-side switch, so it does not need a threads lane.

bili version

0.1.213. The 2026-11-09 run was stock 0.1.213. The 2026-11-10 run used 0.1.213 with two local patches that do not touch this path: the #5441 port for #5432, and a host-transport lane that stays inactive on stock OMP.

Usage mode

Launcher (bili omp), and Plugin native (omp-native extension plus PI_PROXY_ANTHROPIC pointing at one resident proxy).

Client and version

oh-my-pi omp 18.18.3 and 18.18.6

OS

Linux x64 (CachyOS)

Upstream and model

api.anthropic.com, claude-opus-5-5, subscription (OAuth) login


中文摘要:OMP 18.18 起,发往官方地址的 Claude 请求默认走 Anthropic message threads,每轮只发最新一条消息,bili 拿不到完整对话,所以不压缩,也不报错。bili omp 只设置了 PI_PROXY_ANTHROPIC,模型地址仍是官方地址,threads 照开。设置 PI_ANTHROPIC_MESSAGE_THREADS=0 后恢复:3 轮 3 个请求、6 条消息、0 个 |sub: 分叉。建议 launcher 在用户未设置时默认设为 0,扩展加载时也补上。

Activity

  1. ranxianglei commented on Nov 10, 2026

    @ranxianglei
    Owner

    🤖 Powered by ework · qwen3.8-27b

    (ai: vllm-qwen/qwen3.8-27b)

    查重:不重复。 open+closed 全量检索 PI_ANTHROPIC_MESSAGE_THREADS / message threads 无其他条目。最接近的是 #3744(Claude Desktop 内嵌 CC 的 threads 问题),但那是不同客户端(Claude Desktop vs OMP)+ 不同机制(bili 服务端 reforge lane vs OMP 客户端开关),且本 issue 明确说明 OMP 有客户端开关、不需要 threads lane。同家族但不同客户端/不同机制,单独处理。

    标签:bug, omp, scope/wiring, p1(核心承诺「压缩」静默失灵 → p1)。

    审核结论(审核先于实现):

    1. 复现/查证 — 已在 master 代码上验证机制链成立:
      • src/launcher.ts omp 分支只做 PI_PROXY_ANTHROPIC = origin 的 gap-fill([Bug] Anthropic requests leak prompt_cache_key when Cowork transport bypasses native fetch interception #2583),从不设置 PI_ANTHROPIC_MESSAGE_THREADS;全仓 grep PI_ANTHROPIC_MESSAGE_THREADS / message-threads-2026 零命中,确认 bili 侧无任何默认值或诊断。
      • OMP 的 wantsAnthropicThreads 回落到 model policy 时,base URL 是官方地址即开 threads;bili omp 只改代理不改模型 baseUrl,所以 threads 保持开启 → 每轮只带最新消息 → bili 永远看不到完整对话 → 不压缩,还分叉出 |sub: 会话。与 issue 描述完全一致。
    2. 层次判断 — 根因是客户端传输模式变更(Anthropic message threads 把历史留在上游服务端),不是 bili 压缩引擎缺陷;「会话从不压缩」是表面现象。去修压缩引擎是错层堵漏;正确修法是让 bili 拉起的 OMP 关闭 message threads(每轮发全量历史,bili 恢复可见性),外加服务端诊断让这种状态不再静默。
    3. 方案评估 — issue 的三部分建议都打到了核心,全部采纳,落地细节:
      • Launcher(src/launcher.ts omp 分支):在 PI_PROXY_ANTHROPIC gap-fill 之后补 PI_ANTHROPIC_MESSAGE_THREADS="0" 的 gap-fill(空白=未设置;用户显式值优先)——与 OMP native: preflight SSE comments do not reset 300s first-event timeout (Working → aborted) #1774 first-event timeout 的既有 stamp 风格一致。
      • Native lane(src/agent/omp-native.ts 模块求值块):在既有 gate(NODE_TEST_CONTEXT undefined && ompTrafficRidesBili)下、applyOmpFirstEventTimeout 旁补同样的 ??="0"。OMP 在请求时读 env,加载时写即可覆盖扩展模式。
      • 诊断(src/server/handle.ts + context-window.ts 新 helper):anthropic 请求携带 message-threads* beta 头时,按会话(分叉前 id)各告警一次——避免 |sub: fork 刷屏;日志说明上游持有历史、bili 无法压缩该会话、建议设 PI_ANTHROPIC_MESSAGE_THREADS=0。

    行为变更披露(按政策):旧行为 = 继承环境(未设置时 OMP ≥18.18 对官方地址 Claude 默认开 threads → 永不压缩);新行为 = launcher/native 车道默认 "0"(每轮全量历史,压缩恢复),用户显式值(含空白=未设置约定)一律优先。这是恢复 18.18 之前的语义,属修复而非漂移,仍按政策披露。

    下一步:实现 + 定向测试(launcher env 断言、omp-native stamp 幂等、beta 检测 helper 双向)+ PR。

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions