fix: drop heartbeat runs that arrive while another run is active#25610
Closed
mcaxtr wants to merge 2 commits intoopenclaw:mainfrom
Closed
fix: drop heartbeat runs that arrive while another run is active#25610mcaxtr wants to merge 2 commits intoopenclaw:mainfrom
mcaxtr wants to merge 2 commits intoopenclaw:mainfrom
Conversation
d77683e to
3a953f5
Compare
steipete
added a commit
that referenced
this pull request
Feb 25, 2026
Contributor
|
Implemented and landed on What I changed (reimplemented after code review):
Validation:
Thanks for the report and original PR, @mcaxtr. |
joshavant
pushed a commit
that referenced
this pull request
Feb 25, 2026
margulans
pushed a commit
to margulans/Neiron-AI-assistant
that referenced
this pull request
Feb 25, 2026
@mcaxtr) Co-authored-by: Marcus Castro <mcaxtr@gmail.com>
Jackson3195
pushed a commit
to Jackson3195/openclaw-with-a-personal-touch
that referenced
this pull request
Feb 25, 2026
@mcaxtr) Co-authored-by: Marcus Castro <mcaxtr@gmail.com>
brianleach
pushed a commit
to brianleach/openclaw
that referenced
this pull request
Feb 26, 2026
@mcaxtr) Co-authored-by: Marcus Castro <mcaxtr@gmail.com>
2 tasks
execute008
pushed a commit
to execute008/openclaw
that referenced
this pull request
Feb 27, 2026
@mcaxtr) Co-authored-by: Marcus Castro <mcaxtr@gmail.com>
r4jiv007
pushed a commit
to r4jiv007/openclaw
that referenced
this pull request
Feb 28, 2026
@mcaxtr) Co-authored-by: Marcus Castro <mcaxtr@gmail.com>
6 tasks
zooqueen
pushed a commit
to hanzoai/bot
that referenced
this pull request
Mar 6, 2026
@mcaxtr) Co-authored-by: Marcus Castro <mcaxtr@gmail.com>
thebenjaminlee
pushed a commit
to escape-velocity-ventures/openclaw
that referenced
this pull request
Mar 7, 2026
@mcaxtr) Co-authored-by: Marcus Castro <mcaxtr@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
runReplyAgentthat drops heartbeat runs whenisActive: true, before they reach the enqueue path. Also addedmarkRunComplete()calls to all early-return paths for consistency.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
Users with heartbeat enabled will no longer receive duplicate messages when heartbeat intervals coincide with active agent runs. Heartbeat runs that arrive while another run is active are now silently dropped, and the next heartbeat interval independently re-checks the session.
Security Impact (required)
Repro + Verification
Environment
Steps
Expected
Single message delivered (either HEARTBEAT_OK or brief status update)
Actual
Before fix: 2-4 duplicate messages due to stale heartbeat followup creating additional agent run branches
After fix: Single message only (heartbeat dropped when isActive, next interval re-checks)
Evidence
New test suite with 3 test cases:
All tests pass. Existing agent-runner and heartbeat test suites pass.
Human Verification (required)
Verified scenarios:
pnpm build && pnpm checkpasses (oxfmt, oxlint, tsgo all clean)Edge cases checked:
What I did not verify:
Compatibility / Migration
Failure Recovery (if this breaks)
Risks and Mitigations
Risk: Heartbeat might be dropped too aggressively if isActive logic has false positives
Risk: Subtle differences in markRunComplete() timing across early-return paths
Greptile Summary
This PR fixes a bug where heartbeat runs arriving while another agent run is active would get enqueued as followups, causing duplicate agent runs and multiple response branches delivered to users (2-4 duplicate messages instead of 1).
runReplyAgentthat silently drops heartbeat runs whenisActive: true, before they reach the enqueue path. The next heartbeat interval independently re-checks the session, so no heartbeat cycles are permanently lost.markRunComplete()calls to all pre-tryearly-return paths (steered, heartbeat-dropped, and enqueue paths) for consistency — these paths return before thetry/finallyblock, so without explicitmarkRunComplete()calls the typing controller would skip that step.Confidence Score: 5/5
Last reviewed commit: d77683e