fix(compaction): stabilize deletion planner - #1311
Conversation
|
Review: fix(compaction): stabilize deletion planner Thanks for this — replacing the native A few things worth a look before merge. 1. Thinking level vs. the hard-coded maxTokens = 4096 cap (worth verifying). 2. Default thinkingLevel = "off" removes the model-supported guarantee. The deleted 3. Minor performance nits in ContextDeletionMemoryStore. 4. Rollback semantics — correct, but untested. The snapshot/restore approach correctly narrows rollback to the only mutable state ( Tests / changelog. Coverage for the behavioral change is good: both the Overall a good, well-scoped fix. My only real blocker-candidate is item 1 — please confirm the — Reviewed with Claude Code |
Replace the sqlite-backed transcript deletion store with an in-memory implementation so /compact works without native better-sqlite3 installs. Preserve the active reasoning level when auto-compaction invokes the planner and cover both behaviors with tests. Refs #1310 Assistant-model: GPT-5.5
cc50259 to
9c6b336
Compare
Review: fix(compaction): stabilize deletion plannerSolid, well-scoped fix. Dropping the native Correctness / parity — looks good
Things to confirm1. Behavior change, not just a bug fix: compaction now uses the session's reasoning level. 2. Possible regression in the standalone default 3. Version vs. CHANGELOG. Performance (minor)4. const block = this.contentBlocks.find((candidate) => candidate.entryId === entryId && candidate.blockIndex === blockIndex);SQLite had a 5. Nits6. Vestigial SQL-shaped row types. The in-memory store still returns SQL-flavored rows ( 7. Removed export. TestsCoverage is appropriate: the new auto-compaction test pins the forwarded thinking level, and the two deletion-tool tests were updated to reflect pass-through semantics. If you keep the standalone Overall: good fix that removes a real source of fragility. Main asks are confirming the reasoning-level cost trade-off (1), the unsupported- 🤖 Generated with Claude Code |
Assistant-model: GPT-5.5
Code Review —
|
) * feat(compaction)!: remove summary compaction Route compaction documentation, APIs, tests, and runtime paths toward verbatim-only context compaction for #1305. BREAKING CHANGE: Legacy summary compaction APIs and hook shapes are removed in favor of verbatim context compaction. Assistant-model: GPT-5.5 * chore(release): prepare 0.8.28-alpha.1 * feat(workflows): ctx.ui.custom HIL prompts (#1309) — workflows-only, drift removed * docs(changelog): organize 0.8.27-alpha.1 (#1311) and 0.8.28-alpha.1 (1305+1309) sections * refactor(compaction): address PR #1313 review feedback Addresses review comments on the verbatim-only compaction change: - agent-session: isolate session_compact observer errors from the committed compaction. The hook fires after backup/persist/rebuild, so a throwing observer is now routed to the non-fatal extension-error channel instead of rejecting a successful, already-persisted compaction. - agent-session: extract a single runPlanner() closure, removing the triplicated resolve-auth/run-planner fallback blocks. - messages/context-compaction: restore compile-time exhaustiveness (never) guards in convertToLlm and messageText. This surfaced that the upstream pi-agent-core AgentMessage union still includes the legacy compactionSummary role, now handled explicitly (inert: excluded from LLM context) instead of silently falling through. - context-compaction: extract a documented isTaskBearingEntry() predicate shared by the critical-overflow protection and the task-bearing guard; a surviving branch summary intentionally satisfies the guard even when every user message is evicted under critical overflow. - tests: add critical-overflow task-bearing assertions; run the credential-less deletion-shaped compaction tests unconditionally and gate only the planner fallback behind ANTHROPIC_API_KEY. Assistant-model: Claude Opus 4.8 * refactor(compaction): lazy extension snapshot, guard structuredClone, dedupe fallback Addresses the second-round review on PR #1313 (_applyContextVerbatimCompaction): - Build the deep-frozen extension snapshot only when a session_before_compact handler exists, instead of on every compaction. Compaction fires when the transcript is largest, so the common no-extension path no longer deep-clones and freezes the whole transcript for nothing. - Guard structuredClone with try/catch: a non-cloneable entry would otherwise raise a raw DataCloneError and turn a viable compaction into a hard failure. It now surfaces a clear error. Transcript entries are plain data, so this is a latent-invariant guard on the (now hot) path. - Collapse the two byte-identical runPlanner() fallback blocks into a single post-hook `if (!validated)` branch. Reviewer items 3/4/6 were confirm/notes only: the broadened task-bearing predicate is the previously-confirmed intended behavior, so no code change. Assistant-model: Claude Opus 4.8
* fix(compaction): stabilize deletion planner Replace the sqlite-backed transcript deletion store with an in-memory implementation so /compact works without native better-sqlite3 installs. Preserve the active reasoning level when auto-compaction invokes the planner and cover both behaviors with tests. Refs #1310 Assistant-model: GPT-5.5 * fix(compaction): use model output cap for context deletion Assistant-model: GPT-5.5
) * feat(compaction)!: remove summary compaction Route compaction documentation, APIs, tests, and runtime paths toward verbatim-only context compaction for #1305. BREAKING CHANGE: Legacy summary compaction APIs and hook shapes are removed in favor of verbatim context compaction. Assistant-model: GPT-5.5 * chore(release): prepare 0.8.28-alpha.1 * feat(workflows): ctx.ui.custom HIL prompts (#1309) — workflows-only, drift removed * docs(changelog): organize 0.8.27-alpha.1 (#1311) and 0.8.28-alpha.1 (1305+1309) sections * refactor(compaction): address PR #1313 review feedback Addresses review comments on the verbatim-only compaction change: - agent-session: isolate session_compact observer errors from the committed compaction. The hook fires after backup/persist/rebuild, so a throwing observer is now routed to the non-fatal extension-error channel instead of rejecting a successful, already-persisted compaction. - agent-session: extract a single runPlanner() closure, removing the triplicated resolve-auth/run-planner fallback blocks. - messages/context-compaction: restore compile-time exhaustiveness (never) guards in convertToLlm and messageText. This surfaced that the upstream pi-agent-core AgentMessage union still includes the legacy compactionSummary role, now handled explicitly (inert: excluded from LLM context) instead of silently falling through. - context-compaction: extract a documented isTaskBearingEntry() predicate shared by the critical-overflow protection and the task-bearing guard; a surviving branch summary intentionally satisfies the guard even when every user message is evicted under critical overflow. - tests: add critical-overflow task-bearing assertions; run the credential-less deletion-shaped compaction tests unconditionally and gate only the planner fallback behind ANTHROPIC_API_KEY. Assistant-model: Claude Opus 4.8 * refactor(compaction): lazy extension snapshot, guard structuredClone, dedupe fallback Addresses the second-round review on PR #1313 (_applyContextVerbatimCompaction): - Build the deep-frozen extension snapshot only when a session_before_compact handler exists, instead of on every compaction. Compaction fires when the transcript is largest, so the common no-extension path no longer deep-clones and freezes the whole transcript for nothing. - Guard structuredClone with try/catch: a non-cloneable entry would otherwise raise a raw DataCloneError and turn a viable compaction into a hard failure. It now surfaces a clear error. Transcript entries are plain data, so this is a latent-invariant guard on the (now hot) path. - Collapse the two byte-identical runPlanner() fallback blocks into a single post-hook `if (!validated)` branch. Reviewer items 3/4/6 were confirm/notes only: the broadened task-bearing predicate is the previously-confirmed intended behavior, so no code change. Assistant-model: Claude Opus 4.8
Summary
Fixes `/compact` and auto-compaction regressions (#1310): removes the native `better-sqlite3` dependency from the transcript deletion store by replacing it with a pure TypeScript in-memory implementation, ensures the session's configured reasoning level is honored (not silently dropped) during context compaction, and removes an artificial 4096-token output cap on the compaction model.
Changes
Notes