Repository navigation
fix: size OMP native windows from conversation-scoped runtime-info (#1531) - #1532
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1479-pr.1532.ad2296fThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1532.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Review complete — mergeable. Verified branch ① Original issue direction — correct, root-cause levelIssue #1531's four claims were already triage-verified against master v0.1.163. The PR fixes each at its decision point, not at the symptom:
The key consistency invariant holds end-to-end: report ② Regression audit — existing behaviors inventoried
No fail-fast→swallow drift, no threshold/timing/output-format drift beyond the two disclosed items. ③ Code reviewClean. No ④ Test effectiveness — real teethNew ⑤ Diff cleanliness9 files, +353/−42, single linear commit on current master. Every file serves the fix: the five source paths, their tests, and TECHNICAL-NOTES en+zh (kept in sync, accurately describing the dual-table resolution and its #1531 rationale). No unrelated churn, no lockfile/version changes. Behavior changes (confirmed accurate as disclosed in the PR body)
Verification evidence
修复了 OMP native 模式下客户端上报的上下文窗口因缺少 |
|
Deep review complete — mergeable. This fixes all three reported defects of #1531 with one coherent shape, and I verified each leg: 1. Cross-session overwrite (the headline bug). runtime-info is now dual-tabled: legacy agent-keyed (kept for header-carrying agents and pre-first-request status) + conversation-keyed ( 2. Wrong-window resolution. Header-less agents (omp sends no 3. Same-model config change never re-reported. The dedup key was the bare model id; the fingerprint is now proxyBase+agent+conversation+model+contextWindow+maxOutput+baseURL — any field change re-reports. Mutation check: fingerprint → bare model → 2/29 red. Ordering fix I specifically approve: Housekeeping verified: both tables capped at 32 entries with FIFO eviction; Non-blocking observation: a conversation entry can age out via the 32-entry FIFO in a busy process (many concurrent conversations) — degradation is the documented legacy miss, acceptable, but worth remembering if someone reports a window flipping back to registry-peek mid-session. |
[bot] 🏷 收到,独立复核结论与你的深审一致——可以合并。补充两点:
合并后 CI 会自动发布,若需要我再跑一次发布后验证( 中文摘要:owner 深审与 bot 复核结论一致(可合并),FIFO 老化确认为既有 32 条上限设计的延伸且降级方向安全、暂不处理,等待人工合并。 |
…1531) OMP native binds sessions via identity register + prompt_cache_key stamping but sends no x-bili-plugin header on model requests, so the proxy's runtime-info window lookup (header-agent only) always missed and reported contextWindow/maxOutput were silently ignored (registry-peek fallback). The server also kept one runtime slot per agent, so a sub-agent session clobbered the main session's entry, and the client deduped on model id alone, suppressing corrective re-reports. - src/plugin.ts: per-conversation runtime table keyed by conversationId (model-gated); handler records optional conversationId; status + pre-first-request probe fall back to it - src/server.ts: strict dual lookup at window selection and maxOutput fallback - x-bili-plugin header present -> per-agent entry only (unchanged); absent -> conversation-scoped entry keyed by the same session signals used for binding (client conversation header, custom session header, body prompt_cache_key) - src/agent/shared.ts: reportRuntimeInfoOnChange dedupes on (agent, conversation) with a full-field fingerprint incl. proxy origin, re-posting on any reported-config change; async, never rejecting - src/agent/pi.ts: OMP reports await bounded proxy-origin readiness, include conversationId, and are awaited in before_provider_request so the report lands before dispatch - src/agent/omp-native.ts: register the native origin waiter (setNativeOriginWaiter) like pi-native - TECHNICAL-NOTES en/zh: document conversationId and per-agent vs conversation-scoped resolution semantics - tests: conv-scoped storage/lookup/eviction units, e2e header-less pck adoption + clobber regression + header-wins + plain-client compat, dedup fingerprint units, #957 test asserts conversationId + ordering
3e819de to
ceff209
Compare
|
Conflict resolved — rebased onto master (new head Single conflict, union-resolved: the plugin.js import line (#1532 adds Post-rebase verification: runtime-info + plugin-agent suites 90/90, typecheck clean, tree clean (9 files, +353/−42 unchanged from review). Ready once CI is green. |
[bot] 🏷 Rebase 已独立核验,与你的描述逐项对上——新 head 冲突解决核验(对实际代码,非仅读报告)
Rebase 后全量重跑(本地,head
CI(head 合并入口:#1532 中文摘要:rebase 后的新 head 经逐行核验(import union、liveBlindTunnels 消费者、diff 零漂移)+ 本地全量重跑(3026/0 fail)+ CI 13/13 全绿,确认可以合并。 |
Fixes #1531
What was wrong (all four claims verified on master v0.1.163)
src/server.ts:1423): window selection consulted the runtime-info table with the request'sx-bili-pluginheader agent only. OMP native sends no such header on model requests (it binds via identity register +prompt_cache_keystamping; omp has no per-request header event surface — [native] omp: three-mode alignment (proxy / launcher / native plugin) + runtime-info #957), so reportedcontextWindowwas silently ignored → registry-peek fallback (the issue's 922000). The maxOutput headroom fallback had the same header-only lookup.src/plugin.ts):pluginRuntimeTablekept a single entry per agent name, so a sub-agent session's report clobbered the main session's entry (and vice versa) even though both run different models/windows under the same agent nameomp.src/agent/shared.ts):reportRuntimeInfoOnChangeskipped re-reporting whenever the model id was unchanged, suppressing corrective reports after config changes (window/baseURL/maxOutput), across proxy origins, and across sibling sessions sharing one process's module-level cache.Changes
src/plugin.ts: new per-conversation runtime table keyed byconversationId(model-gated lookup, same cap/eviction); handler records optionalconversationId;/statusruntimeInfo + pre-first-request probe fall back to it.src/server.ts: strict dual lookup at window selection AND the maxOutput fallback —x-bili-pluginpresent → per-agent entry only (byte-identical to today); absent → conversation-scoped entry keyed by the same session signals used for binding (client conversation header, custom session header, bodyprompt_cache_key). A miss there degrades to exactly today's legacy resolution — it can never produce a wrong hit.src/agent/shared.ts: dedup now keys on(agent, conversation)with a full-field fingerprint including proxy origin; re-reports on any reported-config change; async never-rejecting with rollback-on-failure.src/agent/pi.ts: the OMP report awaits bounded proxy-origin readiness (≤15 s), includesconversationId, and is awaited inbefore_provider_requestso it lands before dispatch (worst-case hold ~20 s < omp's ~30 s handler guardrail; mirrors pi's Native pi one-shot (-p): first request races the proxy bootstrap — x-bili-plugin never stamped, session binds anonymous wire mode #1243 behavior).src/agent/omp-native.ts: registers the native origin waiter, like pi-native does.conversationId+ the per-agent vs conversation-scoped resolution semantics.runtime-infosource with exact contextLimit; A/B/A no-clobber; per-agent header wins exclusively; plain-client compat unchanged); dedup fingerprint units; the [native] omp: three-mode alignment (proxy / launcher / native plugin) + runtime-info #957 test now assertsconversationIdin the report body and that the report lands before dispatch.Behavior changes (old → new)
contextWindow/maxOutputwere ignored (registry-peek, e.g. 922000 in the issue setup); now adopted at theruntime-inforank (e.g. 258400 − min(128000, 25%) = 193800). Compression/nudge cadence becomes much more aggressive for correctly-sized small windows — this is the intended fix.contextWindow/maxOutput/baseURL/proxy origin changes (previously only on model-id change) — extra loopback admin POSTs, negligible cost.Activation boundary: the conversation-scoped lookup fires on exactly the signals session binding already uses — wherever OMP native binds its session today, window adoption now works there; where no binding signal exists (e.g. Responses-API-shaped bodies are not pck-stamped), behavior stays at today's legacy resolution (no regression).
No config-surface change (no new config fields / env vars / CLI flags). Both compression modes considered: the window cascade is mode-agnostic; plain clients are unaffected (covered by the e2e compat test).
Pre-flight on current master (86e0b68): typecheck clean ·
npm test3015 pass / 0 fail · build OK.