fix(restart): deduplicate reason line in restart sentinel message#32083
fix(restart): deduplicate reason line in restart sentinel message#32083steipete merged 2 commits intoopenclaw:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes duplicate Reason: lines in restart sentinel notifications when payload.message and payload.stats.reason are the same string, reducing noise and improving downstream parsing of system event text.
Changes:
- Update
formatRestartSentinelMessage()to only appendReason:when it differs from the emittedmessage - Add regression tests covering both the deduped and non-deduped cases
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/infra/restart-sentinel.ts |
Adds a reason !== message guard to prevent duplicate reason text in the formatted message output. |
src/infra/restart-sentinel.test.ts |
Adds tests verifying the Reason: line is omitted when redundant and retained when distinct. |
Greptile SummaryThis PR fixes a bug where restart sentinel messages displayed duplicate reason text when no separate note was provided. The fix adds a simple equality check ( Key changes:
Impact: Cleaner restart notifications and less confusion for agents parsing system event text. The fix correctly handles edge cases (whitespace trimming, empty strings, undefined values) and maintains the existing behavior when reason differs from message. Confidence Score: 5/5
Last reviewed commit: 7f84254 |
Issue openclaw#32083: Skip Reason: line when it duplicates the message - Add reason !== message check to prevent duplicate reason lines This PR has been tested locally.
When gateway.restart is triggered with a reason but no separate note, the payload sets both message and stats.reason to the same text. formatRestartSentinelMessage() then emits both the message line and a redundant 'Reason: <same text>' line, doubling the restart reason in the notification delivered to the agent session. Skip the 'Reason:' line when stats.reason matches the already-emitted message text. Add regression tests for both duplicate and distinct reason scenarios.
7f84254 to
8e8991a
Compare
|
Landed via temp rebase onto main.
Thanks @velamints2! |
Summary
gateway.restartis triggered with areasonbut no separatenote,formatRestartSentinelMessage()emits the reason text twice: once as themessageline and again asReason: <same text>. This produces noisy restart notifications and can confuse agents that parse system event text.gateway-tool.tssetspayload.message = note ?? reason ?? nullandpayload.stats.reason = reason. Whennoteis undefined (common case), both fields contain the same string.formatRestartSentinelMessage()unconditionally appendsReason: ${reason}without checking for equality with the already-emitted message.Reason:line whenstats.reasonmatches the already-emittedmessagetext. One-line change inrestart-sentinel.ts.What changed
src/infra/restart-sentinel.ts— addreason !== messageguard to skip duplicateReason:linesrc/infra/restart-sentinel.test.ts— add regression tests for both duplicate (same reason/message) and distinct (different reason/message) scenariosBefore / After
Before (reason = message = "Applying config changes"):
After:
Distinct reason/message still works:
What did NOT change