Skip to content

[PR] pi/opencode inline changed to manual opt-in: revert the default flip; default behavior is identical to the previous vers | pi/opencode inline 改为手动开启:收回默认翻转,默认行为与旧版完全一致 - #4687

Merged
ranxianglei merged 3 commits into
masterfrom
2026-10-25_opencode-inline
Oct 25, 2026

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

这是干嘛的

本 PR 干两件事:

  1. opencode 新增 inline 模式(压缩引擎跑在 opencode 进程内,不 spawn 独立 proxy)——和 pi 的 inline 同构,手动开启
  2. 收回 pi 的默认翻转([PR] pi inline full rollout: fixed real-device stream drops + default to in-process engine (previously scattered across unmer | pi inline 全套落地:修好真机断流 + 默认走进程内引擎(之前散在未合并的 #4527/#4571 里) #4669 曾把 pi 默认改成 inline)——按 owner 规则"不改默认值",pi 默认恢复为旧行为(attach/spawn),inline 同样只手动开

现在的统一规则(pi 和 opencode 一致)

  • 什么都不配 = 和 inline 出现之前完全一样:有 server 在跑就 attach,没有就 spawn 一个 proxy
  • 只有显式开启才走 inline:
    • BILI_PI_INLINE=1 / BILI_OPENCODE_INLINE=1(on/yes/TRUE 也行)
    • 配置 {"pi":{"inline":true}} / {"opencode":{"inline":true}}
    • 一键车道:bili pi-inline / bili opencode-inline(预置环境变量)
  • 显式开启压过 attach 目标;kill-switch、/bili/ rewrite 优先级不变

关键改动

  • planNativePi/planNativeOpencode:显式 inline > attach > spawn(默认 spawn,无默认翻转)
  • opencode arm 分支镜像 pi-native:inline origin 同步冻结、引擎 singleFlight、origin waiter、onGiveUp 清理
  • opencode 模块加载时先装 inline transport 再装 native fetch 拦截(移植 billion-context-pi 版本的非 server 模式 #3278 链序;DSH0.1.7-rc.2中billion-context与dsh-codex-subscription的冲突? #1662 的 chainHop 修复保证改写后的请求能落进引擎)
  • launcher 新增 opencode-inline 车道:插件入口用 dist/agent/opencode-native.js(原生插件,不是 wire 薄插件 opencode.js),OPENCODE_CONFIG 克隆注入,清掉继承的代理 env
  • 文档种子 + LIFECYCLE.md:BILI_PI_INLINE/BILI_OPENCODE_INLINE 均改回 opt-in 表述

测试

  • 单测 441/441 绿(pi-native 19、pi-inline-ws 4、opencode-native 62、launcher 家族 356),tsc 0 错误;两套 plan 矩阵都钉死 {}→spawn(默认不翻转)
  • 实机验证:裸 import(无任何变量)按旧默认走 spawn;显式开变量走 inline——opencode 1.14.47+bun 假上游全链路(模型请求过引擎、盖 plugin 章、4 秒 exit 0)
  • bun 无 node:sqlite:存储驱动自动降级,不炸(已单独探针验证)

#3278 port)

- planNativeOpencode(env, fileInline): explicit inline (BILI_OPENCODE_INLINE on | config opencode.inline=true) > attach > DEFAULT inline > spawn (explicit opt-out only)
- arm inline branch mirrors pi-native: INLINE_ORIGIN frozen sync, engine respawn singleFlight, origin waiter, onGiveUp cleanup
- module-load installs inline transport BEFORE native intercept (#3278 chain order, #1662 hop-fixed)
- launcher: bili opencode-inline (OPENCODE_CONFIG clone + plugin dist/agent/opencode-native.js, BILI_OPENCODE_INLINE=1, inherited proxy env stripped)
- config docs seeds + LIFECYCLE.md rows (BILI_OPENCODE_INLINE default on)
- tests: plan matrix, arm freeze, fetch-chain + V2 route composition, launcher lane (2/2)

Verified on opencode 1.14.47 (bun 1.3.14): fake-upstream run through the in-process engine, session stamped plugin=opencode, exit 0 in 4s.
@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-25_opencode-inline (4ffb76d)

Latest build — install this exact version

npm install -g billion-context@0.0.5752-pr.4687.228d9d9

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Recent builds (commit → version)

commit version build
4ffb76d billion-context@0.0.5752-pr.4687.228d9d9 build
fd50e76 billion-context@0.0.5748-pr.4687.6e3275c build
2a7d6a9 billion-context@0.0.5723-pr.4687.8f79ca7 build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr4687.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title opencode inline 模式:模型流量不再起独立 server,压缩在 opencode 进程内完成 [PR] opencode inline mode: model traffic no longer spawns a standalone server; compression is handled within the opencode pro | opencode inline 模式:模型流量不再起独立 server,压缩在 opencode 进程内完成 Oct 25, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重: 不重复 —— open+closed 全量检索 "opencode inline" / "inline mode" 仅命中本 PR;与 #4669(pi inline 默认翻转)相关但不同:#4669 是 pi 侧、已合入,本 PR 是其 opencode 侧后续,无并行在途的同类 PR。

标签: opencode + scope/wiring + p2(opencode 客户端接入层/请求路由改动;默认行为翻转影响全部 opencode 插件用户,有显式退回路径,定 p2)。

当前状态:开始 review。已知事实——

  • 分支 2026-10-25_opencode-inline 落后 master 2 个提交([PR] align master with v0.1.207 (shipped from bugfix-v0.1.206) #4673 merge + release v0.1.207),无冲突面(版本行 vs 本 PR 文件不重叠);
  • CI:static-gates 与全部 guard job(kernel/config-surface/lane/version/docs…)绿,test 分片多个红(ubuntu 22/24 与 windows 22 各若干 shard),master 本身全绿 → 非继承性失败,正在定位失败用例是本 PR 引入还是 flaky。

详细结论(八问体例)随后补。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Review 结论(八问)

  1. 是什么问题:功能移植——opencode 车道采用 pi 已有的 inline 模式(移植 billion-context-pi 版本的非 server 模式 #3278 机制):压缩引擎跑在 opencode 宿主进程内,不再为每个宿主 spawn 独立 proxy server;默认 inline,可显式退回。
  2. 什么原因导致的(动机):非缺陷。pi 车道 [PR] bili pi-inline: Enter the in-process engine with a single command (no proxy spawned, includes WS bridge) | bili pi-inline:一条命令进入 in-process 引擎(不起 proxy,含 WS 桥) #4571/[PR] pi inline full rollout: fixed real-device stream drops + default to in-process engine (previously scattered across unmer | pi inline 全套落地:修好真机断流 + 默认走进程内引擎(之前散在未合并的 #4527/#4571 里) #4669 已默认翻 inline,opencode 还停留在「每宿主起一个 proxy 进程 + 临时端口」的老架构;本 PR 把同一机制移植过来补齐。
  3. 影响范围与严重程度:全部 opencode 插件用户的默认行为翻转(spawn → inline)。有完整退回路径("opencode": {"inline": false} 或 BILI_OPENCODE_INLINE=0/false/no/off);attach 姿态保留(announce 的 attach 目标压过默认值、显式 inline 压过 attach);kill-switch 不变。属行为变更而非缺陷,风险面 = 进程内引擎在 opencode/bun 宿主的稳定性(作者已真机验 opencode 1.14.47 + bun 1.3.14;bun 无 node:sqlite 时存储降级不炸)。
  4. 怎么修复的(机制):
    • planNativeOpencode(env, fileInline) 决策序:kill-switch > /bili/ rewrite > 显式 inline(env on 或 file true)> attach > 默认 inline > spawn(仅显式关)。与 planNativePi 逐行同构(env 解析、空串=off、garbage=inline presence choice 一致),模块加载处 loadConfigFile().opencode?.inline 取 file 值——loadConfigFile 对坏 JSON 是 catch+log+返回 {},不会炸插件加载(pi-native 同款已在产)。
    • arm inline 分支镜像 pi-native:INLINE_ORIGIN 同步冻结(V1/V2 origin 解析不等不存在的端口)、进程内钉 BILLION_CONTEXT_PROXY 且 onGiveUp 清理、引擎 singleFlight、生产 fail-fast/测试 lazy。pi 侧独有的 state.wsOrigin(codex WS 桥)此处正确省略——opencode 无该车道。
    • 链序:模块加载时 inline 模式先 installInlineTransport()(最内层)再 installNativeFetchIntercept();intercept 幂等(flag-guarded,V1 server() 里后到的安装调用返回 false 不二次包裹);attach/spawn 路径的安装时机不变(仍在 server()),零行为漂移。V2 route 把模型 URL 改写成 ${INLINE_ORIGIN}/bili/<upstream>,host fetch 穿链后被 inline 环节进程内接住;引擎挂掉时模型流量降级直连(一次性 warn)、管理 URL 大声失败——继承 pi-inline transport 语义。
    • launcher bili opencode-inline:剥掉继承的 proxy/MITM env(残留 BILLION_CONTEXT_PROXY 会把子进程翻成 attach)、置 BILI_OPENCODE_INLINE=1、OPENCODE_CONFIG 克隆注入原生插件入口 dist/agent/opencode-native.js(2.x 目录包装器)、dist 缺失 exit 2 大声拒绝(inline 无 wire 兜底,静默直通 = 整会话不压缩)。
  5. 是否有回归问题:审过的既有行为逐项——① kill-switch 与 BILI_PROVIDER_REWRITES stand-down 不变(决策序最前,测试钉住);② attach 语义保留(preset/ATTACH 仍附着;garbage preset 从 fallback-spawn 变为 fallback-inline,是默认翻转的直接推论,测试注释已披露);③ spawn/attach 代码路径逐字节未动(新增分支 + 模块级安装块仅在 mode==="inline" 生效);④ V1 fetch patch 双装疑虑已排除(幂等守卫读源码确认);⑤ pi 车道零改动,跨车道复用 host-agnostic 的 installInlineTransport(注释已说明理由);launcher 常量追加为纯增量。本地定向套件全绿:opencode-native(含全部新用例)、launcher-opencode-inline、launcher-pi-inline、pi-inline、launcher、opencode-v2、opencode-native-v1,0 失败。全量判定在 CI,当前被 master 继承红挡住(见下)。
  6. 是否破坏缓存:不涉及——管线是同一个 startServer handle 路径原样搬进程内,只改路由不改字节;缓存/重试/游标/去重机制零触碰。
  7. 是否改了设计方向:不涉及——移植 billion-context-pi 版本的非 server 模式 #3278 既有设计的同构扩展(pi 车道即先例),无架构转向。
  8. 是否引入了新的配置:有——BILI_OPENCODE_INLINE(env,默认 on)+ opencode.inline(file 键,默认 true),解析序 env > file > 默认 on;LIFECYCLE.md 登记 + CONFIGURATION en/zh + website yaml 种子齐全(config-surface-guard/lifecycle-ledger-guard/docs-sync 全绿)。⚠️ 唯一缺口:PR 正文缺 AGENTS.md「Configuration Surface Discipline」要求的 config surface 小节(新字段为何现有表面表达不了、对照了哪些既有机制)——台账登记齐了,人读的理由段没写;内容其实一句话就够:完全对齐既有 pi.inline 姊妹字段(同解析序/同语义),无新形状。建议补一段后再合,或我代拟文本贴进 PR 描述。

CI 状态(合并前唯一卡点):head 上 7/11 test 分片红,但这是继承性失败——master 自身红(tip ac844fa run failure;本 PR base d1b46fc 的 push run 同样 6/11 红,已知家族见 #4599 floor 151/152:plugin-fork/storage-engine-proofs/refLedgerAligned/generation-boundary 分片噪声)。5 个红分片与 base 红完全重合,其余是新增测试文件触发 LPT 重排换片;ci-fixes 当前是 master tip 的祖先,无可合修复。已在 #4599 留核对结论。分支落后 master 2 提交(#4673 版本对齐 + v0.1.207 bump),与本 PR 文件零冲突面,rebase 与否不影响结论。

行为变更披露(Deliverables #4):opencode 车道默认 spawn → inline(旧:每宿主起 proxy server;新:进程内引擎,不起 server)。原因:对齐 pi 车道 #4669 的决定,消除临时端口/proxy 进程依赖。发版时建议进 release notes。

判定:代码层面 PASS——方向正确、与 pi 车道严格同构、测试是真行为断言(组合链实测落引擎、敌意 env 剥离、dist 缺失拒绝,断言有牙)、文档台账齐。合并等 master CI 转绿(哨兵 #4599 域内事项)+ 补 config surface 小节后即可;无需返工。

Owner decision on #4687: do not flip the opencode default. inline arms only
on BILI_OPENCODE_INLINE=1/on/yes/TRUE or {"opencode":{"inline":true}};
unset behaves exactly as before (attach > spawn). Explicit inline still
beats an announced attach target. Seeds/docs/LIFECYCLE updated accordingly;
plan matrix re-flipped ({}→spawn), lane test unchanged (sets the env).
@ranxianglei ranxianglei changed the title [PR] opencode inline mode: model traffic no longer spawns a standalone server; compression is handled within the opencode pro | opencode inline 模式:模型流量不再起独立 server,压缩在 opencode 进程内完成 opencode inline 模式(手动开启):压缩在 opencode 进程内完成,不起独立 server Oct 25, 2026
@ranxianglei ranxianglei changed the title opencode inline 模式(手动开启):压缩在 opencode 进程内完成,不起独立 server [PR] opencode inline mode (manually enabled): compression is performed within the opencode process; no standalone server is s | opencode inline 模式(手动开启):压缩在 opencode 进程内完成,不起独立 server Oct 25, 2026
Owner rule (never change defaults): plain  with no signals plans the
spawned proxy again, exactly as before #4669. Inline arms only on
BILI_PI_INLINE=1/on/yes/TRUE or {"pi":{"inline":true}} (explicit choice
still beats an announced attach target). Seeds/docs/LIFECYCLE updated;
plan matrices re-flipped ({}→spawn pinned in pi-native + pi-inline-ws
tests). Real-machine check: bare import plans spawn (spawn attempt
observed), env-on/file-true plan inline.
@ranxianglei ranxianglei changed the title [PR] opencode inline mode (manually enabled): compression is performed within the opencode process; no standalone server is s | opencode inline 模式(手动开启):压缩在 opencode 进程内完成,不起独立 server pi/opencode inline 改为手动开启:收回默认翻转,默认行为与旧版完全一致 Oct 25, 2026
@ranxianglei ranxianglei changed the title pi/opencode inline 改为手动开启:收回默认翻转,默认行为与旧版完全一致 [PR] pi/opencode inline changed to manual opt-in: revert the default flip; default behavior is identical to the previous vers | pi/opencode inline 改为手动开启:收回默认翻转,默认行为与旧版完全一致 Oct 25, 2026
@ranxianglei
ranxianglei merged commit bb7c249 into master Oct 25, 2026
27 of 28 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.840-master.bb7c249 (rolling master tag).

npm install -g billion-context@0.0.840-master.bb7c249  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

ranxianglei pushed a commit that referenced this pull request Oct 26, 2026
…in32 rides cmd.exe (#679/#2196)

The #4687 test asserted spawns[0].command === BILI_CLIENT_BIN, which can
never hold on Windows: planClientSpawn wraps .cmd shims in
COMSPEC /d /s /c (CreateProcess cannot exec a batch file). Assert the
wrapped form on win32 (cmd.exe command, /d /s /c prefix, shim path inside
the wrapped line); keep the direct assertion elsewhere. Fixes the
windows-latest 22/3 shard red inherited from master bb7c249.
Louie0806 pushed a commit to Louie0806/billion-context that referenced this pull request Nov 4, 2026
planNativePi used to fall through to 'spawn' — bare pi with the
extension installed spawned its own proxy (dist/index.js start,
ephemeral port, parent-pid watchdog). Inline was opt-in only since
ranxianglei#4687 reverted the ranxianglei#4571 flip.

This restores the ranxianglei#4571 posture with explicit escape hatches:

  kill-switch > /bili/ launch > explicit inline (BILI_PI_INLINE=1/
  on/yes/TRUE or "pi":{"inline":true}) > ANNOUNCED attach target
  (launcher-set BILLION_CONTEXT_PROXY/ATTACH — bili pi keeps its
  launcher proxy) > inline DEFAULT > spawn (explicit opt-out only)

Opt-out restores the old attach/spawn posture verbatim:
BILI_PI_INLINE=0/false/no/off or "pi":{"inline":false}. Blank
BILI_PI_INLINE="" folds to unset. opencode's lane stays opt-in.

bili pi-inline stays (NOT deprecated): it scrubs inherited
BILLION_CONTEXT_PROXY/BILI_MITM_HOSTS so a stale attach env can't
hijack the child, and preflights extension availability — with no
proxy there is no wire-mode fallback, so a missing extension would
otherwise silently run uncompressed.

Supersedes the ranxianglei#4687 owner decision for the pi lane.
@ranxianglei ranxianglei mentioned this pull request Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant