feat(engine): gate executor and heartbeat on allowParallelExecution

When a permanent agent has allowParallelExecution=false, TaskExecutor.execute()
defers if the agent has an active heartbeat run, and HeartbeatScheduler defers
a heartbeat if the agent's bound task has an active executor session. Each side
re-dispatches the other's deferred work on completion via resumeTaskForAgent
and the in-process runtime's onRunCompleted hook.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-05-05 21:20:00 -07:00
parent 8575c48d85
commit 3f2fadd103
10 changed files with 272 additions and 37 deletions

View File

@@ -448,6 +448,13 @@ export class InProcessRuntime
onTerminated: (agentId, reason) => {
runtimeLog.warn(`Agent ${agentId} terminated (unresponsive): ${reason}`);
},
onRunCompleted: (agentId) => {
if (this.executor) {
void this.executor.resumeTaskForAgent(agentId).catch((err) => {
runtimeLog.warn(`resumeTaskForAgent failed for ${agentId}: ${err instanceof Error ? err.message : String(err)}`);
});
}
},
});
this.heartbeatMonitor.start();
}