#17371: fix(heartbeat): always strip HEARTBEAT_OK token from reply text
channel: mattermost
size: XS
Cluster:
HEARTBEAT_OK Suppression Fixes
## Summary
Always strip the `HEARTBEAT_OK` token from reply text. The stripping logic was gated behind `!params.isHeartbeat`, which paradoxically skipped stripping during heartbeat runs — the exact case where the token appears. This caused `HEARTBEAT_OK` to leak into user-visible replies. Removed the `!params.isHeartbeat` guard.
Fixes #16974
## Validation
- [x] `pnpm build` — passed
- [x] `pnpm check` (format + tsgo + lint) — passed
- [x] `pnpm test` — 1073 tests passed (105 test files)
## Scope
- Single focused fix — single file changed (`src/auto-reply/reply/agent-runner-execution.ts`)
## AI-Assistance
- AI-assisted (Claude Code) for implementation
- Human-reviewed: confirmed understanding of changes
- Testing: full local validation suite passed
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Fixes logic bug where `HEARTBEAT_OK` token was paradoxically skipped during heartbeat runs due to incorrect `!params.isHeartbeat` guard. The guard prevented stripping during the exact scenario where the token appears, causing it to leak into user-visible replies when `showOk: false` is configured.
The fix correctly removes the guard so stripping always occurs when the token is present, while preserving the verbose log only for unexpected (non-heartbeat) occurrences. This aligns with other call sites that unconditionally strip the token in streaming contexts.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with no risk - it's a focused, well-tested bug fix
- Single-line logic fix that corrects an obvious bug where the conditional guard was inverted. The change is minimal, focused, and well-validated (1073 tests passed). The fix aligns perfectly with the function's purpose and matches patterns used elsewhere in the codebase
- No files require special attention
<sub>Last reviewed commit: c26f035</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#15575: fix(heartbeat): suppress prefixed HEARTBEAT_OK ack replies (#15505)
by TsekaLuk · 2026-02-13
85.1%
#16321: Fix #12767: suppress HEARTBEAT_OK leakage in Telegram DM replies
by tdjackey · 2026-02-14
83.5%
#19406: fix(heartbeat): filter error payloads from heartbeat reply selection
by namabile · 2026-02-17
80.4%
#23588: fix(auto-reply): suppress repetitive HEARTBEAT_OK loops
by mohandshamada · 2026-02-22
80.0%
#11859: fix: filter HEARTBEAT_OK messages from chat.history when showOk is ...
by Zjianru · 2026-02-08
78.5%
#21014: fix(cron): suppress main-session summary for HEARTBEAT_OK responses
by nickjlamb · 2026-02-19
78.2%
#12786: fix: drop heartbeat runs that arrive while another run is active
by mcaxtr · 2026-02-09
78.2%
#16373: fix: suppress leaked heartbeat poll prompts in reply delivery
by luisecab · 2026-02-14
78.1%
#19339: fix(heartbeat): skip isError payloads when resolving heartbeat reply
by aldoeliacim · 2026-02-17
77.4%
#11647: fix(webchat): filter HEARTBEAT_OK messages from chat.history response
by liuxiaopai-ai · 2026-02-08
77.4%