Skip to content

fix(loop): run applyCompression over the unpruned view - #197

Open
ranxianglei wants to merge 1 commit into
masterfrom
2026-08-22_compress-unpruned-view
Open

fix(loop): run applyCompression over the unpruned view#197
ranxianglei wants to merge 1 commit into
masterfrom
2026-08-22_compress-unpruned-view

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Feature branch (split out of #194 per review: features and releases stay separate).

Problem

The streaming compress path fed applyCompression a view that had neither
the raw messages nor the rendered summaries:

  • server.ts runCompressLoop ctx: messages: prepared.processedMessages.length > 0 ? prepared.processedMessages : prepared.originalMessages
  • processedMessages = stripKernelSummaries(turn.messages) filters every acp_summary_* id
  • loop/core.ts executeProxyTool → stream.ts applyCompression({ messages: ctx.messages })

With kernel ≥0.0.37 (billion-context-pi#195 fix), block anchors resolve via the
rendered summary or surviving raws — a view containing neither can resolve
nothing, so compression of any pruned region fails in streaming mode.

Fix

Split the two purposes of LoopCtx.messages:

  • new optional compressMessages?: CoreMessage[] on RewriteCtx (src/stream.ts) and LoopCtx (src/loop/core.ts)
  • applyRanges uses ctx.compressMessages ?? ctx.messages (src/stream.ts)
  • server.ts runCompressLoop sets compressMessages: prepared.originalMessages (full unpruned log — anchors always resolvable)
  • wire rebuilds / decompress / status keep using the pruned view (unchanged behavior)

Non-streaming paths already used originalMessages — no change for them.

Validation

  • typecheck clean; 512/512 tests; build OK (on pinned acp-kernel 0.0.36)
  • e2e grow-and-compress passes with kernel 0.0.41 overlay (upstream body stays bounded)

Ships in the next release together with the acp-kernel bump (≥0.0.40 for
billion-context-pi#195/#199 fixes).

…xt-pi#195)

The streaming loop ctx passed processedMessages (pruned view with
acp_summary_* stripped) to applyCompression, so active blocks whose raws
were pruned had no resolvable anchor — bN promotion failed with the
self-contradictory 'already compressed' error. Add a dedicated
compressMessages field (unpruned originalMessages) used only by
applyCompression; wire rebuilds keep using the pruned view.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant