Repository navigation
fix: keep Codex compaction_trigger final when injecting the compress nudge - #283
Merged
Merged
Conversation
…nudge refs #280 Codex's native remote-compact request ends with a compaction_trigger input item that the upstream requires to be the FINAL input item. The compress nudge injection appended a user message after it, so any nudge-armed session that hit a native compact got 400 "The 'compaction_trigger' item must be the final input item." and the pre-sampling compact (and the turn) failed. Skip the nudge when the final input item is a compaction_trigger — the native compact IS the compression, and the developer-message / tool injections (head of input) are unaffected. Test: Responses e2e — trailing compaction_trigger stays final with no nudge appended; control request keeps the nudge. Full suite 662/662.
Contributor
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-283Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr283.tgz
npm install -g packageThis comment is automatically updated on each push. |
This was referenced Aug 27, 2026
This was referenced Aug 27, 2026
Merged
This was referenced Sep 13, 2026
Closed
Closed
ranxianglei
pushed a commit
to joshwapohlmann/billion-context
that referenced
this pull request
Sep 17, 2026
…lei#870, PR ranxianglei#871) Two CI regressions found while reviewing ranxianglei#871's red test jobs: 1. The degenerate-turn re-issue fired on the native-compaction trigger request (the resetAfterSuccess passthrough), appending the continuation nudge AFTER compaction_trigger and breaking the wire shape (ranxianglei#283: the trigger must stay the last input item). makeContinuationRefetch now refuses to re-issue a body whose final input item is a trigger. 2. The new gates retried turns the model left genuinely bare — zero output of any kind — double-billing an upstream empty completion. Both plugin pipes now require proof of invisible-but-real output (a stripped render-tag/marker echo, released markup, or thought/reasoning), matching the boundary the compress loop has kept since ranxianglei#732/ranxianglei#821.
This was referenced Sep 17, 2026
This was referenced Sep 26, 2026
ranxianglei
pushed a commit
that referenced
this pull request
Sep 27, 2026
…or-wins enforcement (#1421) Owner-approved design (issue #1421, decision 2026-09-26): adopt carrier merge (a) with per-wire split on role-alternation-strict wires. Stamp shape per wire (insertCheckpointCarrier): - anthropic: merge as an extra trailing text part of the last user message (string content normalizes to parts); standalone append only when the body does not end in a user message. - google: merge into the last content's parts when it is not model-role (mandatory — mirrors appendGoogleNudge; the append form died inside bili's own pipeline because coreToGoogle fuses same-side runs). - openai: standalone trailing user message (unchanged from step 2). - responses: standalone trailing user message inserted before any trailing compaction_trigger (unchanged; #283 invariant preserved). Restamping an already-stamped body replaces the trailing carrier instead of stacking (idempotent re-stamp). Recognition relaxation (extractChainCarriers), matching each wire's emitted shape — still whole-part matching, ownership semantics unchanged: - anthropic: whole-content OR a LAST part that entirely is the tag. - google: ANY part that entirely is the tag (a later hop's nudge merge can push the tag off the end of parts). - openai/responses: unchanged. Strip is surgical: part-level removal for merged carriers, whole-slot for standalone ones; emptied entries are dropped. Enforcement (server.ts, first-processor-wins): - valid / recent-mismatch / stale+digest-matched → forward verbatim, pipeline skipped (log [chain] info/warn). - stale without digest match → strip the stale carrier(s), process normally (the request leaves re-stamped fresh by this instance). - invalid → never trusted, process normally + warn. - new ChainCheckpointContext.selectedMatched splits the stale verdict. - kill switch: both enforcement and outbound stamping respect opts.chainContentDetection !== false (BILI_CHAIN_CONTENT=0). Outbound stamping (forward()): every request that actually ran the kernel (prepared with non-empty processedMessages, not side passthrough) leaves with a <bili-chain> stamp computed over the exact bytes forwarded (placed after compat roles + output steering so the digest covers them). Best-effort: a stamp failure logs debug and forwards unstamped. requestId = first 8 hex of the digest (deterministic, constant-size). New stampOutbound() export; module header now carries the identification-contract-freeze warning carried forward from #1397 plus the #1421 per-wire shape decision. Legacy advisory text updated from 'until signed chain proof lands' to 'until both sides ship the request checkpoint'. Tests: new tests/chain-checkpoint-step3.test.ts (per-wire stamp shapes, restamp idempotency, recognition relaxation, google must-fail regression via real coreToGoogle fusion, round-trip invariant matrix, integration E1-E7 incl. kill switch and side-request no-stamp). Step-2 test file updated to step-3 semantics (T1/T2 now assert byte-identical verbatim forward; google two-part case is now a carrier under the any-part rule). Eight unrelated test rigs pin exact wire shapes and opt out via chainContentDetection:false.
This was referenced Sep 27, 2026
Closed
This was referenced Oct 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
refs #280
Background
Codex 0.147.0 performs native server-side compaction by sending a request whose input ends with a
compaction_triggeritem. The upstream requires that item to be the final input item — anything after it is rejected with:Bili's compress-nudge injection appends a user message at the end of the input. In any nudge-armed session (the issue's log shows
INJECT T1right before the 400), the nudge landed after the trigger, so Codex's own pre-sampling compact failed and the turn died withError running remote compact task. This only appeared after v0.1.57 because nudge injection shipped in that release.The 426
Upgrade Requiredon the WebSocket attempt is separate and by design — bili has no WS support and Codex fast-falls back to HTTP.Changes
src/server.ts(prepareResponses): when the final input item is acompaction_trigger, skip the nudge for that request. The native compact IS the compression, so a client-side nudge is both contract-violating and redundant. The developer-message and tool injections (head of input) are unaffected; the kernel's wire layer already preserves the trigger's final position through projection/rebuild.Tests
tests/compaction-trigger-finality.test.ts): nudge-armed session → request ending incompaction_trigger→ forwarded input's last item is the trigger and no nudge text is present (200); control request with a normal trailing message still gets the nudge. Verified the test fails on master without the fix.Full suite: 662/662 pass.
🤖 ework agent