From cc061328ed27bc9d8fa748dc737aa4fc0e52ed05 Mon Sep 17 00:00:00 2001 From: tsubasakong Date: Tue, 17 Mar 2026 08:22:49 -0700 Subject: [PATCH 1/2] Use agent.maxSteps for cron step budget instead of hardcoded 30 Cron tasks were aborting mid-execution because the step budget defaulted to 30 (clamped 20-60), far below the configured agent.maxSteps of 100. This caused tasks like "comment on 10 posts" to fail after only 6. - Default cron stepBudget now uses config.agent.maxSteps - Clamp range changed from 20-60 to 80-agent.maxSteps - LLM planner prompt updated to reflect new range - Remove redundant stepBudget fallback in attempt.ts guidance builder Co-Authored-By: Claude Opus 4.6 (1M context) --- src/agent/runtime/attempt.ts | 2 +- src/gateway/chat-assistant.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/agent/runtime/attempt.ts b/src/agent/runtime/attempt.ts index ad2b7a4..31446a9 100644 --- a/src/agent/runtime/attempt.ts +++ b/src/agent/runtime/attempt.ts @@ -191,7 +191,7 @@ function buildCronTaskPlanGuidance(plan: CronTaskPlan | null | undefined): strin .replace(/\s+/g, " ") .trim() .slice(0, 320) || "Finish after completing one focused pass or when the step budget is exhausted."; - const stepBudget = Number.isFinite(plan.stepBudget) ? Math.max(1, Math.round(plan.stepBudget)) : 30; + const stepBudget = plan.stepBudget; const steps = Array.isArray(plan.steps) ? plan.steps .map((step) => String(step || "").replace(/\s+/g, " ").trim()) diff --git a/src/gateway/chat-assistant.ts b/src/gateway/chat-assistant.ts index f681853..0d54bff 100644 --- a/src/gateway/chat-assistant.ts +++ b/src/gateway/chat-assistant.ts @@ -3362,7 +3362,7 @@ export class ChatAssistant { "Capture any meaningful result or confirmation before ending the run.", "Stop after this focused pass and leave remaining work for the next scheduled trigger.", ], - stepBudget: 30, + stepBudget: this.config.agent.maxSteps, completionCriteria: "Finish after one focused pass, once meaningful progress is made, or when the step budget is exhausted.", }; } @@ -3378,7 +3378,7 @@ export class ChatAssistant { return { summary: this.normalizeOneLine(String(value?.summary || "")) || fallback.summary, steps: steps.length > 0 ? steps : fallback.steps, - stepBudget: Math.max(20, Math.min(60, Number(value?.stepBudget) || fallback.stepBudget)), + stepBudget: Math.max(80, Math.min(this.config.agent.maxSteps, Number(value?.stepBudget) || fallback.stepBudget)), completionCriteria: this.normalizeOneLine(String(value?.completionCriteria || "")) || fallback.completionCriteria, }; } @@ -3466,14 +3466,14 @@ export class ChatAssistant { "Output strict JSON only:", '{', ' "steps": ["step 1 description", "step 2 description", ...],', - ' "stepBudget": ,', + ` "stepBudget": ,`, ' "completionCriteria": "when to call finish",', ' "summary": "one-line plan summary for the user"', '}', "", "Rules:", "1) Break the task into 3-8 concrete, actionable steps. Each step should be specific (e.g. 'Open X app and scroll the home feed for 2-3 posts related to Open Pocket' not 'Browse feed').", - "2) Set stepBudget to a realistic number of agent steps needed (typically 20-60). Open-ended monitoring tasks should be capped, not infinite.", + `2) Set stepBudget to a realistic number of agent steps needed (typically 80-${this.config.agent.maxSteps}). Open-ended monitoring tasks should be capped, not infinite.`, "3) completionCriteria must be clear and achievable within a single session. The task will trigger again later, so do NOT try to be exhaustive.", "4) For social media tasks: plan specific interactions (e.g. 'comment on 2-3 relevant posts', 'check profile for new replies'), not open-ended browsing.", "5) For monitoring tasks: do one focused pass, not continuous monitoring. The cron schedule handles repetition.", From 5b6349cdb9032c10f95bd0d4888f534a0e602214 Mon Sep 17 00:00:00 2001 From: tsubasakong Date: Tue, 17 Mar 2026 08:31:30 -0700 Subject: [PATCH 2/2] Update cron step budget test to match new 80-maxSteps range Co-Authored-By: Claude Opus 4.6 (1M context) --- test/chat-assistant.test.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/chat-assistant.test.mjs b/test/chat-assistant.test.mjs index 4abef04..31a9fd0 100644 --- a/test/chat-assistant.test.mjs +++ b/test/chat-assistant.test.mjs @@ -658,8 +658,8 @@ test("ChatAssistant cron planner returns bounded fallback plan without model aut assert.ok(plan); assert.equal(Array.isArray(plan.steps), true); assert.ok(plan.steps.length >= 3); - assert.ok(plan.stepBudget >= 20); - assert.ok(plan.stepBudget <= 60); + assert.ok(plan.stepBudget >= 80); + assert.ok(plan.stepBudget <= 100); assert.match(plan.completionCriteria, /focused pass|step budget/i); });