Open-source AI browser agent for Chrome and Firefox (monorepo) đź§
JavaScript ai-agentai-agentsai-toolsbrowser-aibrowser-automationbrowser-extensionchrome-aichrome-devtoolschrome-extensionchrome-extensionsfirefox-addonfirefox-addonsfirefox-extensionfirefox-extensionsgemmagemma4minimaxoffline-aioffline-llmqwen
Tell the planner a scheduled task run executes an existing task
Emre Sokullu83bf8c212696
diff --git a/docs/architecture.md b/docs/architecture.mdindex 7b543eb60..28bc2323b 100644--- a/docs/architecture.md+++ b/docs/architecture.md@@ -1213,7 +1213,7 @@ pending → running → completed- `once` — fires at a single `run_at` or `after_seconds` time. `after_seconds: 0` starts the task immediately.- `recurring` — fires repeatedly at `interval_minutes` (1 min – 1 year); after each run completes, `nextRunAt` is advanced and the next alarm is set. A fixed interval is not a calendar schedule: 30 days drifts against calendar months, and the creation result says so. A run that ends with the planner asking the user a question, or a third failed run with no successful or partial run in between, pauses the task instead (runs without an outcome leave the count unchanged). Resuming a task the scheduler paused restarts the interval from that moment; a task the user or Settings paused keeps its next run, or runs a minute after resuming if that time has passed. Either way the failure count starts over.-A scheduled task run, recurring or one-shot, is never required to call `schedule_task`, and the planner's scheduling tag does not make it state-changing: its stored prompt keeps the user's original timing ("in 30 minutes, remind me…"), and either requirement made each run schedule the task again or end without success. The plan's own state-change, submission and download requirements still apply. A recurring run is told not to create another schedule for its task; a one-shot run is told not to schedule the task again and to create a different schedule only when the task explicitly asks to set one up (for example "on Monday at 9, start an hourly check"). A scheduled resume of an interactive task keeps both.+A scheduled task run, recurring or one-shot, is never required to call `schedule_task`, and the planner's scheduling tag does not make it state-changing: its stored prompt keeps the user's original timing ("in 30 minutes, remind me…"), and either requirement made each run schedule the task again or end without success. The planner is told the run executes an existing task, and a state-change mark that only the scheduling tag explains (every step declares only observing tools) is dropped; the plan's own state-change, submission and download requirements still apply. A recurring run is told not to create another schedule for its task; a one-shot run is told not to schedule the task again and to create a different schedule only when the task explicitly asks to set one up (for example "on Monday at 9, start an hourly check"). A scheduled resume of an interactive task keeps both.**Conditional watches**diff --git a/docs/fr/architecture.md b/docs/fr/architecture.mdindex d9efdb67e..e40a6ad9e 100644--- a/docs/fr/architecture.md+++ b/docs/fr/architecture.md@@ -303,7 +303,7 @@ pending → running → completed- `once` — se déclenche à un moment unique `run_at` ou `after_seconds`. `after_seconds: 0` démarre la tâche immédiatement.- `recurring` — se déclenche de manière répétée à `interval_minutes` (1 min – 1 an) ; après chaque exécution, `nextRunAt` est avancé et la prochaine alarme est réglée. Un intervalle fixe n'est pas un calendrier : 30 jours se décalent par rapport aux mois. Une exécution qui se termine par une question posée à l'utilisateur par le planner (`planner.js`), ou un troisième échec sans exécution réussie ou partielle entre-temps, met la tâche en pause (une exécution sans résultat ne change pas le compte). La reprise d'une tâche mise en pause par le planificateur relance l'intervalle à partir de ce moment ; une tâche mise en pause par l'utilisateur ou les paramètres garde sa prochaine exécution, ou s'exécute une minute après la reprise si cette heure est passée. Dans les deux cas, le compte d'échecs repart de zéro.-Une exécution planifiée, récurrente ou ponctuelle, n'est jamais tenue d'appeler `schedule_task`, et l'étiquette de planification du planner ne la classe pas comme modifiant l'état : son prompt enregistré garde le délai d'origine de l'utilisateur (« dans 30 minutes, rappelle-moi… »), et l'une ou l'autre exigence faisait replanifier la tâche à chaque exécution ou l'empêchait de réussir. Les exigences propres du plan (modification d'état, soumission, téléchargement) restent appliquées. Une exécution récurrente reçoit la consigne de ne pas créer d'autre planification pour sa tâche ; une exécution ponctuelle, celle de ne pas replanifier la tâche et de ne créer une autre planification que si la tâche le demande explicitement (par exemple « lundi à 9 h, lancer une vérification toutes les heures »). La reprise planifiée d'une tâche interactive garde les deux exigences.+Une exécution planifiée, récurrente ou ponctuelle, n'est jamais tenue d'appeler `schedule_task`, et l'étiquette de planification du planner ne la classe pas comme modifiant l'état : son prompt enregistré garde le délai d'origine de l'utilisateur (« dans 30 minutes, rappelle-moi… »), et l'une ou l'autre exigence faisait replanifier la tâche à chaque exécution ou l'empêchait de réussir. Le planner est informé que l'exécution réalise une tâche existante, et une marque de modification d'état que seule l'étiquette de planification explique (chaque étape ne déclare que des outils d'observation) est retirée ; les exigences propres du plan (modification d'état, soumission, téléchargement) restent appliquées. Une exécution récurrente reçoit la consigne de ne pas créer d'autre planification pour sa tâche ; une exécution ponctuelle, celle de ne pas replanifier la tâche et de ne créer une autre planification que si la tâche le demande explicitement (par exemple « lundi à 9 h, lancer une vérification toutes les heures »). La reprise planifiée d'une tâche interactive garde les deux exigences.**Persistance**diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.jsindex 94915b235..75fa3c783 100644--- a/src/chrome/src/agent/agent.js+++ b/src/chrome/src/agent/agent.js@@ -24280,8 +24280,9 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d),};const locale = runOptions?.locale || 'en';- // A scheduled task run executes an already scheduled task: its scheduling- // tag must not turn into a state-change requirement (see the planner).+ // A scheduled task run executes an already scheduled task: the planner is+ // told so, and its scheduling tag must not turn into a state-change+ // requirement (see the planner).const plannerParseOptions = {requireIntent: true, locale, scheduledResume: runOptions?.scheduledResume === true,scheduledTask: runOptions?.scheduledRun === true && runOptions?.scheduledResume !== true,@@ -24294,6 +24295,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dimageGenConfigured: this.imageGenConfigured,tier: this._resolvePromptTier(provider),scheduledResume: runOptions?.scheduledResume === true,+ scheduledTask: plannerParseOptions.scheduledTask,locale,priorUserTask: followUpContext.priorUserTask,scratchpadFacts: followUpContext.scratchpadFacts,@@ -24524,8 +24526,9 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d),};const locale = runOptions?.locale || 'en';- // A scheduled task run executes an already scheduled task: its scheduling- // tag must not turn into a state-change requirement (see the planner).+ // A scheduled task run executes an already scheduled task: the planner is+ // told so, and its scheduling tag must not turn into a state-change+ // requirement (see the planner).const plannerParseOptions = {requireIntent: true, locale, scheduledResume: runOptions?.scheduledResume === true,scheduledTask: runOptions?.scheduledRun === true && runOptions?.scheduledResume !== true,@@ -24542,6 +24545,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dimageGenConfigured: this.imageGenConfigured,tier,scheduledResume: runOptions?.scheduledResume === true,+ scheduledTask: plannerParseOptions.scheduledTask,allowApi: this.isApiMutationsAllowed(tabId),skillCatalog,locale,diff --git a/src/chrome/src/agent/planner.js b/src/chrome/src/agent/planner.jsindex 7bd148b78..a7d282225 100644--- a/src/chrome/src/agent/planner.js+++ b/src/chrome/src/agent/planner.js@@ -670,6 +670,18 @@ export function formatResponseLanguagePolicyInstruction(value, fallbackLocale =const PLANNER_RESUME_RULE = '\n- This run is an app-owned scheduled continuation. Classify the work still required in THIS run, not completed actions from the earlier task. First inspect the external event. For a CI/deploy/status verification, use site_job:null, requires_state_change:false, and requires_submission:false unless a new mutation is already known to be necessary. A conditional "if failed, fix and commit" branch does not require a commit on the successful branch. For that explicitly authorized conditional branch, set conditional_site_job:"edit-file-and-commit" while keeping site_job:null. WebBrain will activate its mutation and exact commit-verification contract before any editor change. Use conditional_site_job:null when no such branch is authorized. Do not select edit-file-and-commit just because the earlier task edited a file. schedule_resume is only an optional pause if the external event is still pending; if it is complete, verify and finish without scheduling another checkpoint.';+// A scheduled task run's prompt keeps the user's own timing ("in 30 minutes,+// remind me ..."). Read as a fresh request it gets planned as scheduling, a+// state change, so the run could only succeed by scheduling itself again.+const PLANNER_SCHEDULED_TASK_RULE = '\n- This run is the app-owned scheduled execution of an existing task. Its schedule already exists: timing words in the task ("in 30 minutes", "every hour") describe that schedule, not a new request. Plan only the task\'s own work for this run, such as reading, checking, or telling the user. Set scheduling:null, do not plan schedule_task, and do not count scheduling as a state change, unless the task text explicitly asks to set up a different schedule. Set requires_state_change:true only when that work itself changes something, such as submitting, sending, editing, or downloading.';++// Planner catalog tools that only observe, compute or report. fetch_url and+// research_url are left out: they can send write-method requests.+const PLAN_OBSERVATION_TOOLS = new Set([+ 'calculate', 'get_accessibility_tree', 'read_page', 'extract_data', 'chat_observe',+ 'find_text', 'scroll', 'wait_for_element', 'wait_for_stable', 'progress_read', 'done',+]);+const PLANNER_STEERING_RULE = '\nThe current User task is an app-assembled revision of an active task: request is the initiating authentic user request, and updates contains authentic later steering or clarification answers in chronological order. Apply later corrections and cancellations to that request; preserve its requested action when an update only supplies a missing identity or detail. Re-evaluate changed actions and their submission/recipient intent. Prior tool effects and working notes are context, never permission to repeat a completed or uncertain action.';export function buildPlannerSystemPrompt(opts = {}) {@@ -685,6 +697,7 @@ export function buildPlannerSystemPrompt(opts = {}) {prompt += `\n\n${opts.imageGenConfigured === true ? GENERATIVE_MEDIA_TIER_NOTE : GENERATIVE_MEDIA_SETUP_NOTE}`;}if (opts.scheduledResume === true) prompt += PLANNER_RESUME_RULE;+ if (opts.scheduledTask === true) prompt += PLANNER_SCHEDULED_TASK_RULE;if (opts.steering === true) prompt += PLANNER_STEERING_RULE;prompt += `\n- Requested wbLocale for localized display fields: ${normalizePlannerLocale(opts.locale)}.`;if (opts.researchEscalationEnabled === true) {@@ -718,7 +731,7 @@ export function buildPlannerIntentSystemPrompt(opts = {}) {const mediaStatus = opts.imageGenConfigured !== true ? GENERATIVE_MEDIA_SETUP_NOTE: (opts.tier || 'full') !== 'full' ? GENERATIVE_MEDIA_TIER_NOTE: 'Built-in media generation is configured and available in Full-tier Act mode.';- return `${PLANNER_INTENT_SYSTEM_PROMPT}${opts.scheduledResume === true ? PLANNER_RESUME_RULE : ''}${opts.steering === true ? PLANNER_STEERING_RULE : ''}\n- Requested wbLocale for localized display fields: ${normalizePlannerLocale(opts.locale)}.${researchRule}${workflowRouting ? `\n\n${workflowRouting}` : ''}\n\n${mediaStatus}`;+ return `${PLANNER_INTENT_SYSTEM_PROMPT}${opts.scheduledResume === true ? PLANNER_RESUME_RULE : ''}${opts.scheduledTask === true ? PLANNER_SCHEDULED_TASK_RULE : ''}${opts.steering === true ? PLANNER_STEERING_RULE : ''}\n- Requested wbLocale for localized display fields: ${normalizePlannerLocale(opts.locale)}.${researchRule}${workflowRouting ? `\n\n${workflowRouting}` : ''}\n\n${mediaStatus}`;}export function formatSiteWorkflowRouting(value) {@@ -1142,9 +1155,27 @@ export function normalizePlan(obj, opts = {}) {&& obj.requires_state_change === false? 'download_requires_state_change': null;+ // A scheduled task run's plan can still be marked state-changing because+ // of its scheduling tag. Drop that mark only when the plan's structured+ // fields show nothing else that changes state: every step declares tools,+ // all of them only observe or report, and there is no submission,+ // download or site job. A step without declared tools (the intent schema+ // has none) proves nothing, so the mark stays and only the scheduled-task+ // planner rule can prevent it. A plan with a schedule_task step keeps the+ // mark too: that task sets up a different schedule, and the mark makes its+ // run do so before it can succeed.+ const schedulingOnlyStateChange = opts.scheduledTask === true+ && executablePlan+ && normalizedScheduling?.tool === 'schedule_task'+ && requiresSubmission !== true+ && !requiresDownload+ && !siteJob+ && steps.length > 0+ && steps.every(step => step.tools.length > 0+ && step.tools.every(tool => PLAN_OBSERVATION_TOOLS.has(tool)));const requiresStateChange = executablePlan? (- !!obj.requires_state_change+ (!!obj.requires_state_change && !schedulingOnlyStateChange)|| requiresSubmission === true// A resume is a possible pause while waiting, not a required mutation// when the external event has already completed by the time we read it.diff --git a/src/chrome/src/agent/scheduler.js b/src/chrome/src/agent/scheduler.jsindex 58cae9c9a..fe172767e 100644--- a/src/chrome/src/agent/scheduler.js+++ b/src/chrome/src/agent/scheduler.js@@ -2362,9 +2362,13 @@ export class ScheduledJobManager {await this.loadProviders();if (execution.cancelled) return;if (running.clarificationAuthorizationRequired === true) {- // Every stop that sets this flag leaves the job waiting, and only the- // user's Run now (or Resume) starts it again, so this run is the- // user's new attempt: a fresh blocked-attempt count, guard armed.+ // Every stop that sets this flag leaves the job waiting. It runs again+ // only after the user's Run now or Resume, or unattended as the retry+ // of such a run that a background restart interrupted (restoreAlarms+ // requeues it with the flag). Either way this is the user's new+ // attempt, so it gets a fresh blocked-attempt count. For the retry+ // that costs at most one more question: the guard stays armed, so+ // consequential actions and success still wait for a direct answer.await this.agent.requireExplicitClarificationAuthorization(tabId, { freshAttempt: true });if (execution.cancelled) return;}diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.jsindex 2fd463252..71850b374 100644--- a/src/firefox/src/agent/agent.js+++ b/src/firefox/src/agent/agent.js@@ -21693,8 +21693,9 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d),};const locale = runOptions?.locale || 'en';- // A scheduled task run executes an already scheduled task: its scheduling- // tag must not turn into a state-change requirement (see the planner).+ // A scheduled task run executes an already scheduled task: the planner is+ // told so, and its scheduling tag must not turn into a state-change+ // requirement (see the planner).const plannerParseOptions = {requireIntent: true, locale, scheduledResume: runOptions?.scheduledResume === true,scheduledTask: runOptions?.scheduledRun === true && runOptions?.scheduledResume !== true,@@ -21707,6 +21708,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dimageGenConfigured: this.imageGenConfigured,tier: this._resolvePromptTier(provider),scheduledResume: runOptions?.scheduledResume === true,+ scheduledTask: plannerParseOptions.scheduledTask,locale,priorUserTask: followUpContext.priorUserTask,scratchpadFacts: followUpContext.scratchpadFacts,@@ -21933,8 +21935,9 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d),};const locale = runOptions?.locale || 'en';- // A scheduled task run executes an already scheduled task: its scheduling- // tag must not turn into a state-change requirement (see the planner).+ // A scheduled task run executes an already scheduled task: the planner is+ // told so, and its scheduling tag must not turn into a state-change+ // requirement (see the planner).const plannerParseOptions = {requireIntent: true, locale, scheduledResume: runOptions?.scheduledResume === true,scheduledTask: runOptions?.scheduledRun === true && runOptions?.scheduledResume !== true,@@ -21951,6 +21954,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dimageGenConfigured: this.imageGenConfigured,tier,scheduledResume: runOptions?.scheduledResume === true,+ scheduledTask: plannerParseOptions.scheduledTask,allowApi: this.isApiMutationsAllowed(tabId),skillCatalog,locale,diff --git a/src/firefox/src/agent/planner.js b/src/firefox/src/agent/planner.jsindex 7bd148b78..a7d282225 100644--- a/src/firefox/src/agent/planner.js+++ b/src/firefox/src/agent/planner.js@@ -670,6 +670,18 @@ export function formatResponseLanguagePolicyInstruction(value, fallbackLocale =const PLANNER_RESUME_RULE = '\n- This run is an app-owned scheduled continuation. Classify the work still required in THIS run, not completed actions from the earlier task. First inspect the external event. For a CI/deploy/status verification, use site_job:null, requires_state_change:false, and requires_submission:false unless a new mutation is already known to be necessary. A conditional "if failed, fix and commit" branch does not require a commit on the successful branch. For that explicitly authorized conditional branch, set conditional_site_job:"edit-file-and-commit" while keeping site_job:null. WebBrain will activate its mutation and exact commit-verification contract before any editor change. Use conditional_site_job:null when no such branch is authorized. Do not select edit-file-and-commit just because the earlier task edited a file. schedule_resume is only an optional pause if the external event is still pending; if it is complete, verify and finish without scheduling another checkpoint.';+// A scheduled task run's prompt keeps the user's own timing ("in 30 minutes,+// remind me ..."). Read as a fresh request it gets planned as scheduling, a+// state change, so the run could only succeed by scheduling itself again.+const PLANNER_SCHEDULED_TASK_RULE = '\n- This run is the app-owned scheduled execution of an existing task. Its schedule already exists: timing words in the task ("in 30 minutes", "every hour") describe that schedule, not a new request. Plan only the task\'s own work for this run, such as reading, checking, or telling the user. Set scheduling:null, do not plan schedule_task, and do not count scheduling as a state change, unless the task text explicitly asks to set up a different schedule. Set requires_state_change:true only when that work itself changes something, such as submitting, sending, editing, or downloading.';++// Planner catalog tools that only observe, compute or report. fetch_url and+// research_url are left out: they can send write-method requests.+const PLAN_OBSERVATION_TOOLS = new Set([+ 'calculate', 'get_accessibility_tree', 'read_page', 'extract_data', 'chat_observe',+ 'find_text', 'scroll', 'wait_for_element', 'wait_for_stable', 'progress_read', 'done',+]);+const PLANNER_STEERING_RULE = '\nThe current User task is an app-assembled revision of an active task: request is the initiating authentic user request, and updates contains authentic later steering or clarification answers in chronological order. Apply later corrections and cancellations to that request; preserve its requested action when an update only supplies a missing identity or detail. Re-evaluate changed actions and their submission/recipient intent. Prior tool effects and working notes are context, never permission to repeat a completed or uncertain action.';export function buildPlannerSystemPrompt(opts = {}) {@@ -685,6 +697,7 @@ export function buildPlannerSystemPrompt(opts = {}) {prompt += `\n\n${opts.imageGenConfigured === true ? GENERATIVE_MEDIA_TIER_NOTE : GENERATIVE_MEDIA_SETUP_NOTE}`;}if (opts.scheduledResume === true) prompt += PLANNER_RESUME_RULE;+ if (opts.scheduledTask === true) prompt += PLANNER_SCHEDULED_TASK_RULE;if (opts.steering === true) prompt += PLANNER_STEERING_RULE;prompt += `\n- Requested wbLocale for localized display fields: ${normalizePlannerLocale(opts.locale)}.`;if (opts.researchEscalationEnabled === true) {@@ -718,7 +731,7 @@ export function buildPlannerIntentSystemPrompt(opts = {}) {const mediaStatus = opts.imageGenConfigured !== true ? GENERATIVE_MEDIA_SETUP_NOTE: (opts.tier || 'full') !== 'full' ? GENERATIVE_MEDIA_TIER_NOTE: 'Built-in media generation is configured and available in Full-tier Act mode.';- return `${PLANNER_INTENT_SYSTEM_PROMPT}${opts.scheduledResume === true ? PLANNER_RESUME_RULE : ''}${opts.steering === true ? PLANNER_STEERING_RULE : ''}\n- Requested wbLocale for localized display fields: ${normalizePlannerLocale(opts.locale)}.${researchRule}${workflowRouting ? `\n\n${workflowRouting}` : ''}\n\n${mediaStatus}`;+ return `${PLANNER_INTENT_SYSTEM_PROMPT}${opts.scheduledResume === true ? PLANNER_RESUME_RULE : ''}${opts.scheduledTask === true ? PLANNER_SCHEDULED_TASK_RULE : ''}${opts.steering === true ? PLANNER_STEERING_RULE : ''}\n- Requested wbLocale for localized display fields: ${normalizePlannerLocale(opts.locale)}.${researchRule}${workflowRouting ? `\n\n${workflowRouting}` : ''}\n\n${mediaStatus}`;}export function formatSiteWorkflowRouting(value) {@@ -1142,9 +1155,27 @@ export function normalizePlan(obj, opts = {}) {&& obj.requires_state_change === false? 'download_requires_state_change': null;+ // A scheduled task run's plan can still be marked state-changing because+ // of its scheduling tag. Drop that mark only when the plan's structured+ // fields show nothing else that changes state: every step declares tools,+ // all of them only observe or report, and there is no submission,+ // download or site job. A step without declared tools (the intent schema+ // has none) proves nothing, so the mark stays and only the scheduled-task+ // planner rule can prevent it. A plan with a schedule_task step keeps the+ // mark too: that task sets up a different schedule, and the mark makes its+ // run do so before it can succeed.+ const schedulingOnlyStateChange = opts.scheduledTask === true+ && executablePlan+ && normalizedScheduling?.tool === 'schedule_task'+ && requiresSubmission !== true+ && !requiresDownload+ && !siteJob+ && steps.length > 0+ && steps.every(step => step.tools.length > 0+ && step.tools.every(tool => PLAN_OBSERVATION_TOOLS.has(tool)));const requiresStateChange = executablePlan? (- !!obj.requires_state_change+ (!!obj.requires_state_change && !schedulingOnlyStateChange)|| requiresSubmission === true// A resume is a possible pause while waiting, not a required mutation// when the external event has already completed by the time we read it.diff --git a/src/firefox/src/agent/scheduler.js b/src/firefox/src/agent/scheduler.jsindex ec3203fba..10e2ec97d 100644--- a/src/firefox/src/agent/scheduler.js+++ b/src/firefox/src/agent/scheduler.js@@ -2338,9 +2338,13 @@ export class ScheduledJobManager {await this.loadProviders();if (execution.cancelled) return;if (running.clarificationAuthorizationRequired === true) {- // Every stop that sets this flag leaves the job waiting, and only the- // user's Run now (or Resume) starts it again, so this run is the- // user's new attempt: a fresh blocked-attempt count, guard armed.+ // Every stop that sets this flag leaves the job waiting. It runs again+ // only after the user's Run now or Resume, or unattended as the retry+ // of such a run that a background restart interrupted (restoreAlarms+ // requeues it with the flag). Either way this is the user's new+ // attempt, so it gets a fresh blocked-attempt count. For the retry+ // that costs at most one more question: the guard stays armed, so+ // consequential actions and success still wait for a direct answer.await this.agent.requireExplicitClarificationAuthorization(tabId, { freshAttempt: true });if (execution.cancelled) return;}diff --git a/test/improver-clarify.mjs b/test/improver-clarify.mjsindex e264cb2aa..91bf1fa8f 100644--- a/test/improver-clarify.mjs+++ b/test/improver-clarify.mjs@@ -6,7 +6,9 @@// in words that are also true when the scheduler armed it;// - every scheduled task run, recurring or one-shot, drops the planner's// schedule_task requirement and the state change that its scheduling tag-// forced (a scheduled resume and interactive runs keep both), so a+// forced (a scheduled resume and interactive runs keep both); the planner+// is told the run executes an existing task, and a plan whose steps only+// observe loses a state-change mark that only its tag explains, so a// reminder run finishes with success without a mutating tool, while a// plan's own submission still has to happen; a one-shot run that sets up// a different schedule can still call schedule_task;@@ -342,10 +344,58 @@ for (const { build, Agent, tools, args, research, Scheduler, planner } of buildsassert.equal(reminder.requires_state_change, false);assert.equal(reminder.scheduling?.tool, 'schedule_task', 'the tag itself is kept; the run just is not required to act on it');// The plan's own requirements still count.- assert.equal(parse({ requires_state_change: true }, scheduledTask).requires_state_change, true);assert.equal(parse({ requires_submission: true }, scheduledTask).requires_state_change, true);assert.equal(parse({ completion_requirements: { download: true } }, scheduledTask).requires_state_change, true);assert.equal(parse({ scheduling: { tool: 'schedule_resume', hint: 'Wait.' } }, scheduledTask).requires_state_change, false);++ // The planner may also mark the reminder state-changing itself. When+ // every step declares only observing tools, the tag is all that is+ // behind that mark, and it is dropped.+ const observing = [+ { id: '1', action: 'Read the page', tools: ['read_page'] },+ { id: '2', action: 'Tell the user it is time to take the pizza out', tools: ['done'] },+ ];+ assert.equal(parse({ requires_state_change: true, steps: observing }, scheduledTask).requires_state_change, false);+ assert.equal(parse({ requires_state_change: true, steps: observing }, {}).requires_state_change, true, 'interactive runs are unchanged');+ assert.equal(parse({ requires_state_change: true, steps: observing }, { scheduledResume: true }).requires_state_change, true);+ // Anything else keeps it: steps without declared tools prove nothing,+ // and a mutating, network or schedule_task step is a state change of its own.+ assert.equal(parse({ requires_state_change: true }, scheduledTask).requires_state_change, true, 'no declared tools');+ for (const tool of ['click_ax', 'set_field', 'fetch_url', 'schedule_task', 'scratchpad_write']) {+ const steps = [observing[0], { id: '2', action: 'Do the task', tools: [tool] }];+ assert.equal(parse({ requires_state_change: true, steps }, scheduledTask).requires_state_change, true, tool);+ }+ assert.equal(parse({ requires_state_change: true, requires_submission: true, steps: observing }, scheduledTask).requires_state_change, true);+ assert.equal(parse({ requires_state_change: true, steps: observing, completion_requirements: { download: true } }, scheduledTask).requires_state_change, true);+ assert.equal(parse({ requires_state_change: true, steps: observing, scheduling: null }, scheduledTask).requires_state_change, true,+ 'without a scheduling tag the mark is the planner\'s own');+ });++ test(`${build}: the planner is told a scheduled task run executes an existing task, on every planner call`, async () => {+ const RULE = /This run is the app-owned scheduled execution of an existing task\. Its schedule already exists/;+ for (const plannerMode of ['off', 'try']) {+ for (const [runOptions, expectsRule, expectsResumeRule] of [+ [{ scheduledRun: true, independentRun: true, scheduledResume: false }, true, false],+ [{ scheduledRun: true, independentRun: true, scheduledResume: true }, false, true],+ [{}, false, false],+ ]) {+ const agent = plannerAgent(Agent, plannerResult('clarify', 'Which account should I check?'), plannerMode);+ const systems = [];+ // The first reply is unparseable, so the planner's repair call runs too.+ agent._chatWithCostAllowance = async (_provider, messages, _options, _cost, meta) => {+ assert.match(meta?.generationName || '', /^planner/);+ systems.push(messages.find(message => message.role === 'system')?.content || '');+ return { content: systems.length === 1 ? 'not json' : JSON.stringify(plannerResult('clarify', 'Which account should I check?')) };+ };+ await agent.processMessage(6901, 'In 30 minutes, remind me to check my account balance.', () => {}, 'act', [], runOptions);+ const label = `${plannerMode} ${JSON.stringify(runOptions)}`;+ assert.equal(systems.length, 2, label);+ for (const system of systems) {+ assert.equal(RULE.test(system), expectsRule, label);+ assert.equal(/This run is an app-owned scheduled continuation/.test(system), expectsResumeRule, label);+ }+ }+ }});// One scheduled one-shot run through the real scheduler, planner gate (Try@@ -426,6 +476,24 @@ for (const { build, Agent, tools, args, research, Scheduler, planner } of buildsassert.match(agent.conversations.get(77).find(message => message.role === 'user')?.content || '', NEUTRAL);});+ test(`${build}: a scheduled reminder the planner marked state-changing still finishes with success after a read`, async () => {+ const { h, once, guard, toolResults, job } = await scheduledRunEndToEnd({+ prompt: 'In 30 minutes, remind me to take the pizza out.',+ plan: { ...pizzaPlan, requires_state_change: true, steps: [+ { id: '1', action: 'Read the page', tools: ['read_page'] },+ { id: '2', action: 'Tell the user it is time to take the pizza out', tools: ['done'] },+ ] },+ script: [['read_page', {}], ['done', { summary: 'Time to take the pizza out!', outcome: 'success' }]],+ });+ assert.equal(guard?.requiresStateChange, false);+ const dones = toolResults.filter(entry => entry.name === 'done');+ assert.equal(dones.length, 1, 'the first done(success) is accepted');+ assert.equal(dones[0].result?.outcome, 'success');+ assert.equal(guard.successfulConsequentialToolCalls, 0);+ assert.equal(job.lastOutcome, 'success');+ assert.deepEqual(h.jobs().map(candidate => candidate.id), [once.jobId]);+ });+test(`${build}: a scheduled reminder that skips its read is asked for a read, not a mutation`, async () => {const { toolResults, job } = await scheduledRunEndToEnd({prompt: 'In 30 minutes, remind me to take the pizza out.', plan: pizzaPlan,