Repository navigation
[PR] fix(pi): declare every pi dispatch as the session's main conversation turn - #7077
Conversation
… turn (discussions/6884) pi has no auxiliary LLM calls (no title-gen, no compaction summarizer, no auto-review; subagents and forks mint fresh session ids), so the pi plugin now stamps the x-bili-plugin-purpose "conversation" sentinel on every dispatch, and the server treats that sentinel from a PI-marked request as a declared main turn riding the #1699 explicit-main intent rung — it outranks every body heuristic. The bug this fixes: a pi main turn whose body happens to match a legacy side shape — a one-shot `pi -p` with a small maxTokens and no tools, for example — was demoted by the max_tokens<=200 budget heuristic to the #388 side passthrough and never entered the kernel pipeline: no compression state, no tools, silent substrate loss on a real conversation turn. The sentinel deliberately means different things per client: dsh DERIVES it ("GenerateOptions.purpose was unset" — possibly an unrecognized new aux feature), so for dsh it stays ≡ absent and the body heuristics classify, byte-for-byte as before #6880 (pinned). pi's sentinel is a FACT, so it suppresses the heuristics. The per-client asymmetry is pinned in tests/issue6884-pi-purpose-declaration.test.ts alongside the declared/ undeclared twin cases. Refs #6880, discussions/6884
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.10669-pr.7077.c92b71fThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr7077.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) Duplicate check: not a duplicate. Searched open + closed issues/PRs for "pi purpose declaration side request x-bili-plugin-purpose" and "pi -p one-shot side passthrough demoted compression pipeline" — zero matches. This is the pi leg of the #6880 declaration channel (the dsh leg is already merged); no parallel work exists. Review status (code review complete):
CI is RED on one mechanical gate: Fixing it now: adding a handle-level pin to Labels applied on pickup: |
#7077 lane-guard) lane-guard (#2170) demands a dedicated side-lane suite move whenever the lane region of handle.ts changes: #7077's declaredPiMainTurn derivation rides the #1699 explicit-main rung inside isSideRequest, so the truth table gains the pi leg of the #6880 sentinel pin — pi + conversation sentinel outranks the budget heuristic (side-shaped body stays main), while the same sentinel from dsh stays ≡ absent (heuristic still demotes), a real pi purpose still declares side, and an unstamped pi dispatch keeps the pre-#6884 heuristic classification. Closes the lane-guard failure on head c197e4c.
(ai: vllm-qwen/qwen3.8-27b) lane-guard fixed — green on the new head What I did this run:
七问:
|
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。 Searched open+closed issues/PRs for "pi purpose declaration side request x-bili-plugin-purpose" and "pi -p one-shot side passthrough demoted compression pipeline" — zero matches. This is the pi leg of the #6880 purpose-declaration channel (the dsh leg is already merged). Code review: the fix is correct. Verified:
CI: was red on Residual gap (not a blocker): the Verdict: mergeable (once the test lanes finish green). 结构化八问
收工判定: 可合(等 test lanes 跑绿;lane-guard 已由 CI 自动化修好,我本地验证 gate 通过 + 相关套件绿)。 |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) CI is now fully green on the new head ( Final verdict: mergeable, no blockers. The one residual gap (the #1897 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.1226-master.6b07dff # this exact build
npm install -g billion-context@master # always the newest merged build
|
What is broken (in one sentence)
A pi main-turn request whose body looks like a side request (e.g.
pi -pone-shot, or a smallmax_tokenswith no tools in the body → themax_tokens <= 200heuristic) gets demoted to the #388 side passthrough lane and skips the whole compression pipeline — the conversation's kernel state is lost for that turn.The fix
pi has an in-process plugin (discussions/6884: pi and dsh are the only hosts with one), so pi can declare what a dispatch is, instead of the server guessing from the body:
src/agent/pi.ts— the singlebefore_provider_headersstamp site (covers every pi lane, including native spawn and inline; omp never fires this event so it is untouched) now also stampsx-bili-plugin-purpose: conversation, next to the existingx-bili-plugin/x-bili-plugin-conversationheaders.src/server/handle.ts— when a request carries thepimarker and theconversationpurpose, the twoisSideRequestcall sites feed it as explicitmain(the existing opencode v2 title-gen requests get injected with compression philosophy (misclassified by isTitleGen) #1699 rung), so the declaration outranks body-shape guessing.isSideRequestitself is unchanged — all side-lane truth-table pins stay green.Why the sentinel is not normalized to "absent" for pi
The
"conversation"sentinel means different things per client, and only dsh's meaning matches "absent":conversation= "dsh did not set a purpose" → it may be an aux call the classify-set doesn't know yet, so it must keep behaving exactly as an undeclared request (byte-for-byte [Design][dsh] Stop guessing dsh's auxiliary requests — the in-process plugin can declare each request's purpose explicitly #6880 contract — pinned by test feat: OpenAI Responses API support (/v1/responses) #4 in the new file).conversationis a fact — pi has no title-gen / compaction / auto-review / structured-output aux calls at all; subagents and forks mint brand-new session ids. So the sentinel must suppress the body heuristics.What is deliberately untouched
src/server/side-request.ts(signature and all heuristics unchanged),demoteGate(OMP extension injects tools and compression philosophy in helper prompts #1897),prepare-openai/prepare-googleinternalisTitleGenswitches,isSideRequest).Test evidence
tests/issue6884-pi-purpose-declaration.test.ts(5 tests): declared pi main turn on a side-shaped body stays on the full pipeline (1 kernel request, no|sub:ghost); the identical undeclared body still takes the legacy side lane (pin, not regression); no plugin marker → no effect; dsh sentinel asymmetry pin (dsh +conversationon a side-shaped body stays off the pipeline, guarding against a future "normalize all sentinels" change); cross-system-drift parity.tests/plugin-agent.test.ts(extension,pi -pone-shot, post-prewarm).tsc --noEmitclean.Refs: discussions/6884, #6880, #6883