Skip to content

Incremental turns for opencode, omp, and pi-native hosts (#3248 phase 2) - #3292

Merged
ranxianglei merged 4 commits into
masterfrom
2026-10-15_incremental-native-hosts
Oct 16, 2026
Merged

ranxianglei merged 4 commits into
masterfrom
2026-10-15_incremental-native-hosts

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Completes the native-host matrix for the incremental lane (#3248 phase 2, server side + pi/dsh-native landed in #3273):

host identity body conversion marker ack
pi (#3273) session id before_provider_request before_provider_headers after_provider_response
dsh-native (#3273) x-bili-plugin-conversation fetch beforeSend headersFor onResponse
pi-native (here) inherits the pi wiring unchanged (same extension factory; only proxy discovery differs)
opencode (here) e.sessionID http.request hook incremental callback → replaceRequestPayload (after routing/stamping so the marker rides the same request) on the replaced request fetch intercept onResponse
omp (here) prompt_cache_key body field (omp emits no header events; the extension stamps it, wire mode already resolves the same value — identity upgrade, not a fork) fetch beforeSend stamped directly on the request init onResponse

Shared machinery:

  • wireMessagesLookAnthropic — non-Anthropic wire shapes (OpenAI tool_calls/role:"tool") are detected and left on full resend (the lane ingests the anthropic wire).
  • Planned turns are single-in-flight per URL and age out after 30s — a network-dead request must not block the URL's incremental forever (onResponse only fires on successful sends).
  • native-intercept now fires onResponse on the model-API path too (previously routed-only).
  • Test hygiene fix that mattered: omp origin discovery now funnels through publishOrigin, so a test-pinned base survives the async attach verify — it landed mid-suite and raced probes off to the REAL lane (flaky ~50% locally under BILLION_CONTEXT_PROXY).

Tests: tests/opencode-incremental.test.ts 4 (seed swap + marker + auth preserved → ack → delta; probe disabled byte-untouched; OpenAI tool_calls untouched; 409-on-delta → dead → original body), tests/omp-native-incremental.test.ts 3 (pck → conversation id + three headers on init + delta after ack; no pck untouched; probe off untouched), tests/incremental-lane.test.ts 17 (+wire shape guard unit). Regressions: opencode-native 34, fork-adopt 4, issue1569 15, issue1958 4, issue2455 + native-intercept-selfheal 27 — all green; tsc clean; unused-export gate clean (4 waived).

Known non-goals here: claude/codex CLI remain full-resend (pure proxy clients — no in-process hook exists; #3248 tracks host-side adoption), and omp native Cowork transport bypasses fetch (pre-existing limitation, same as #2583).

prepared by an agent under the local git identity (ranxianglei), human merge required

…#3248 phase 2)

- opencode: http.request hook adapter callback swaps the request body after
  routing/stamping (replaceRequestPayload keeps url/method/headers); acks ride
  the fetch intercept's onResponse.
- omp: no header events exist — beforeSend reads the extension-stamped
  prompt_cache_key body field as the conversation id and stamps the plugin
  headers directly on the request init (identity upgrade, never a fork: wire
  mode already resolves the same value via preferPromptCacheKeyIdentity).
- pi-native: inherits the pi wiring unchanged (same extension factory).
- shared: wireMessagesLookAnthropic gates non-Anthropic shapes (OpenAI
  tool_calls) to full resend; planned turns are single-in-flight per URL and
  age out after 30s (a network-dead request must not block the URL forever);
  native-intercept fires onResponse on the model-API path too.
- test hygiene: omp origin discovery funnels through publishOrigin so a
  test-pinned base survives the async attach verify (it landed mid-suite and
  raced probes off to the real lane).
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-15_incremental-native-hosts (4471085)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.3889-pr.3292.43c6942

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

Option B — Download artifact

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

Install instructions are refreshed on each push.

awork and others added 2 commits October 15, 2026 22:57
…letion point (#3248 phase 2 review)

- routed-lane success fired onResponse with the post-reroute target while
  every ack consumer (dsh/omp/opencode) keys pending plans by the
  host-requested URL — a dead-origin reroute silently dropped the ack, so
  the next turn 409'd into the sticky full-resend fallback.
- rewrite-lane recovery retry never fired onResponse at all — the same
  ack loss when the proxy blips mid-incremental-turn.
- pin the URL identity in the NativeInterceptState.onResponse doc;
  regression assertions ride the existing #1130 reroute and respawn+retry
  intercept tests.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重:不重复——本 PR 即 #3248 phase 2(native-host matrix 补齐),与 #3273(phase 1,已合入)相关但范围不同(本 PR 新增 opencode/omp/pi-native 三个 host + 共享 guard),不构成重复。

审核结论:可合并(待剩余 CI lane 转绿)。以下审核独立于 PR 描述重新做过,基于分支 head 170b821bc(含 master 74456f36b 的 merge;merge 带入的变更与 PR 在 src/agent/* 零文件重叠,无语义冲突)。

审核过程摘要

  1. 方向:成立。增量 lane 此前只有服务端 + pi/dsh-native(Incremental turns phase 2: marker divert on ordinary model requests + native client helpers (#3248) #3273);本 PR 把 opencode/omp/pi-native 接入,各 host 的 identity/转换点/marker/ack 点与服务端契约对得上(opencode 的 stamp sid 与 adapter 用的 e.sessionID 同源、omp 的 preferPromptCacheKeyIdentity 确认是 identity 升级而非 fork——均独立验证过)。
  2. 回归清点(diff 触碰路径的既有行为,逐项):replaceRequestPayload 纯新增(catch 分支 = 原请求原样发出,等价 pre-PR);model-API 路径新增的 onResponse 触发是纯观测钩子且 try/catch 包裹;opencode-v2 的 incremental 回调在 hook 链最后调用、launcher 模式不存在、try/catch 包裹;pi-native 仅 +6 行注释(factory 不变,继承声明经 src/agent/pi.ts 验证属实);wireMessagesLookAnthropic 对非 Anthropic 形态保守退回全量重发。无意回归:无。
  3. 代码审查发现与处置:
    • F1/F2(已修,commit ed03ccf7a 推到 PR 分支):三个 fetch-lane ack 消费者(opencode/omp/dsh)全部以 host 原始请求 URL 为 key,但 routed-lane 成功路径原来 fire onResponse(target)(reroute 后的 target)、rewrite-lane 的 recovery-retry 路径根本不 fire——dead-origin reroute 场景下 ack 静默丢失(波及 dsh,含已合入的 Incremental turns phase 2: marker divert on ordinary model requests + native client helpers (#3248) #3273),proxy 死后重试成功的场景丢 ack → 下一轮 409 → sticky dead → 进程内永久全量重发。已统一改为以 host 原 URL fire,并把 URL 身份契约钉进 NativeInterceptState.onResponse doc;tests/native-intercept.test.ts 两处断言加固(reroute 用例修复前会丢第二次记录、retry 用例会丢整条记录,均 fail-before-fix)。本地定向跑过:PR 面 77/77 + 回归面 112/112,typecheck clean。
    • F3(已单独立题 #3304,不进本 PR):代理挂掉时 give-up 降级直连会把已增量化载荷原样发给真实上游 → 400(opencode/omp/dsh 同一机制,两条 give-up 路径都会命中)。自愈、无数据丢失、当前功能默认关零暴露,但 rollout 前必须闭环——修法有两个选项(A 回滚缝 / B 保守不直连),留 owner 拍板。
  4. 测试有效性:新测试断言有牙(seed swap+marker+auth 保留的字节级断言、probe 禁用时 byte-untouched、OpenAI tool_calls 不受触碰、409-on-delta→sticky-dead→回退原始 body),覆盖与 diff 触碰路径匹配,不是为测试而测试。
  5. diff 整洁度:12 文件 +548/-21,每行都与本 PR 目的相关;无无关改动、无空白噪声、无生成物混入。
  6. 旧 head CI 红说明:d73cb98fc 上 4 个 shard-2 job 全红,但都是同一个测试(#3148 clampOutgoingOutput … capped 4096 vs 1360)——master 存量红,与本 PR 无关:前一个 master head 62b86e555 的同测试也红(shard 1)、本地单独跑同样失败;根因是 [bug] 0.1.195 输出预算三路饿死仍复现:无 output 上限模型 restore 无下限(1→252、fork 原样转发 1)、#2490 planning floor 钳到 1479–2623 → 3 会话 9 次 finish=length 空轮不重试(#546/#1665/#1840/#2904/#2756 残留) #3071 加 4096 capability floor 后该测试期望没更新,已在 master ba456cfff 修掉并被本分支 merge 带入。(分片号漂移只因本 PR 两个新测试文件改变了 ci已经运行超过20分钟了 检查为什么并作优化 #3143 的均衡分片。)

八问

  1. 是什么问题:增量轮次 lane(Delta lane: native-mode clients send only deltas, server maintains full state + one-time fold, upstream receives snapsho | 增量车道:native 模式客户端只发增量,服务端全量维护+一次折叠,上游只收快照(#2926 的泛化) #3248)补齐 native-host matrix 的第二阶段——opencode/omp/pi-native 接入增量发送,外加两个共享 guard(wire 形态识别、单飞+30s TTL)和 model-API 路径的 onResponse 覆盖。
  2. 什么原因导致的:lane 的服务端与 pi/dsh-native host 侧已在 Incremental turns phase 2: marker divert on ordinary model requests + native client helpers (#3248) #3273 落地,其余三个 native host 缺各自的转换点/marker 点/ack 点接线,流量仍走全量重发。
  3. 影响范围与严重程度:只影响开启 pluginIncrementalTurns 的会话(当前 rollout 0%,默认关)——存量用户零外部影响。开启范围内:代理崩溃/重启落在 30s probe 窗口内时单轮可能 400(F3,When the proxy goes down, incremental rounds fall back to direct connection, sending the incremental payload as-is to upstream and causing a 400 (same mechanism across opencode/omp/dsh-native). | 代理挂掉时增量轮次降级直连会把增量载荷原样发给上游导致 400(opencode/omp/dsh-native 同一… #3304,自愈无数据丢失);F1/F2 类 ack 丢失场景(代理死亡+reroute/重试)已由本 PR 修复。
  4. 怎么修复的:每个 host 在自己的扩展 hook 里按矩阵接线(opencode:http.request 末尾回调换体;omp:beforeSend 换 init;pi-native:继承 pi factory);非 Anthropic wire 形态保守留全量重发;planned turn 每 URL 单飞 + 30s TTL 防网络死请求卡死 URL;ack 统一以 host 原 URL 为 key(F1/F2)。
  5. 是否有回归问题:无。既有行为逐项清点见上第 2 条;高危模式过完——catch 分支全部是「退回原行为」而非吞错,无阈值/时序/输出格式漂移,dead flag 粘性是文档化设计(PLUGIN.md)。
  6. 是否破坏缓存:不涉及。prefix cache / unified storage sidecar 策略未动;lane 的 seq/ack 状态机是会话内部状态。
  7. 是否改了设计方向:不涉及。完成既有 lane,架构/边界/数据流不变。
  8. 是否引入新配置:无。无新 env/config/CLI;功能门仍是服务端 pluginIncrementalTurns + unified sidecar,默认值未变。

CI 状态(提交本回复时):head 170b821bc 已完成 24/24 全绿,16 个 lane(测试分片/e2e)排队中,0 失败。转绿后我补一条确认;若红,定向排查后报告。

判定:可合并——建议 owner 待剩余 CI lane 转绿后合并(merge 需人工执行,符合仓库规则)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

进度同步(我的长轮询进程被平台看门狗重启了,改用短轮询继续盯):

  • 审核已完成,结论见上一条回复:可合并(待 CI 全绿)。F1/F2 ack URL keying 修复已推到 PR 分支(commit ed03ccf7a);give-up 直连发增量载荷的问题已单独立题 #3304。
  • CI 最新状态(head 170b821bc):40 个 lane 中 35 完成且全绿,5 个测试分片运行中,0 失败。
  • 剩余分片转绿后我补一条最终确认;若红,定向排查后报告。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

CI 全绿确认:head 170b821bc 40/40 lane 全部 success(含全部测试分片与 e2e),0 失败。

收工判定维持不变:可合并——审核结论见本线程第一条审核回复(F1/F2 ack URL keying 修复 ed03ccf7a 已在分支上;give-up 直连发增量载荷的遗留问题已立项 #3304,rollout 前需闭环)。合并由人工执行。

…tal-native-hosts

# Conflicts:
#	CHANGELOG.md
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

上游 PR 冲突已解决并推送——本 PR(#3292,#3248 phase 2)分支与 master 的合并冲突(dirty)已消除:merge origin/master → 解掉唯一冲突文件 CHANGELOG.md → push。新 head 44710852e,base 已对齐 master 6ee4a2ac9,GitHub 侧 mergeable=True(不再是 dirty);当前 mergeable_state=blocked 仅为新 head 的 CI lane 尚在跑,转绿后即可由人工合并。

冲突成因与解法

master 在本分支上次合入点(74456f36b)之后又前进了 33 个提交(kernel 图片预压缩移除 #3266/#3295、unit-projection 共享判定 #3236/#3268、prune 顺序配对 #3046/#3053、output budget floor #3071/#3080、text-run guard #3260、lineage persist window #2987、web trajectory brush #2489)。合并后只有 CHANGELOG.md 一个文件冲突——master 新增了 #3266 图片移除条目,而本分支的 #3248 phase 2 条目比 master 侧更长(多了 pi-native/opencode/omp 接线的收尾说明)。按「并集」解:保留 master 新增的 #3266 条目 + 本分支更长的 #3248 phase 2 条目。

零代码级冲突:除 CHANGELOG 外,本 PR 的 11 个文件(src/agent/* + 其测试 + PLUGIN.md)与 master 改动的 111 个文件无交集,其余文件均为单边取用,无手工干预。PR 有效 diff(base→head)确认只含本 PR 自己的 12 个文件——kernel/ 0 处、version 字段未动,故 kernel-guard / 版本门禁不会被这次 rebase 触发。

本地验证(定向,全量交给远程 CI):typecheck clean;build clean(commit=44710852e);定向测试 77/77(incremental-lane / native-intercept / omp-native-incremental / opencode-incremental);相邻回归 38/38(opencode-native / opencode-fork-adopt / issue1569 / issue1958 / issue2455 / native-intercept-selfheal)。

八问

  1. 是什么问题:本 PR 分支与目标分支 master 产生合并冲突(PR 处于 dirty 无法合并),不是功能缺陷。
  2. 什么原因导致的:master 在分支上次合入点之后又前进了 33 个提交,其中改动落在 CHANGELOG.md 的 [Unreleased] 段、与本 PR 的新增条目相邻,产生文本冲突;源码两侧零重叠。
  3. 影响范围与严重程度:仅调度层面——PR 无法合并;对运行时无任何影响(未改动任何已发布行为)。严重度低(纯合并阻塞,非回归)。
  4. 怎么修复的:用 merge 策略把 origin/master 合入 PR 分支(与本分支既有历史一致);CHANGELOG 按并集解;其余文件单边取用,无手工改码。
  5. 是否有回归问题:无。typecheck+build 干净,定向 77/77 + 相邻回归 38/38 全绿;本次仅动 CHANGELOG 文本,无语义/阈值/时序/输出格式变化。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:不涉及。
  8. 是否引入新配置:无。

判定:冲突已解决,push 后 mergeable=True;待新 head 的 CI lane 转绿即可由人工合并(合并须人工执行,符合仓库规则)。

@ranxianglei
ranxianglei merged commit ce4d60b into master Oct 16, 2026
32 of 40 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.480-master.ce4d60b (rolling master tag).

npm install -g billion-context@0.0.480-master.ce4d60b  # 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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant