agents-relay 1.0.88 → 1.0.90
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pool.js +4 -1
- package/dist/reconciler.js +17 -3
- package/package.json +1 -1
package/dist/pool.js
CHANGED
|
@@ -88,7 +88,10 @@ export class RepositoryWorkerPool {
|
|
|
88
88
|
return;
|
|
89
89
|
}
|
|
90
90
|
const store = new GitHubStore(this.client, target.repository, target.prNumber, this.trustedAuthors);
|
|
91
|
-
|
|
91
|
+
const reconciler = this.makeReconciler(store, Math.max(1, this.concurrency));
|
|
92
|
+
await reconciler.handleEvent(event);
|
|
93
|
+
if (['task.completed', 'task.failed', 'task.blocked', 'task.cancelled'].includes(event.type))
|
|
94
|
+
await reconciler.reconcile(event.job_id);
|
|
92
95
|
}
|
|
93
96
|
async watch(bus) {
|
|
94
97
|
return bus.subscribeAll(async (event) => {
|
package/dist/reconciler.js
CHANGED
|
@@ -72,6 +72,15 @@ Before your final return, verify that a terminal event for this exact Job/Task w
|
|
|
72
72
|
If no terminal event has been published, publish task.failed before exiting.`;
|
|
73
73
|
}
|
|
74
74
|
const taskLaunchClaims = new Set();
|
|
75
|
+
const terminalExecutionClaims = new Set();
|
|
76
|
+
function claimTerminalExecution(sourceId) {
|
|
77
|
+
terminalExecutionClaims.add(sourceId);
|
|
78
|
+
const cleanup = setTimeout(() => terminalExecutionClaims.delete(sourceId), 60000);
|
|
79
|
+
cleanup.unref();
|
|
80
|
+
}
|
|
81
|
+
function terminalExecutionClaimed(jobId, taskId, executionId) {
|
|
82
|
+
return terminalExecutionClaims.has(executionEventSource(jobId, taskId, executionId));
|
|
83
|
+
}
|
|
75
84
|
export class Reconciler {
|
|
76
85
|
store;
|
|
77
86
|
options;
|
|
@@ -766,7 +775,7 @@ export class Reconciler {
|
|
|
766
775
|
if (!task || task.executionId !== executionId)
|
|
767
776
|
return;
|
|
768
777
|
await this.emit(eventFor(jobId, taskId, task.parentTaskId, task.adapter === 'chatgpt' ? 'task.process.async_exited' : 'task.process.exited', error ? 'failed' : 'succeeded', error ?? result?.summary ?? 'Worker runtime exited', 'orchestrator', { authoritative: false, waitingForTerminalEvent: true, processError: error }, { agent: 'relay', component: 'agents-relay' }));
|
|
769
|
-
if (['QUEUED', 'RUNNING'].includes(task.state) && task.adapter === 'codex')
|
|
778
|
+
if (['QUEUED', 'RUNNING'].includes(task.state) && task.adapter === 'codex' && !terminalExecutionClaimed(jobId, taskId, executionId))
|
|
770
779
|
this.scheduleUnexpectedExit(jobId, taskId, executionId, workerStarted === true);
|
|
771
780
|
}
|
|
772
781
|
scheduleUnexpectedExit(jobId, taskId, executionId, workerStarted) {
|
|
@@ -778,9 +787,11 @@ export class Reconciler {
|
|
|
778
787
|
this.terminalExitGraceTimers.set(taskId, timer);
|
|
779
788
|
}
|
|
780
789
|
async failUnexpectedExit(jobId, taskId, executionId, workerStarted) {
|
|
790
|
+
if (terminalExecutionClaimed(jobId, taskId, executionId))
|
|
791
|
+
return;
|
|
781
792
|
const job = await this.store.load(jobId);
|
|
782
793
|
const task = job.tasks.find(item => item.id === taskId);
|
|
783
|
-
if (!task || task.executionId !== executionId || !['QUEUED', 'RUNNING'].includes(task.state))
|
|
794
|
+
if (!task || task.executionId !== executionId || !['QUEUED', 'RUNNING'].includes(task.state) || terminalExecutionClaimed(jobId, taskId, executionId))
|
|
784
795
|
return;
|
|
785
796
|
const reason = workerStarted ? 'worker_exit_without_terminal_event' : 'worker_exit_before_start';
|
|
786
797
|
const message = workerStarted
|
|
@@ -848,7 +859,10 @@ export class Reconciler {
|
|
|
848
859
|
const terminalWaiter = this.terminalWaiters.get(task.id);
|
|
849
860
|
if (terminalWaiter && (!event.timestamp || new Date(event.timestamp).getTime() < terminalWaiter.launchBarrier))
|
|
850
861
|
return;
|
|
851
|
-
|
|
862
|
+
const acceptedExecutionId = task.executionId;
|
|
863
|
+
if (modelBacked && acceptedExecutionId)
|
|
864
|
+
claimTerminalExecution(executionEventSource(job.id, task.id, acceptedExecutionId));
|
|
865
|
+
this.clearExecution(task.id, acceptedExecutionId);
|
|
852
866
|
task.leaseOwner = null;
|
|
853
867
|
task.leaseExpiresAt = null;
|
|
854
868
|
task.updatedAt = event.timestamp || new Date().toISOString();
|