Skip to content

fix: pair successful no-op compaction hooks - #118094

Merged
steipete merged 3 commits into
openclaw:mainfrom
peterolkhov:codex/fix-noop-compaction-hooks
Sep 6, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
peterolkhov:codex/fix-noop-compaction-hooks

Conversation

@peterolkhov

@peterolkhov peterolkhov commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Related: #81925.

A context engine can successfully decide that no compaction is needed. OpenClaw sent before_compaction for that attempt but omitted after_compaction, leaving plugin observers waiting for a completion that never arrived.

Why This Change Was Made

The queued/manual and overflow/timeout recovery emitters now complete successful engine-owned no-ops using the existing compactedCount: 0 payload. Actual compactions retain their existing metrics. Attempts that fail, abort or lose their owner remain excluded. Transcript adoption, checkpoints, maintenance, memory synchronization and native follow-up still require an actual compaction.

The patch is refreshed against the current emitter locations. The original subscriber correction is already on main and is omitted from this change. Existing fixtures cover the current queued and recovery paths without adding a production test seam.

User Impact

Plugins observing a successful no-op receive its completion and can distinguish it from changed history using the existing zero count. This addresses the engine-owned lifecycle part of the linked issue; it does not change native/Copilot hook semantics or validator error wording.

The review’s observer-compatibility concern is accepted for this repair: successful engine-owned no-ops are an existing documented result, and compactedCount: 0 is the existing signal for unchanged history. This follows the maintainer direction on the predecessor. Consumers that need changed history can use the count; the completion remains available to observers waiting for the attempt to finish.

Evidence

Current head: 20158ac193a0878bb92d0be2f465abfacfcad0a9.

Production +2/-4, net −2; tests +34/-4, net +30; reference documentation +4/-0.

Hosted baseline/candidate proof runs the actual Gateway sessions.compact call through a registered external context-engine plugin. Both repeated successful no-ops omit completion on baseline and emit exactly one after_compaction with count zero on the candidate. Returned and thrown failures produce no completion hook on either side. Session accounting and the full transcript remain unchanged, and the provider endpoint receives zero calls.

The queued, overflow and timeout regressions fail on baseline for the intended missing callback; their real-compaction and failed-result controls pass. All six focused cases pass on the candidate, followed by 225 passing current owner/subscriber tests, both private-QA builds and the full check:changed gate. The test includes real plugin loading, hook dispatch and SQLite state access, with a deterministic no-op engine; it does not claim authenticated external-provider testing.

The experiment is pinned to main 954d47a99a6b814da0bb31eb92adeb8603368f20 plus this exact production/test patch. All four emitted source hashes match the composed candidate. Pinned formatting and diff checks pass. Fresh isolated Codex source review through P2 and independent source and proof verification found no actionable findings. The branch now includes the landed CI preflight output-limit repair from main. The previous run stopped before tests at GitHub’s job-output limit; final independent review of the new committed head is also clean. Required CI is green on this exact head.

The ordinary merge preserves the original contributor commits and credit to @peterolkhov. No public hook fields, options, schemas, dependencies or runtime defaults are added.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Aug 2, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Aug 2, 2026
@clawsweeper

clawsweeper Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 6, 2026, 12:47 PM ET / 16:47 UTC.

ClawSweeper review

What this changes

The PR completes plugin notifications after successful engine-owned compaction attempts that leave history unchanged, documents the zero-count result, and adds queued and recovery regression coverage.

Merge readiness

⛔ Blocked before merge - 1 item remains

This remains a useful, focused fix: current main still suppresses successful no-op completion hooks in both affected paths. No introduced correctness defect was found, and the captured production-path evidence supports the narrowed repair.

Priority: P2
Reviewed head: 20158ac193a0878bb92d0be2f465abfacfcad0a9

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful regression coverage and detailed production-path before/after evidence; the observer compatibility tradeoff is explicit.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The captured Gateway sessions.compact baseline/candidate report exercises real plugin loading, engine dispatch, hooks, and SQLite state, observing paired zero-count completions and unchanged state after the fix. Recovery fixtures supplement that production proof. Hosted logs could not be independently opened because reviewer network access failed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The captured Gateway sessions.compact baseline/candidate report exercises real plugin loading, engine dispatch, hooks, and SQLite state, observing paired zero-count completions and unchanged state after the fix. Recovery fixtures supplement that production proof. Hosted logs could not be independently opened because reviewer network access failed.
Evidence reviewed 10 items Current main still needs the repair: Both current-main emitters still require compacted=true before invoking after_compaction, excluding successful engine-owned no-ops.
Recovery completion and ownership guards: The recovery emitter retains its engine-ownership, successful-result, and active-recovery checks. Its callers invoke completion before branching on whether history was compacted; accounting and successor adoption remain separately guarded.
Queued mutation gates remain intact: Checkpoint persistence, maintenance, memory synchronization, and native follow-up still require actual compaction. Only the observer completion gate changes. The changed hook path is owned by OpenClaw's context-engine runtime; nearby optional native-harness integration does not establish a dependency-contract requirement for this repair.
Findings None None.
Security None None.

How this fits together

Context engines manage conversation compaction for OpenClaw agents. Manual requests and overflow or timeout recovery invoke the engine, then notify plugin observers and perform history-related follow-up when compaction actually occurred.

flowchart TD
  A[Manual compaction request] --> C[Context engine attempt]
  B[Overflow or timeout recovery] --> C
  C --> D{Successful and still active?}
  D -->|No| E[No completion hook]
  D -->|Yes| F[Notify plugin observers]
  F --> G{History compacted?}
  G -->|Yes| H[Compaction accounting and follow-up]
  G -->|No| I[Zero-count completion]
Loading

Before merge

  • Resolve merge risk (P1) - External plugin observers that equate every completion callback with changed history will now receive successful no-op callbacks too; the documented compactedCount: 0 signal must be handled appropriately.
Agent review details

Security

None.

PR surface

Source -2, Tests +30, Docs +4. Total +32 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 2 4 -2
Tests 2 34 4 +30
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 40 8 +32

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Retain the documented zero-count contract (recommended)
    Accept the narrowly scoped observer behavior change documented and exercised by this repair, with mutation-dependent consumers using compactedCount.

Technical review

Best possible solution:

Complete successful engine-owned attempts through the existing zero-count hook contract while keeping transcript mutation, accounting, and native follow-up conditional on actual compaction.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: an engine returning {ok:true, compacted:false} reaches the current-main completion gates and is excluded in both paths. This review did not execute the runtime; the captured baseline/candidate report independently describes that failure and recovery.

Is this the best way to solve the issue?

Yes. Removing only the completion predicate and using the existing zero-count payload repairs the lifecycle owner without adding API fields or enabling mutation-only follow-up.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 6b7db226a9a8.

Labels

Label justifications:

  • P2: This fixes a bounded compaction-observer lifecycle defect without changing compaction policy.
  • merge-risk: 🚨 compatibility: Existing external plugin observers will receive completion callbacks for successful no-ops that previously produced none.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The captured Gateway sessions.compact baseline/candidate report exercises real plugin loading, engine dispatch, hooks, and SQLite state, observing paired zero-count completions and unchanged state after the fix. Recovery fixtures supplement that production proof. Hosted logs could not be independently opened because reviewer network access failed.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured Gateway sessions.compact baseline/candidate report exercises real plugin loading, engine dispatch, hooks, and SQLite state, observing paired zero-count completions and unchanged state after the fix. Recovery fixtures supplement that production proof. Hosted logs could not be independently opened because reviewer network access failed.

Evidence

What I checked:

  • Current main still needs the repair: Both current-main emitters still require compacted=true before invoking after_compaction, excluding successful engine-owned no-ops. (src/agents/embedded-agent-runner/compact.queued-execution.ts:495, 6b7db226a9a8)
  • Recovery completion and ownership guards: The recovery emitter retains its engine-ownership, successful-result, and active-recovery checks. Its callers invoke completion before branching on whether history was compacted; accounting and successor adoption remain separately guarded. (src/agents/embedded-agent-runner/run/compaction-runtime.ts:531, 20158ac193a0)
  • Queued mutation gates remain intact: Checkpoint persistence, maintenance, memory synchronization, and native follow-up still require actual compaction. Only the observer completion gate changes. The changed hook path is owned by OpenClaw's context-engine runtime; nearby optional native-harness integration does not establish a dependency-contract requirement for this repair. (src/agents/embedded-agent-runner/compact.queued-execution.ts:495, 20158ac193a0)
  • Existing plugin payload and documented scope: The hook already accepts numeric compactedCount. The documentation explicitly limits the new completion guarantee to successful engine-owned attempts and excludes failures and aborts; no public field or configuration option is added. Public docs: docs/plugins/hooks.md. (docs/plugins/hooks.md:332, 20158ac193a0)
  • Meaningful regression coverage: The added recovery matrix covers overflow and timeout with successful and failed no-op results, checking callback count, unchanged durable transcript and session entry, no successor adoption, no maintenance, and unchanged compaction accounting. The queued test extends the existing success case rather than adding a production test seam. Tests were inspected, not executed. (src/agents/embedded-agent-runner/run.compaction-runtime.test.ts:17, 20158ac193a0)
  • Captured production-path proof: The fully supplied PR body records actual Gateway sessions.compact calls through a registered external engine: repeated baseline no-ops omitted completion, while the candidate emitted exactly one zero-count completion per attempt; returned and thrown failures emitted none, transcript and accounting stayed unchanged, and provider calls remained zero. It links https://github.com/steipete/openclaw/actions/runs/34026610687 and identifies baseline 954d47a plus the exact patch, with matching source hashes. GitHub API access failed and browser retrieval returned a cache miss, so the hosted logs were not independently inspected. This assessment preserves the supplied body under sourceRevision f6b7066018fe29ab8a1ec0b488dc45361591348f949251fe40fe97a44b2ff4d8 rather than substituting newer evidence. (20158ac193a0)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

History

Review history (21 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-06T06:37:26.000Z sha 211e8d0 :: needs changes before merge. :: [P1] Pair direct successful no-op hooks | [P1] Pair Copilot manual successful no-op hooks
  • reviewed 2026-08-08T01:46:32.618Z sha 211e8d0 :: needs changes before merge. :: [P1] Pair native direct successful no-op hooks | [P1] Pair Copilot manual successful no-op hooks
  • reviewed 2026-08-08T21:49:04.387Z sha 211e8d0 :: needs changes before merge. :: [P1] Pair native direct successful no-op hooks | [P1] Pair Copilot manual successful no-op hooks
  • reviewed August 21, 2026, 10:02 PM ET / August 22, 2026, 02:02 UTC sha unknown :: found issues before merge. :: [P1] Pair all successful no-op compaction producers
  • reviewed 2026-08-22T02:02:10.611Z sha 211e8d0 :: found issues before merge. :: [P1] Pair all successful no-op compaction producers
  • reviewed 2026-08-28T12:26:40.341Z sha 211e8d0 :: needs changes before merge. :: [P1] Pair every successful no-op compaction producer
  • reviewed September 5, 2026, 4:03 AM ET / 08:03 UTC sha unknown :: blocked before merge. :: none
  • reviewed 2026-09-06T11:23:48.605Z sha fd8ad9e :: blocked before merge. :: none

@peterolkhov
peterolkhov force-pushed the codex/fix-noop-compaction-hooks branch from 5c0aba0 to aa708d1 Compare August 2, 2026 18:40
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: copilot labels Aug 2, 2026
@peterolkhov

Copy link
Copy Markdown
Contributor Author

Addressed all ClawSweeper rank-up moves and refreshed the branch onto current main:

  • added redacted production-runtime evidence of a successful engine-owned no-op with paired hooks, compactedCount: 0, and explicit compacted: false
  • documented and implemented the compatibility signal across all after_compaction emitters
  • verified mutation-only follow-up remains absent for no-ops
  • reran build, focused tests, the complete changed-surface gate, autoreview, and secret scan

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@openclaw-barnacle openclaw-barnacle Bot added triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 2, 2026
@peterolkhov
peterolkhov force-pushed the codex/fix-noop-compaction-hooks branch 2 times, most recently from 92dabbf to 251956d Compare August 2, 2026 18:44
@peterolkhov

Copy link
Copy Markdown
Contributor Author

Exact-head refresh is complete at 251956d55174970c14f08e97b0ca7d4944540055. The authored Evidence section is present, the Real behavior proof check passes, all exact-head checks are green, and the branch is rebased onto current main.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 2, 2026
@peterolkhov
peterolkhov force-pushed the codex/fix-noop-compaction-hooks branch from 251956d to 699bce2 Compare August 2, 2026 19:09
@peterolkhov

Copy link
Copy Markdown
Contributor Author

Addressed the remaining P1 on exact head 699bce230b2:

  • subscribed after_compaction now requires completed && !willRetry
  • removed the subscriber's false-outcome overload entirely; that emitter can only publish compacted: true
  • aborted, result-plus-aborted, and result-less terminal events now assert that neither the counter nor after_compaction fires
  • reviewer acceptance suite: 4 files / 160 tests passed
  • final post-rebase subscriber/hook rerun: 2 files / 19 tests passed
  • changed-surface gate, formatting, git diff --check, TruffleHog, and autoreview all pass
  • rebased onto 27d1f1afd52

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 2, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 5, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. and removed P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 5, 2026
@steipete steipete self-assigned this Sep 6, 2026
Emit the existing zero-count completion after successful engine-owned no-ops
in queued and recovery paths. Keep failure, cancellation, ownership and
mutation-only follow-up gates intact, and reuse current regression fixtures.

Related: openclaw#81925
Co-authored-by: peterolkhov <peter@useprox.com>
Bring in the landed CI output-limit repair so required checks can admit the
no-op compaction candidate. Preserve the proven hook changes and contributor
ancestry through an ordinary merge.

Co-authored-by: peterolkhov <peter@useprox.com>
@steipete
steipete merged commit 2738afc into openclaw:main Sep 6, 2026
216 of 217 checks passed
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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.

2 participants