feat: send compaction start and completion notices#67830
Conversation
Greptile SummaryThis PR extends Confidence Score: 5/5Safe to merge — the completion notice is gated behind the existing opt-in flag and all P0/P1 paths are unchanged. Both findings are P2: one is a niche UX edge case for compaction failures (which almost always surface a separate error payload anyway), and the other is a missing test for a code path whose logic is directly symmetric with already-tested start-notice behavior. No correctness, data-integrity, or security issues were found. No files require special attention.
|
| const completed = evt.data?.completed === true; | ||
| if (phase === "end" && completed) { | ||
| attemptCompactionCount += 1; | ||
| await params.opts?.onCompactionEnd?.(); | ||
| if (params.opts?.onCompactionEnd) { | ||
| await params.opts.onCompactionEnd(); | ||
| } else if (shouldNotifyUserAboutCompaction) { | ||
| await sendCompactionNotice("end"); | ||
| } | ||
| } |
There was a problem hiding this comment.
No end notice when compaction starts but doesn't complete
When notifyUser: true and a compaction event fires with phase === "end" but completed !== true (i.e., compaction ran but didn't finish successfully), users will see "🧹 Compacting context..." with no follow-up message. In most failure scenarios the agent turn also fails and the user gets an error payload, so it's rarely noticed in practice — but the asymmetry is worth being aware of. A "🧹 Compaction incomplete" notice (or clearing the start notice) could improve UX for the edge case where the session continues after an incomplete compaction.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/auto-reply/reply/agent-runner-execution.ts
Line: 530-538
Comment:
**No end notice when compaction starts but doesn't complete**
When `notifyUser: true` and a compaction event fires with `phase === "end"` but `completed !== true` (i.e., compaction ran but didn't finish successfully), users will see "🧹 Compacting context..." with no follow-up message. In most failure scenarios the agent turn also fails and the user gets an error payload, so it's rarely noticed in practice — but the asymmetry is worth being aware of. A "🧹 Compaction incomplete" notice (or clearing the start notice) could improve UX for the edge case where the session continues after an incomplete compaction.
How can I resolve this? If you propose a fix, please make it concise.631a284 to
ef9e6ec
Compare
Code reviewFound 1 issue:
https://github.com/openclaw/openclaw/blob/ef9e6ecdfe7dd96be554795a08065b7957845491/src/config/schema.base.generated.ts#L1-L2 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
a16ce30 to
c9e3547
Compare
027ceeb to
65f8dd5
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 65f8dd582b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } else if (shouldNotifyUserAboutCompaction) { | ||
| await sendCompactionNotice("incomplete"); |
There was a problem hiding this comment.
Respect onCompactionEnd for incomplete compaction events
When compaction ends with completed !== true, this branch still emits the fallback 🧹 Compaction incomplete notice whenever notifyUser is enabled, even if the caller already provided onCompactionEnd. Channels that wire custom compaction UX callbacks (for example extensions/telegram/src/bot-message-dispatch.ts:915-933 and extensions/discord/src/monitor/message-handler.process.ts:921-933) can then show an unexpected extra chat message during failed/incomplete compactions, which breaks callback precedence established for start/completed events. Gate this fallback on !params.opts?.onCompactionEnd as well.
Useful? React with 👍 / 👎.
c6d45c3 to
5a58251
Compare
- Regenerate config baseline sha256 (pnpm config:docs:gen) - Add incomplete compaction notice when compaction ends without completing - Add test for onCompactionEnd callback precedence over notifyUser notice - Add test for incomplete compaction notice delivery
5a58251 to
abedf6c
Compare
|
Merged via squash.
Thanks @feniix! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: abedf6cf11
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } else if (shouldNotifyUserAboutCompaction) { | ||
| await sendCompactionNotice("incomplete"); |
There was a problem hiding this comment.
Skip incomplete notice during retrying compaction
This branch sends 🧹 Compaction incomplete for every phase === "end" event with completed !== true, but compaction retry events can legitimately end with completed: false and willRetry: true before a later successful retry. In that case, users with notifyUser enabled will see a misleading failure notice even though compaction is still in progress and may complete moments later. Please gate the incomplete notice on a non-retrying terminal end (for example, when willRetry is not true) to avoid false alarm messages.
Useful? React with 👍 / 👎.
Summary
agents.defaults.compaction.notifyUseronly surfaced a start notice, so messaging users could still see a long silent pause until the final reply arrived.agents.defaults.compaction.notifyUserconfig to send both🧹 Compacting context...and🧹 Compaction complete, add targeted coverage for the completion notice path, and update the config/docs wording to match.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause / Regression History (if applicable)
For bug fixes or regressions, explain why this happened, not just what changed. Otherwise write
N/A. If the cause is unclear, writeUnknown.git blame, prior PR, issue, or refactor if known): existing behavior already supported start notices vianotifyUser; this PR extends that same surface to cover completion.Regression Test Plan (if applicable)
For bug fixes or regressions, name the smallest reliable test coverage that should have caught this. Otherwise write
N/A.src/auto-reply/reply/agent-runner-execution.test.tsagents.defaults.compaction.notifyUseris enabled and compaction completes successfully, the messaging surface receives both the start and completion notices.User-visible / Behavior Changes
agents.defaults.compaction.notifyUser: truenow sends a completion notice in addition to the existing start notice.Diagram (if applicable)
Security Impact (required)
Yes/No) NoYes/No) NoYes/No) NoYes/No) NoYes/No) NoYes, explain risk + mitigation:Repro + Verification
Environment
agents.defaults.compaction.notifyUser: trueSteps
agents.defaults.compaction.notifyUser.Expected
🧹 Compacting context...when compaction starts.🧹 Compaction completewhen compaction finishes.Actual
Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
onCompactionStart/onCompactionEndcallbacks still keep precedence over default notice delivery.Review Conversations
If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.
Compatibility / Migration
Yes/No) YesYes/No) NoYes/No) NoRisks and Mitigations
agents.defaults.compaction.notifyUserflag and does not affect the default silent mode.