Skip to content

refactor(agents): trim compaction duplicate tests - #123903

Merged
steipete merged 1 commit into
mainfrom
test/trim-compaction-duplicates
Aug 15, 2026
Merged

steipete merged 1 commit into
mainfrom
test/trim-compaction-duplicates

Conversation

@steipete

Copy link
Copy Markdown
Contributor

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 --check passed.
  • Fresh structured autoreview reported no accepted/actionable findings.
  • Production/test API: +0/-6 (net -6). Tests/test support: +2/-150 (net -148). Total: net -154.

@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 15, 2026 00:30
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Aug 15, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 15, 2026
@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 14, 2026, 8:35 PM ET / August 15, 2026, 00:35 UTC.

ClawSweeper review

What this changes

The 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
Reviewed head: 6b31dfa41380b97f49c335407014f02efe61484b

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused cleanup that preserves stronger owner-boundary coverage while reducing test-only production surface.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored, behavior-neutral test refactor does not require external real-behavior proof; the PR provides focused test-run evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored, behavior-neutral test refactor does not require external real-behavior proof; the PR provides focused test-run evidence.
Evidence reviewed 5 items Provider finalizer remains the owner: The provider path finalizes its generated body with split-turn and preserved-turn sections through the shared budgeting owner; the deleted string wrapper was only a test adapter.
Boundary regression retained: The retained provider-boundary test verifies that final trimming starts at a complete user message, retains the newest raw split-turn message, stays bounded, and preserves recent-turn context.
Persistence coverage remains separately owned: The removed session test injected an already-finalized summary through a test hook; session-manager coverage still persists and reopens a compaction entry, while runtime compaction appends the actual result before replay.
Findings None None.
Security None None.

How this fits together

The 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]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -8, Tests -146. Total -154 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 0 8 -8
Tests 2 2 148 -146
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 2 156 -154

Review metrics

Metric Value Why it matters
Production versus test delta production -6; tests/test support +2/-150 The patch removes a test-only production wrapper and consolidates duplicated coverage at the owner boundary.

Stored data model

Persistent data-model change detected: serialized state: src/agents/sessions/agent-session-compaction.test.ts, unknown-data-model-change: src/agents/sessions/agent-session-compaction.test.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best 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.

Labels

Label changes:

  • add P3: This is a behavior-neutral internal test and test-API cleanup with no identified runtime regression.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored, behavior-neutral test refactor does not require external real-behavior proof; the PR provides focused test-run evidence.

Label justifications:

  • P3: This is a behavior-neutral internal test and test-API cleanup with no identified runtime regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored, behavior-neutral test refactor does not require external real-behavior proof; the PR provides focused test-run evidence.

Evidence

What I checked:

Likely related people:

  • joshavant: Authored the recent suffix-overflow compaction fix and the removed test's originating coverage. (role: recent compaction-feature author; confidence: high; commits: 2ce443d9a46b; files: src/agents/agent-hooks/compaction-safeguard.ts, src/agents/sessions/agent-session-compaction.test.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for 6b31dfa41380b97f49c335407014f02efe61484b:

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.

@steipete
steipete merged commit 61bc612 into main Aug 15, 2026
248 of 251 checks passed
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@steipete
steipete deleted the test/trim-compaction-duplicates branch August 15, 2026 00:40
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant