Fix exec heartbeat wake scoping to prevent cross-agent fan-out#31729
Fix exec heartbeat wake scoping to prevent cross-agent fan-out#31729altaywtf wants to merge 3 commits intoopenclaw:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6124db32ad
ℹ️ 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".
src/gateway/server-node-events.ts
Outdated
|
|
||
| enqueueSystemEvent(text, { sessionKey, contextKey: runId ? `exec:${runId}` : "exec" }); | ||
| requestHeartbeatNow({ reason: "exec-event" }); | ||
| requestHeartbeatNow({ reason: "exec-event", sessionKey }); |
There was a problem hiding this comment.
Avoid session-scoping wakes for non-agent node exec keys
Passing sessionKey unconditionally here makes exec-event wakes targeted even when the payload used the fallback non-agent key (node-... when obj.sessionKey is missing). In that case the runner resolves the target agent from the session key (resolveAgentIdFromSessionKey) to main and returns skipped/disabled if main is not an enabled heartbeat agent, so node exec completions can stop triggering any heartbeat in configs that only define non-main agents; before this change, the unscoped wake still ran enabled agents.
Useful? React with 👍 / 👎.
Greptile SummaryThis PR correctly scopes exec-driven heartbeat wake events to their originating session by passing Key observations:
Confidence Score: 4/5
Last reviewed commit: 6124db3 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9ebf1c465e
ℹ️ 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".
| } | ||
| enqueueSystemEvent(text, { sessionKey, contextKey: opts.contextKey }); | ||
| requestHeartbeatNow({ reason: "exec-event" }); | ||
| requestHeartbeatNow({ reason: "exec-event", sessionKey }); |
There was a problem hiding this comment.
Guard scoped exec wakes to agent session keys
emitExecSystemEvent now always passes sessionKey to requestHeartbeatNow, but defaults.sessionKey is not guaranteed to be agent-scoped (the caller keeps non-agent keys too, e.g. global; see src/agents/bash-tools.exec.ts:195-201), and targeted wakes are routed via resolveAgentIdFromSessionKey (src/infra/heartbeat-runner.ts:1122-1124), which maps non-agent keys to main. In configs where heartbeat is enabled for non-main agents, exec completions from legacy/global sessions will be dropped as skipped/disabled instead of waking the enabled agent(s), which is a regression from the previous unscoped behavior.
Useful? React with 👍 / 👎.
9ebf1c4 to
9952460
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9952460a39
ℹ️ 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".
| : `Exec ${status} (${session.id.slice(0, 8)}, ${exitLabel})`; | ||
| enqueueSystemEvent(summary, { sessionKey }); | ||
| requestHeartbeatNow({ reason: `exec:${session.id}:exit` }); | ||
| requestHeartbeatNow({ reason: `exec:${session.id}:exit`, sessionKey }); |
There was a problem hiding this comment.
Keep notify-on-exit wakes unscoped for non-agent sessions
Adding sessionKey unconditionally here makes notify-on-exit wakes targeted even when exec runs are tied to non-agent keys (for example createExecTool forwards defaults.sessionKey directly in src/agents/bash-tools.exec.ts:195,485, and callers can pass sessionId when no session key exists in src/agents/pi-embedded-runner/run/attempt.ts:587). Targeted wakes resolve non-agent keys to main (src/infra/heartbeat-runner.ts:1122-1128), so installations with heartbeat enabled only on non-main agents will skip these exec completion wakes entirely, whereas the prior unscoped behavior still ran enabled agents.
Useful? React with 👍 / 👎.
ec5463a to
d1beab4
Compare
|
Superseding with a fresh draft PR (same body) to reset branch history after rebase. |
|
Closed in favor of new draft PR: |
|
Superseded by the new draft PR: #32724 |
Summary
sessionKeywhen callingrequestHeartbeatNow, and regression tests enforce no cross-agent fan-out for scoped exec wakes.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
Security Impact (required)
Repro + Verification
Environment
Steps
Expected
Actual
Evidence
Trace/log snippets (local):
pnpm test src/agents/bash-tools.exec-runtime.test.ts src/gateway/server-node-events.test.ts src/agents/bash-tools.test.tsTest Files 3 passed (3)Tests 38 passed (38)pnpm test src/infra/heartbeat-runner.scheduler.test.ts src/infra/heartbeat-wake.test.tsTest Files 2 passed (2)Tests 20 passed (20)pnpm check(format/type/lint guardrails passed)Human Verification (required)
emitExecSystemEventemits scoped wake calls withsessionKey.sessionKey.exec-eventwakes do not trigger unrelated agents.Compatibility / Migration
Failure Recovery (if this breaks)
6124db32a.tools.exec.notifyOnExit=falseto stop exec-driven wake paths.src/agents/bash-tools.exec-runtime.tssrc/gateway/server-node-events.tsRisks and Mitigations
mainby existing session-key semantics.sessionKeystill gets unscoped behavior.sessionKey; tests enforce this contract.