agents-relay 1.0.112 → 1.0.114
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/cli.js +4 -1
- package/dist/reconciler.js +21 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -180,8 +180,11 @@ async function runTaskCommand(action, args) {
|
|
|
180
180
|
return;
|
|
181
181
|
}
|
|
182
182
|
if (action === 'retry' || action === 'cancel') {
|
|
183
|
-
if (action === 'retry')
|
|
183
|
+
if (action === 'retry') {
|
|
184
184
|
task.maxAttempts = extendRetryBudget(task);
|
|
185
|
+
if (task.kind === 'planner' && task.error)
|
|
186
|
+
task.plannerRetryFeedback = task.error;
|
|
187
|
+
}
|
|
185
188
|
await transitionTaskEvent(task, action === 'retry' ? 'retry' : task.state === 'RUNNING' ? 'task.cancelled' : 'cancel');
|
|
186
189
|
task.error = action === 'retry' ? null : 'Cancelled by user';
|
|
187
190
|
task.leaseOwner = null;
|
package/dist/reconciler.js
CHANGED
|
@@ -292,7 +292,7 @@ export class Reconciler extends ReconcilerReviewBase {
|
|
|
292
292
|
const contextTask = job.tasks.find(task => task.kind === 'planner') ?? job.tasks[0];
|
|
293
293
|
if (!contextTask)
|
|
294
294
|
return;
|
|
295
|
-
const executionContext = await this.
|
|
295
|
+
const executionContext = await this.plannerContext(job, contextTask);
|
|
296
296
|
for (const planner of job.tasks.filter(task => task.kind === 'planner' && task.state === 'SUCCEEDED' && task.plannerResult)) {
|
|
297
297
|
const children = planner.plannerResult?.next_tasks.map(spec => this.plannerChild(job, planner, spec, executionContext)) ?? [];
|
|
298
298
|
for (const child of children) {
|
|
@@ -313,6 +313,17 @@ export class Reconciler extends ReconcilerReviewBase {
|
|
|
313
313
|
runtimes: this.options.adapters.map(adapter => ({ name: adapter.name, id: adapter.id, capabilities: [...adapter.capabilities] })),
|
|
314
314
|
});
|
|
315
315
|
}
|
|
316
|
+
async plannerContext(job, task) {
|
|
317
|
+
let projectPath = this.options.projectPathForJob ? await this.options.projectPathForJob(job) : task.routing?.cwd ?? process.cwd();
|
|
318
|
+
if (this.store.pullRequestHead) {
|
|
319
|
+
const head = await this.store.pullRequestHead();
|
|
320
|
+
if (!head)
|
|
321
|
+
throw new Error(`PR #${job.prNumber} has no resolvable head ref`);
|
|
322
|
+
const key = `planner-${task.id}-${head.sha.slice(0, 12)}`;
|
|
323
|
+
projectPath = await prepareManagedExecutionWorktree(projectPath, job.repository, job.prNumber, head, key);
|
|
324
|
+
}
|
|
325
|
+
return this.resolvedContext(job, task, 'planner', projectPath);
|
|
326
|
+
}
|
|
316
327
|
async launch(job, task) {
|
|
317
328
|
const adapter = this.options.adapters.find(x => x.name === task.adapter);
|
|
318
329
|
if (!adapter) {
|
|
@@ -443,8 +454,11 @@ export class Reconciler extends ReconcilerReviewBase {
|
|
|
443
454
|
this.plannerLive.set(task.id, { executionId: executionId, controller, timer });
|
|
444
455
|
let promise;
|
|
445
456
|
try {
|
|
446
|
-
const executionContext = await this.
|
|
447
|
-
|
|
457
|
+
const executionContext = await this.plannerContext(job, task);
|
|
458
|
+
const context = { job, tasks: job.tasks, objective: job.objective ?? job.description ?? job.title, previousPlannerTaskId: task.parentTaskId, executionContext, retryFeedback: task.plannerRetryFeedback };
|
|
459
|
+
task.input = plannerInput(context);
|
|
460
|
+
await this.store.saveTask(task);
|
|
461
|
+
promise = planner.plan(context, controller.signal);
|
|
448
462
|
}
|
|
449
463
|
catch (error) {
|
|
450
464
|
await this.finishPlanner(job.id, task.id, executionId, error instanceof Error ? error : new Error(String(error)));
|
|
@@ -465,6 +479,7 @@ export class Reconciler extends ReconcilerReviewBase {
|
|
|
465
479
|
if (task.state === 'CANCELLED')
|
|
466
480
|
return;
|
|
467
481
|
if (error) {
|
|
482
|
+
task.plannerRetryFeedback = error.message;
|
|
468
483
|
task.error = error.message;
|
|
469
484
|
task.leaseOwner = null;
|
|
470
485
|
task.leaseExpiresAt = null;
|
|
@@ -479,7 +494,7 @@ export class Reconciler extends ReconcilerReviewBase {
|
|
|
479
494
|
}
|
|
480
495
|
try {
|
|
481
496
|
const result = parsePlannerResult(raw);
|
|
482
|
-
const executionContext = await this.
|
|
497
|
+
const executionContext = await this.plannerContext(job, task);
|
|
483
498
|
const children = result.next_tasks.map(spec => this.plannerChild(job, task, spec, executionContext));
|
|
484
499
|
for (const child of children) {
|
|
485
500
|
const existing = job.tasks.find(item => item.id === child.id);
|
|
@@ -490,6 +505,7 @@ export class Reconciler extends ReconcilerReviewBase {
|
|
|
490
505
|
task.plannerResult = result;
|
|
491
506
|
task.result = { summary: result.assessment, data: { objective_status: result.objective_status, next_tasks: result.next_tasks } };
|
|
492
507
|
task.error = null;
|
|
508
|
+
task.plannerRetryFeedback = undefined;
|
|
493
509
|
task.leaseOwner = null;
|
|
494
510
|
task.leaseExpiresAt = null;
|
|
495
511
|
task.executionId = null;
|
|
@@ -508,6 +524,7 @@ export class Reconciler extends ReconcilerReviewBase {
|
|
|
508
524
|
await this.emit(eventFor(job.id, task.id, task.parentTaskId, 'planner.children_failed', 'failed', `Planner ${task.id} child materialization failed: ${message}`, 'user'));
|
|
509
525
|
}
|
|
510
526
|
else {
|
|
527
|
+
task.plannerRetryFeedback = message;
|
|
511
528
|
task.error = message;
|
|
512
529
|
task.leaseOwner = null;
|
|
513
530
|
task.leaseExpiresAt = null;
|