Repository navigation
refactor(agents): trim compaction duplicate tests - #123903
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 14, 2026, 8:35 PM ET / August 15, 2026, 00:35 UTC. ClawSweeper reviewWhat this changesThe PR removes duplicate compaction tests and test-only exports while retaining the split-turn boundary assertion at the provider finalization path. Merge readiness✅ Ready for maintainer review Keep open. This focused maintainer cleanup is not on current main, and the remaining provider-boundary tests preserve the relevant compaction guarantees without the private test wrapper. Priority: P3 Review scores
Verification
How this fits togetherThe compaction safeguard converts long agent-session history into a bounded summary before the session manager persists it and rebuilds replay context. It combines generated summary text with preserved recent turns and split-turn context while keeping message and tool boundaries intact. flowchart LR
A[Long session history] --> B[Compaction safeguard]
B --> C[Provider or built-in summary]
C --> D[Body and suffix budgeting]
D --> E[Session compaction entry]
E --> F[Replayed agent context]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -8, Tests -146. Total -154 across 4 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Land the narrow test/API deletion after ordinary exact-head CI, keeping the provider-finalizer tests as the canonical coverage for summary preservation and message-boundary trimming. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR removes implementation-coupled test coverage rather than addressing a user-reported failure; the supplied focused test evidence covers the retained behavior. Is this the best way to solve the issue? Yes. The deletion removes a wrapper used only by tests, while the retained provider-finalizer test exercises the actual body/suffix budgeting path and its newest-message invariant. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d862148954ad. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Land-ready proof for
Production test API is +0/-6 (net -6); tests/test support are +2/-150 (net -148); total is net -154. The deleted session block was test-only and changes no persisted schema or migration contract. |
|
Merged via squash.
|
What Problem This Solves
The new compaction regression suite included a copied body-budget algorithm, a cross-owner persistence/reopen composition that injected an already-finalized string, a tiny-budget UTF-16 expectation that no longer crossed a surrogate boundary, and a direct split-turn wrapper test duplicated by the real provider finalizer. Those tests would churn under behavior-preserving refactors and kept a production test wrapper plus global test API fields alive.
Why This Change Was Made
The duplicated/private-shape tests are removed. The one unique split-turn invariant—retaining the newest raw message—is added to the existing provider-boundary test that already proves final trimming starts at a complete message. The now-test-only string wrapper and its test API declarations are deleted. Strong owner regressions for provider and built-in bodies, exact marker fits, redacted loss warnings, atomic tool interactions, persistence, and replay remain.
User Impact
No intended visible behavior change. Compaction still preserves generated summary bodies, bounds suffix context, reports loss, and keeps message/tool boundaries intact, with less implementation-coupled coverage and less production test surface.
AI-assisted: yes.
Evidence
node scripts/run-vitest.mjs src/agents/agent-hooks/compaction-safeguard.test.ts src/agents/sessions/agent-session-compaction.test.ts src/agents/sessions/agent-session-loop-correctness.test.ts src/agents/sessions/session-manager.test.ts packages/agent-core/src/harness/session/session-context.test.ts packages/normalization-core/src/utf16-slice.test.ts— 6 files, 225 tests passed across 3 Vitest projects.node scripts/check-changed.mjs -- src/agents/agent-hooks/compaction-safeguard.ts src/agents/agent-hooks/compaction-safeguard.test-support.ts src/agents/agent-hooks/compaction-safeguard.test.ts src/agents/sessions/agent-session-compaction.test.ts— core/coreTests changed gate passed through the documented trusted-source local fallback after no Crabbox/Testbox provider was ready.git diff --checkpassed.