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.
📦 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
Merged
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