Repository navigation
fix: mechanically pin subagent session ids into fold blocks (#1702) - #1704
ranxianglei wants to merge 4 commits into
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1659-pr.1704.d063bddThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1704.tgz
npm install -g packageInstall instructions are refreshed on each push. |
#1563 root-cause fix: fold protection is tool-name-keyed and content-blind, so opencode subagent dispatch pairs (ses_ ids in tool-call args + results) fold like ordinary exchanges and the ids survived only via the model's free-text summary — probabilistic fidelity (A/B probe behind #1563: 20% id loss for weak models; #475 prompt-naming still truncated ids). At fold commit (applyRanges, the single adoption point for every fold path — model-driven compress, preflight overflow, in-place refolds), extract ses_ ids from the covered originals by code and pin a machine appendix line on each changed block summary: after model output exists, before any consumer reads the summary. Idempotent (strip-then-re-pin normalizes model-echoed lines), tier-transparent (T2 re-pins via child summaries), zero-cost when no ids are covered, prompt layer untouched. Closes #1702.
…or, pre-existing on master)
3066d3e to
2799fb1
Compare
…self-exemption suite (#1707) The T9 teardown restored by the import fix still used plain recursive rmSync, which #1646 deliberately replaced everywhere with retry-hardened rmrf because it races active writers with ENOTEMPTY (this file's own comment at the store-dir teardown says so). Migrate the one remaining call site so no non-hardened teardown is left.
[bot] 🏷 Review complete — mergeable once CI goes green on the new head ① Original issue (#1702 ← #1563): direction verifiedThe root-cause chain holds: kernel fold protection is tool-name-keyed and content-blind ( ② Regression audit (existing behaviors on touched paths)Enumerated every consumer of block summaries around the hook site in
③ Code reviewModule logic sound: idempotent strip-then-re-pin (normalizes lines a model echoed into its own summary), zero-cost fast path returns the same string reference (no copy, no mutation) when inert, per-block cap (100) with truncation logged, global-flag regex ④ Test validity14 tests, real teeth: mechanical full-string assertions regardless of what the model summary says; the #1563 truncated-id failure mode; T2 propagation (asserts a genuinely new parent block); refold normalization (decompress → re-fold → exactly one canonical line); zero-cost byte-identity as strict equality. Integration tests drive the real kernel ( ⑤ Diff cleanlinessPurpose-related files only, no whitespace churn, no lock/generated noise. CI forensics — the 4 red test jobs were NOT this PRci.yml checks out the merge tree (master+head). Master carried a broken Local evidence (rebased onto current master
|
|
Closing per the review direction in this thread: the replacement is #1722 — structured-field capture (no regex), sidecar storage in |
Root cause (#1563 → #1702)
The kernel's fold protection is tool-name-keyed and content-blind (
ALWAYS_PROTECTED_TOOLS = ["compress","acp_rule"]; soft zone = last-5-msgs / 5K tokens). An opencode subagent dispatch pair — theses_session id in the tool-call args plus its result — is an ordinary exchange to the kernel: a few parent-agent turns later it slides out of the fresh zone and folds. The id's only survival channel was then the model's free-text summary — probabilistic fidelity (#1563 A/B probe: 20% id loss for weak models; #475 prompt-naming still truncated ids), which broke subagent resume ("Subagent session not found").Fix — mechanical fidelity at fold commit
New module
src/mechanical-preserve.ts, hooked intoapplyRanges(src/stream.ts) — the single adoption point for every fold path (model-driven compress, preflight overflow, in-place refolds). After the model output exists and before any consumer reads the block state (fingerprint excerpts, token estimate, persistence), the code extractsses_[A-Za-z0-9]+ids from the covered originals (machine read, not model transcription) and pins them as a machine appendix line on each changed block summary:ID_PATTERNSlater, generalization explicitly deferred. Prompt layer untouched — no summary-writing rule changed in any channel.Behavior change (flagged per policy)
Folds covering content with
ses_ids now append one machine line (~tens of bytes) to the stored block summary.\n\n[acp-mechanical-preserve] <ids>.Config surface
None — no field/env/CLI flag added, renamed, or re-semantics'd.
Both compression modes (§6)
forwardTool→/__bili/plugin/tool); folds execute proxy-side with full history → pinned.Evidence
npm run typecheck— cleannpm test— 3246 pass / 0 fail / 12 skipped (default skips)npm run build— success (+ dist-import-annotations OK)tests/mechanical-preserve.test.ts(14 tests): mechanical acceptance assertions (full-string match inside the block regardless of what the model summary says), the opecode2 压缩的时候会截断sub agent的 session_id #1563 truncated-id failure mode, T2 propagation, refold normalization, zero-cost byte-identity, plus extract/strip/pin unit coverage incl. the per-block cap.e2e-codex): local run blocked — the local sglang upstream was down at run time (connection refused on forward; proxy pipeline itself processed the request correctly per its log). CI e2e auto-runs on this PR (hot-file trigger coverssrc/stream.ts) against the configured upstream.Closes #1702 (subtask of #1563).