Repository navigation
fix: pi one-shot (-p) first request claims plugin mode — await tool registration before header stamp - #1228
Conversation
…egistration before header stamp (#1214)
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-1228Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr1228.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Review started. Two things up front:
Full findings shortly. |
[bot] 🏷 Review complete — verified mergeable (human merge; gate note at the end). ① Direction (issue #1214): root cause confirmed — a one-shot dispatches exactly one request, so the fire-and-forget registration could never win the race; the fix serializes registration before the ownership gate, i.e. it removes the producer of the defect rather than masking the symptom. Premise checked against the real host: pi's extension runner awaits async handlers in Boundedness: ② Regression inventory (existing behaviors on touched paths):
③ Code: +16/-9, every line on-purpose. Nit (non-blocking): the try/catch around ④ Tests: the new #1214 test has teeth — I ran it against origin/master's ⑤ Diff: clean — 2 files, no whitespace/lock/generated churn. Rebases cleanly onto current master (the release v0.1.142 commit since your base only touches package.json/lock). Scope note (follow-up filed): this PR fixes only pi's header path. omp has the identical latent race on its own one-shot mode ( Overlap with #1216: my earlier open PR covered both paths with a bounded 5s readiness gate. This direct-await approach is cleaner — no arbitrary constant, boundedness derives from the existing fetch timeout + throttle. Recommendation: merge #1228, close #1216 as superseded (your call), track the omp gap in #1230. Gate: would pass auto-merge §7.4 except item 8 (touches session-binding logic) → human merge either way. 中文摘要:修复了 |
…ity registration before dispatch (ranxianglei#1230) Mirror ranxianglei#1228 on the before_provider_request path: make the handler async and await registerTools before stamping/reporting. omp's runner awaits async handlers and sends the resolved payload (verified in the omp 18.0.3 dist), so the plugin-mode claim (the identity:true register that runs INSIDE registerTools, after the manifest fetch) now serializes ahead of the single -p dispatch instead of racing it. A losing race bound the session as an anonymous pfa-*/proxy-mode session with no round 2 to self-heal.
Fixes #1214
Root cause
before_provider_headersstampedx-bili-plugin*only whenstate.toolsReady === true, but droveregisterToolsfire-and-forget. TUI recovered on request #2; a one-shot (pi -p) dispatches exactly ONE request — it rode wire mode forever and bound as an anonymouspfa-session (proxy-mode compression,/acpcannot bind by session id).Fix
pi's runner awaits async handlers (
emitBeforeProviderHeaders, verified in pi-stabledist/core/extensions/runner.js), so the handler is nowasyncand awaitsregisterToolsBEFORE the ownership gate.registerToolsis idempotent (sid-cached, pending-deduped, retryAt-throttled), so the await is bounded; a permanently failing manifest fetch still degrades to wire mode unchanged.Effect: the one-shot's single request carries the full header set (
x-bili-plugin,-conversation,-context-window,-model) → plugin-mode contract + real session binding from request 1. TUI round 1 also stops riding wire mode (previously round 1 = wire, round 2+ = plugin).Tests
session_startprewarm; FIRST fire stamps full headers + tools registered)