Skip to content

Make compaction visible and resume final replies#76651

Merged
steipete merged 6 commits into
openclaw:mainfrom
simplyclever914:fix/compaction-visible-resume
May 3, 2026
Merged

Make compaction visible and resume final replies#76651
steipete merged 6 commits into
openclaw:mainfrom
simplyclever914:fix/compaction-visible-resume

Conversation

@simplyclever914

Copy link
Copy Markdown
Contributor

Summary

  • add a bundled compaction-notifier hook for visible before/after compaction chat notices
  • retry once with a compacted-transcript continuation instruction when automatic compaction happens and the turn otherwise has no final visible payload
  • document the new hook

Why

A mid-turn compaction can make chat surfaces look stuck and can leave the user without a final assistant reply after tool work. The continuation retry asks the model to finish from the compacted transcript without restarting or rerunning completed tools.

Test plan

  • local basic syntax smoke over changed TypeScript files
  • not run: full repository test suite (large monorepo; opened from minimal source snapshot)

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: S labels May 3, 2026
@clawsweeper

clawsweeper Bot commented May 3, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Summary
The PR adds a bundled compaction notifier hook, routes compaction hook messages to chat surfaces, documents the hook, and retries once from the compacted transcript when auto-compaction leaves no final visible reply.

Reproducibility: yes. by source inspection for the PR behavior and prior blockers: current main lacks the hook/retry, while the latest head routes hook messages through routeReply and adds focused coverage. I did not run runtime tests because this review was read-only.

Next step before merge
The branch is dirty against current main and needs maintainer rebase plus validation rather than an automated repair for a specific remaining code defect.

Security
Cleared: Cleared: the diff adds runtime hook/retry delivery plus docs and changelog, with no dependency, workflow, package-script, permission, secret-handling, or external-download changes.

Review details

Best possible solution:

Rebase the branch onto current main, rerun the focused tests and changed gate, then merge if maintainer validation confirms the visible compaction notices and replay-safe retry behavior.

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

Yes by source inspection for the PR behavior and prior blockers: current main lacks the hook/retry, while the latest head routes hook messages through routeReply and adds focused coverage. I did not run runtime tests because this review was read-only.

Is this the best way to solve the issue?

Yes for the current code direction: it reuses the existing internal hook messages contract and existing reply router, and the retry is narrowly side-effect guarded. It still needs conflict resolution and maintainer-side validation before merge.

Acceptance criteria:

  • pnpm test src/agents/pi-embedded-runner/compact.hooks.test.ts src/agents/pi-embedded-runner/run.incomplete-turn.test.ts src/hooks/frontmatter.test.ts src/hooks/loader.test.ts
  • pnpm exec oxfmt --check --threads=1 src/agents/pi-embedded-runner/run.ts src/agents/pi-embedded-runner/compact.ts src/agents/pi-embedded-runner/compaction-hooks.ts src/hooks/bundled/compaction-notifier/handler.ts src/hooks/bundled/compaction-notifier/HOOK.md docs/automation/hooks.md CHANGELOG.md
  • pnpm check:changed

What I checked:

Likely related people:

  • steipete: Introduced the split compaction hook module and has recent maintainer commits in the embedded runner and auto-reply delivery paths relevant to retry and visible reply behavior. (role: introduced behavior and recent maintainer; confidence: high; commits: 3fdd7c9e0047, 8f20d03373f8, 1c300cec5d80; files: src/agents/pi-embedded-runner/compact.ts, src/agents/pi-embedded-runner/compaction-hooks.ts, src/agents/pi-embedded-runner/run.ts)
  • vincentkoc: Carried broad agent/runtime seam extraction that touched the compaction, embedded runner, hook, and auto-reply surfaces this PR builds on. (role: adjacent refactor owner; confidence: medium; commits: 74e7b8d47b18, 97d1b88e3faa, 7308e72fac98; files: src/agents/pi-embedded-runner/compact.types.ts, src/agents/pi-embedded-runner/compaction-hooks.ts, src/agents/pi-embedded-runner/compaction-runtime-context.ts)
  • BunsDev: Recently touched compaction hook tests and compaction hook side-effect plumbing while reducing WebUI/session latency churn, and is associated with adjacent compaction visibility UX work. (role: recent adjacent maintainer; confidence: medium; commits: 05c9492bff0f; files: src/agents/pi-embedded-runner/compact.hooks.test.ts, src/agents/pi-embedded-runner/compaction-hooks.ts, docs/web/webchat.md)

Remaining risk / open question:

  • The public PR API reports mergeable_state: dirty, so the branch needs rebase or conflict resolution before it can merge.
  • Only label/auto-response check runs were visible on the PR head through the public API; targeted tests and pnpm check:changed are author-reported and should be rerun by maintainers.
  • This read-only review did not execute tests or formatters in the checkout.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 8c95664e5596.

@simplyclever914

Copy link
Copy Markdown
Contributor Author

Addressed the Codex review blockers in the PR branch:

  • gated the compaction continuation retry with the existing resolveAttemptReplayMetadata(attempt).hadPotentialSideEffects replay-safety semantics
  • replaced the hook's explicit any with HookHandler plus typed Record<string, unknown> context narrowing
  • added an Unreleased changelog bullet

Local validation available in this environment: a focused explicit-any smoke over the changed TS files passed. I could not run the requested pnpm test/oxfmt lanes from this source snapshot because dependencies are not installed here (node_modules missing).

@simplyclever914

Copy link
Copy Markdown
Contributor Author

Validation follow-up after installing dependencies locally:

  • pnpm test src/agents/pi-embedded-runner/run.incomplete-turn.test.ts src/hooks/frontmatter.test.ts src/hooks/loader.test.ts ✅ — 3 shards passed, 126 tests passed
  • pnpm exec oxfmt --check --threads=1 src/agents/pi-embedded-runner/run.ts src/hooks/bundled/compaction-notifier/handler.ts src/hooks/bundled/compaction-notifier/HOOK.md docs/automation/hooks.md CHANGELOG.md
  • pnpm check:changed

I also pushed a formatting/validation follow-up commit.

simplyclever914 and others added 4 commits May 3, 2026 14:35
When an automatic compaction happens mid-turn, chat users currently see a long stall and the run can finish without a final visible answer.

This adds an optional bundled compaction notifier hook and a one-shot compacted-transcript continuation retry when a compaction produced no user-visible final payload.
- gate the compaction continuation retry on existing replay side-effect metadata
- type the bundled compaction notifier hook without explicit any
- add an Unreleased changelog entry
- apply oxfmt formatting to changed files
- keep replay-safety, typed hook, and changelog fixes
- validated targeted tests, oxfmt check, and check:changed locally
@simplyclever914

Copy link
Copy Markdown
Contributor Author

Addressed the updated Codex findings:

  • compaction internal hook event.messages are now delivered through routeReply when the compaction run has an originating chat target, so the bundled compaction-notifier messages are actually visible to users
  • restored the unrelated CHANGELOG.md entries by rebasing the changelog edit on origin/main and keeping only this PR's new bullet
  • added focused coverage for before/after compaction hook message delivery

Validation rerun locally:

  • pnpm test src/agents/pi-embedded-runner/compact.hooks.test.ts src/agents/pi-embedded-runner/run.incomplete-turn.test.ts src/hooks/frontmatter.test.ts src/hooks/loader.test.ts ✅ — 4 files / 3 shards, 129 tests passed
  • pnpm exec oxfmt --check --threads=1 ...changed files...
  • pnpm check:changed

@steipete
steipete force-pushed the fix/compaction-visible-resume branch from 64c6271 to 204f19b Compare May 3, 2026 13:43
@steipete
steipete merged commit 89ac126 into openclaw:main May 3, 2026
5 checks passed
lxe pushed a commit to lxe/openclaw that referenced this pull request May 6, 2026
lxe pushed a commit to lxe/openclaw that referenced this pull request May 6, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 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 docs Improvements or additions to documentation size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants