fix: skip heartbeat wake for subagent exec completions
When sub-agents run many exec commands (e.g., during builds), each completion triggers requestHeartbeatNow() which wakes the main session. With only 250ms coalesce, this causes heartbeat spam in the main session. This change skips the heartbeat wake when the exec belongs to a subagent session (sessionKey contains ":subagent:"). The system event is still enqueued for the subagent session, but the main session is not woken. Fixes heartbeat spam when sub-agents run background builds or other multi-exec workflows.
This commit is contained in:
parent
01e0d3a320
commit
2ba26bc4e9
@ -318,7 +318,10 @@ function maybeNotifyOnExit(session: ProcessSession, status: "completed" | "faile
|
|||||||
? `Exec ${status} (${session.id.slice(0, 8)}, ${exitLabel}) :: ${output}`
|
? `Exec ${status} (${session.id.slice(0, 8)}, ${exitLabel}) :: ${output}`
|
||||||
: `Exec ${status} (${session.id.slice(0, 8)}, ${exitLabel})`;
|
: `Exec ${status} (${session.id.slice(0, 8)}, ${exitLabel})`;
|
||||||
enqueueSystemEvent(summary, { sessionKey });
|
enqueueSystemEvent(summary, { sessionKey });
|
||||||
requestHeartbeatNow({ reason: `exec:${session.id}:exit` });
|
// Skip heartbeat for subagent exec completions - prevents main session spam
|
||||||
|
if (!sessionKey.includes(":subagent:")) {
|
||||||
|
requestHeartbeatNow({ reason: `exec:${session.id}:exit` });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createApprovalSlug(id: string) {
|
function createApprovalSlug(id: string) {
|
||||||
@ -337,7 +340,10 @@ function emitExecSystemEvent(text: string, opts: { sessionKey?: string; contextK
|
|||||||
const sessionKey = opts.sessionKey?.trim();
|
const sessionKey = opts.sessionKey?.trim();
|
||||||
if (!sessionKey) return;
|
if (!sessionKey) return;
|
||||||
enqueueSystemEvent(text, { sessionKey, contextKey: opts.contextKey });
|
enqueueSystemEvent(text, { sessionKey, contextKey: opts.contextKey });
|
||||||
requestHeartbeatNow({ reason: "exec-event" });
|
// Skip heartbeat for subagent exec events
|
||||||
|
if (!sessionKey.includes(":subagent:")) {
|
||||||
|
requestHeartbeatNow({ reason: "exec-event" });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function runExecProcess(opts: {
|
async function runExecProcess(opts: {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user