@workermill/agent 0.7.15 → 0.7.17

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.
Files changed (2) hide show
  1. package/dist/planner.js +18 -7
  2. package/package.json +1 -1
package/dist/planner.js CHANGED
@@ -933,15 +933,25 @@ export async function planTask(task, config, credentials) {
933
933
  console.log(`${ts()} ${taskLabel} ${chalk.yellow("⚠")} ${msg}`);
934
934
  await postLog(task.id, msg);
935
935
  const planningDurationMs = Date.now() - startTime;
936
- return await postValidatedPlan(task.id, bestPlan, config.agentId, taskLabel, elapsed, bestScore, [`Best-plan fallback: critic rejected after ${MAX_ITERATIONS} iterations`], criticHistory, totalFileCapTruncations, planningDurationMs, MAX_ITERATIONS);
936
+ const fallbackPosted = await postValidatedPlan(task.id, bestPlan, config.agentId, taskLabel, elapsed, bestScore, [`Best-plan fallback: critic rejected after ${MAX_ITERATIONS} iterations`], criticHistory, totalFileCapTruncations, planningDurationMs, MAX_ITERATIONS);
937
+ if (fallbackPosted) {
938
+ return true;
939
+ }
940
+ // Fallback post failed (404, 409, etc.) — fall through to plan-failed
941
+ // so the task doesn't stay stuck in "planning" status forever.
942
+ console.log(`${ts()} ${taskLabel} ${chalk.yellow("⚠")} ${PREFIX} Fallback post rejected by server, reporting plan-failed`);
943
+ await postLog(task.id, `${PREFIX} Fallback plan rejected by server — reporting failure`);
937
944
  }
938
- // No usable plan — report failure to server so the task doesn't
939
- // stay in "planning" status forever (which causes an infinite retry loop).
945
+ // No usable plan (or fallback rejected) — report failure to server so
946
+ // the task doesn't stay in "planning" status forever (infinite retry loop).
940
947
  try {
948
+ const failReason = bestPlan && bestScore >= BEST_PLAN_FALLBACK_THRESHOLD
949
+ ? `Best-plan fallback rejected by server after ${MAX_ITERATIONS} iterations (best score: ${bestScore}/100)`
950
+ : `Critic rejected after ${MAX_ITERATIONS} iterations (best score: ${bestScore}/100, threshold: ${AUTO_APPROVAL_THRESHOLD}, fallback minimum: ${BEST_PLAN_FALLBACK_THRESHOLD})`;
941
951
  await api.post("/api/agent/plan-failed", {
942
952
  taskId: task.id,
943
953
  agentId: config.agentId,
944
- reason: `Critic rejected after ${MAX_ITERATIONS} iterations (best score: ${bestScore}/100, threshold: ${AUTO_APPROVAL_THRESHOLD}, fallback minimum: ${BEST_PLAN_FALLBACK_THRESHOLD})`,
954
+ reason: failReason,
945
955
  criticHistory,
946
956
  });
947
957
  }
@@ -990,9 +1000,10 @@ async function postValidatedPlan(taskId, plan, agentId, taskLabel, elapsed, crit
990
1000
  }
991
1001
  catch (error) {
992
1002
  const err = error;
993
- const detail = err.response?.data?.detail || String(error);
994
- console.error(`${ts()} ${taskLabel} ${chalk.red("✗")} Server validation failed: ${detail.substring(0, 100)}`);
995
- await postLog(taskId, `${PREFIX} Server-side plan validation failed: ${detail.substring(0, 200)}`, "error", "error");
1003
+ const detail = err.response?.data?.error || err.response?.data?.detail || String(error);
1004
+ const statusCode = err.response?.status ? ` (${err.response.status})` : "";
1005
+ console.error(`${ts()} ${taskLabel} ${chalk.red("✗")} Server validation failed${statusCode}: ${detail.substring(0, 100)}`);
1006
+ await postLog(taskId, `${PREFIX} Server-side plan validation failed${statusCode}: ${detail.substring(0, 200)}`, "error", "error");
996
1007
  return false;
997
1008
  }
998
1009
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workermill/agent",
3
- "version": "0.7.15",
3
+ "version": "0.7.17",
4
4
  "description": "WorkerMill Remote Agent - Run AI workers locally with your Claude Max subscription",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",