Skip to content

fix(exec): skip heartbeat wake for subagent sessions#2514

Open
BingqingLyu wants to merge 1 commit into
mainfrom
fork-pr-66749-fix-subagent-exec-event-heartbeat
Open

fix(exec): skip heartbeat wake for subagent sessions#2514
BingqingLyu wants to merge 1 commit into
mainfrom
fork-pr-66749-fix-subagent-exec-event-heartbeat

Conversation

@BingqingLyu

@BingqingLyu BingqingLyu commented Apr 28, 2026

Copy link
Copy Markdown
Owner

Summary

Skip requestHeartbeatNow for subagent session keys in both maybeNotifyOnExit() and emitExecSystemEvent(). Subagent sessions receive exec results via process poll and report completion via subagent_announce, so the exec-event heartbeat wake is redundant and wasteful.

Problem

Each background exec completion in a subagent triggers requestHeartbeatNow({reason: "exec-event"}). Since resolveHeartbeatSession falls back subagent keys to the main session, this causes spurious heartbeat wake-ups (and LLM calls) on the parent agent every time a subagent exec finishes.

In a session with 47 subagent exec calls, this produced ~50 unnecessary LLM invocations.

Changes

  • Guard both requestHeartbeatNow call sites with isSubagentSessionKey(sessionKey)
  • Add import for isSubagentSessionKey from session-key-utils.js
  • Add test case verifying heartbeat wake is skipped for subagent session keys

Testing

  • New test: emitExecSystemEvent with subagent session key → requestHeartbeatNow not called (but enqueueSystemEvent still fires)
  • Existing tests for non-subagent and empty session keys remain unchanged

Fixes openclaw#66748

@BingqingLyu BingqingLyu added conflicting-group-1 Conflicting PR group 1 — review as a batch conflicting-pr Shares at least one cross-PR dependency with other PRs labels May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflicting-group-1 Conflicting PR group 1 — review as a batch conflicting-pr Shares at least one cross-PR dependency with other PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Subagent background exec triggers spurious heartbeat wake-ups on main session

1 participant