Force manual compaction past empty kept-tail cuts#94046
Conversation
97fafad to
7706e3e
Compare
This comment has been minimized.
This comment has been minimized.
70e9f51 to
fd09d2e
Compare
Local E2E verification (real LLM call)Exercised the forced manual-compaction path end-to-end from source — in-process embedded runner, isolated Forcing works as intended. A 2-message session (transcript text well under the 20k Session lifecycle. Stays in the same session — same session id, same transcript file, Proof caveats (what wasn't covered):
|
|
Codex review: found issues before merge. Reviewed June 26, 2026, 2:11 PM ET / 18:11 UTC. Summary PR surface: Source +48, Tests +196. Total +244 across 6 files. Reproducibility: yes. with medium confidence: the PR tests construct a high-usage tiny transcript where the planner selects no messages, and the discussion includes after-fix live output from manual Review metrics: 1 noteworthy metric.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Copy recommended automerge instructionNext step before merge
Security Review findings
Review detailsBest possible solution: Keep the forced manual checkpoint behavior, but route the manual-only force through an internal helper or explicitly approve and document it as public SDK API before merge. Do we have a high-confidence way to reproduce the issue? Yes, with medium confidence: the PR tests construct a high-usage tiny transcript where the planner selects no messages, and the discussion includes after-fix live output from manual Is this the best way to solve the issue? No as submitted: the manual compaction behavior is targeted, but exposing the control as a public SDK option still needs maintainer approval or internalization. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 1cd6f81a46ae. Label changesLabel justifications:
Evidence reviewedPR surface: Source +48, Tests +196. Total +244 across 6 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
Problem
Manual
/compactfailed to create a checkpoint when a session reported high context usage but held only a tiny transcript.Context size is measured from provider usage (
usage.totalTokens, which includes the cached system prompt and tool definitions), so it can read ~170k even when the actual conversation is just a couple of short messages. In that state the cut-point planner keeps the whole branch within thekeepRecentTokens(20k) budget and selects zero older messages, soprepareCompactionreturnsundefined:/compactinstead surfaced a confusingNothing to compact (session too small), even though the user explicitly asked for a checkpoint."0 messages to summarize" here means "the retained-tail heuristic found no old prefix to replace" — not "the session is empty".
Fix
forceoption toprepareCompaction. Manual session/harness compaction passforce: true; automatic does not. When the heuristic would summarize zero messages, the forced path summarizes the whole branch so/compactproduces a real checkpoint.firstKeptEntryIdon the last valid cut point (findValidCutPoints, which excludes tool results), not the raw final entry.Further context
force, the zero-message case still returnsundefined→ skip, so automatic compaction never writes empty no-op summaries.forcepath is narrowly scoped. It only changes the zero-old-prefix case; every normal cut runs untouched. Truly empty / already-compacted sessions are still refused — the path proceeds only when there is at least one real message.hardenManualCompactionBoundary), nothing is dropped silently.undefinedrather than emitting an orphan.Tests
pnpm test packages/agent-core/src/harness/compaction/compaction.test.ts— automatic skip, manual force, and the valid-anchor / no-orphan-tool-result regressionpnpm test src/agents/embedded-agent-runner/manual-compaction-boundary.test.tspnpm test src/agents/embedded-agent-runner/compact.hooks.test.ts