Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

Let a second look plan a schedule the task already carried

Claudee9c80f241bf0
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4e9e4c3d8..fb27850f7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,7 +19,7 @@ This changelog was generated from the repository Git history and release tags. V
- Providers β†’ Decision accepts a local decision server on another machine on your network, such as `http://192.168.1.51:8091`. **Load available models** and **Test** used to stop with "Decision endpoints require HTTPS outside localhost." for any address but this computer's. Private addresses (10.x, 172.16–31.x, 192.168.x, Tailscale's 100.64–127.x, link-local, IPv6 unique-local) and `.local`, `.home.arpa` and `.internal` names now work over plain HTTP; public addresses still need HTTPS. In Chrome, decision requests to such a server go through the same offscreen proxy as chat models on your network. Vision and speech endpoints already accepted these addresses.
- Act can send a photo or video in an Instagram direct message. Instagram's message box keeps its file input hidden, outside any form, deep in a long conversation, where WebBrain's check that an action still targets what the model saw cannot reach it. Every attachment was refused, even with the exact selector WebBrain itself listed for that input, often right after you had confirmed the recipient on WebBrain's card; the model then sent a link to the picture, or said Instagram blocks attachments. With Strict checks off, an upload to the very input WebBrain listed on that page, named by the selector it gave, now goes through with a note to the model, and the recipient checks still apply. A selector WebBrain did not list is still refused, and so is an input the page re-created after the list under the same selector, until WebBrain lists the page's controls again. When clicking "Add Photo or Video" opens a file chooser, WebBrain now names the input with that same selector, and the Instagram site notes say to attach the file to that input instead of clicking the button, and that a link to a picture is not the picture.
- Act can attach images and videos to a post on X again. While the post composer is open at x.com/compose/post, the timeline behind it keeps a second, identical file input, and WebBrain's list of the page's controls gave neither input a selector. After the model's first selector matched both, WebBrain refused every later upload until it saw a selector it could not get, so the run ended at its cost limit with nothing attached. The list now gives every file input a selector that matches only that input, scoped to the open dialog where that is what tells them apart, and marks the dialog's input `inDialog`. The X site notes name the dialog's input, and when no selector can single out an input, WebBrain tells the model to report the upload as blocked instead of retrying.
-- Act no longer asks you the same question again when the answer is on the page. Asked to post the same thing on LinkedIn while the X post was open, the planner asked which text and files to use, and after β€œlook at the screen β€” the same” it asked again: the planner works from your words, the page's address and title and a short summary of the chat, never the page itself or your attachments. That summary held only the last ten messages, tool calls and page observations included, each cut to 300 characters, so the earlier answer that named the post's text and your screenshot file had dropped out of it. It now holds the last ten turns of the conversation without the agent's step-by-step notes, gives the latest answer up to 1,200 characters, and names the files you attached earlier. When you have just answered a planner question and the planner wants to ask again, it first takes a second look, told that it cannot see the page while the agent can, and plans the task instead. That second look cannot add anything you did not ask for: posting, sending or a schedule your request did not already carry stays a question for you, and so do when a scheduled task should run, who a message goes to, an account or an amount, which it may never take from the page. A planner running Qwen 3, QwQ or DeepSeek R1, which is told not to think so that it answers faster, now thinks during that second look and before any question it would ask you, unless reasoning is turned off for that provider. Chrome and Firefox.
+- Act no longer asks you the same question again when the answer is on the page. Asked to post the same thing on LinkedIn while the X post was open, the planner asked which text and files to use, and after β€œlook at the screen β€” the same” it asked again: the planner works from your words, the page's address and title and a short summary of the chat, never the page itself or your attachments. That summary held only the last ten messages, tool calls and page observations included, each cut to 300 characters, so the earlier answer that named the post's text and your screenshot file had dropped out of it. It now holds the last ten turns of the conversation without the agent's step-by-step notes, gives the latest answer up to 1,200 characters, and names the files you attached earlier. When you have just answered a planner question and the planner wants to ask again, it first takes a second look, told that it cannot see the page while the agent can, and plans the task instead. That second look cannot add anything you did not ask for: posting, sending or a schedule your request did not already carry stays a question for you. When a scheduled task should run, who a message goes to, an account or an amount stay questions too until you give them, and it never takes them from the page; an answer such as "every five minutes" to a question about a scheduled task is planned. A planner running Qwen 3, QwQ or DeepSeek R1, which is told not to think so that it answers faster, now thinks during that second look and before any question it would ask you, unless reasoning is turned off for that provider. Chrome and Firefox.
## [42.3.1] - 2026-10-20
diff --git a/docs/architecture.md b/docs/architecture.md
index 169697c2a..e7ae2ce3b 100644
--- a/docs/architecture.md
+++ b/docs/architecture.md
@@ -934,7 +934,7 @@ Planner calls are traced with `phase: "planner"` when trace recording is enabled
The recent-history digest (`_buildPlannerHistoryDigest()`) takes the last ten authored turns, after app-owned notes, pinned state, tool results and the narration sent with tool calls are filtered out, and spends a 2,000-character budget newest first: an assistant turn keeps up to 1,200 characters and a user turn up to 600, and older turns that no longer fit are left out whole. A user turn names its attachments (`[attached: …]`, at most four names, sanitized like the executor's attachment notice), because the planner never receives attachment bytes.
-A `clarify` from the planner or the intent check gets one second look before the user sees it (`_plannerClarifyRetry()`). A model that was sent `/no_think` (Qwen 3, QwQ, DeepSeek R1) answers again with thinking on and up to 8,192 output tokens (`_plannerCanRethink()`: not when reasoning is off in the provider's settings or extra request body, and not for Qwen3 Instruct-2507 and Coder models, which have no thinking mode). On the turn that answers the planner's previous question (`_turnAnswersPlannerQuestion()`, which reads an answer as the task binding does; not in scheduled runs or the intent recheck), `PLANNER_REASK_GUIDANCE` is added to the system prompt: the planner cannot see the page and the executor can, so it may ask again only about schedule timing or a calendar recurrence, a recipient, an account, an amount, a credential, whether to publish, send or submit at all, or conflicting answers, none of which it may take from page content. Such a second look may not add a submission that neither its first answer nor the answered question carried, a recipient its first answer did not name (for a message or a draft), or a schedule (`_plannerSecondLookWidens()`, trace note `planner_second_look_rejected`). The trace phase is `planner_rethink` or `planner_reask` (`intent_rethink`, `intent_reask` for the intent check). The second answer is parsed and consistency-checked like the first and then takes the first answer's place in the rest of the gate, which in the planner gate includes the alignment check, recipient pinning and review. A failed, unparseable, inconsistent or rejected second answer, including one stopped by the cost allowance, keeps the first question, and a pending correction gets no second look.
+A `clarify` from the planner or the intent check gets one second look before the user sees it (`_plannerClarifyRetry()`). A model that was sent `/no_think` (Qwen 3, QwQ, DeepSeek R1) answers again with thinking on and up to 8,192 output tokens (`_plannerCanRethink()`: not when reasoning is off in the provider's settings or extra request body, and not for Qwen3 Instruct-2507 and Coder models, which have no thinking mode). On the turn that answers the planner's previous question (`_turnAnswersPlannerQuestion()`, which reads an answer as the task binding does; not in scheduled runs or the intent recheck), `PLANNER_REASK_GUIDANCE` is added to the system prompt: the planner cannot see the page and the executor can, so it may ask again only about schedule timing or a calendar recurrence, a recipient, an account, an amount, a credential, whether to publish, send or submit at all, or conflicting answers, none of which it may take from page content. Such a second look may not add a submission or a schedule that neither its first answer nor the answered question carried, or a recipient, for a message or a draft, that its first answer did not name (`_plannerSecondLookWidens()`, trace note `planner_second_look_rejected`). A planner question keeps the schedule of the task it asks about (`normalizePlan()` keeps `scheduling` on a `clarify` plan, and nothing runs from it), and the stored question records its tool as `schedulingTool`, so an answer that only gives a scheduled task its timing ("every five minutes") can still be planned. Only a schedule of the kind the task carried passes: a task that carried a `schedule_resume` pause does not let a second look create a recurring `schedule_task`. The trace phase is `planner_rethink` or `planner_reask` (`intent_rethink`, `intent_reask` for the intent check). The second answer is parsed and consistency-checked like the first and then takes the first answer's place in the rest of the gate, which in the planner gate includes the alignment check, recipient pinning and review. A failed, unparseable, inconsistent or rejected second answer, including one stopped by the cost allowance, keeps the first question, and a pending correction gets no second look.
LLM-request trace events include privacy-safe prompt provenance: the controlled
prompt variant, system-prompt and aggregate message character counts, message
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index 42281960c..cfbd3fee9 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -26747,9 +26747,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const historyDigest = this._buildPlannerHistoryDigest(priorMessages);
const followUpContext = cloudIntent ? { authenticTaskText: this._plannerUserAuthoredText(enriched) }
: { ...this._buildPlannerFollowUpContext(priorMessages), authenticTaskText: this._plannerAuthenticTaskText(messages, runOptions.steeringRevision != null ? null : enriched),
- answersPlannerQuestion: runOptions.steeringRevision == null
- && runOptions?.scheduledRun !== true && runOptions?.scheduledResume !== true
- && this._turnAnswersPlannerQuestion(messages, messages.lastIndexOf(submittedUserMessage)) };
+ ...this._plannerQuestionAnswerContext(messages, messages.lastIndexOf(submittedUserMessage), runOptions) };
let gate;
if (runOptions.steeringRevision == null && this._shouldSkipPlannerForShortFollowUp(tabId, priorMessages, enriched, plannerMode)) {
this.plannerFollowUpSkipTabs.delete(tabId);
@@ -27168,6 +27166,21 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
return this._plannerClarificationIndexBefore(messages, index) >= 0;
}
+ // For the planner's second look (_plannerClarifyRetry): whether the user
+ // turn at `index` answers the planner's previous question, and the schedule
+ // tool of the task that question was about (_plannerSecondLookWidens). A
+ // correction or a scheduled run answers no question.
+ _plannerQuestionAnswerContext(messages, index, runOptions = {}) {
+ const answersPlannerQuestion = runOptions?.steeringRevision == null
+ && runOptions?.scheduledRun !== true && runOptions?.scheduledResume !== true
+ && this._turnAnswersPlannerQuestion(messages, index);
+ const question = answersPlannerQuestion ? messages[this._plannerClarificationIndexBefore(messages, index)] : null;
+ return {
+ answersPlannerQuestion,
+ answeredQuestionSchedulingTool: question?.webbrainPlannerClarification?.schedulingTool || null,
+ };
+ }
+
// Whether a second look may think: only a model planning tells not to
// think (/no_think). Reasoning turned off in the provider's settings or in
// its extra request body stays off (mergeProviderRequestBody merges both
@@ -27185,19 +27198,24 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
}
// A second look told not to re-ask may not take on more than the user's
- // task already carried: a submission neither the first answer nor the
- // question the user just answered held, a recipient the first answer did
- // not name, or a schedule. Those stay questions for the user. A recipient
- // counts for a draft too: normalizePlan moves the addressees of a message
- // that is not sent into draft_recipients, and a draft written into the open
- // conversation is still a recipient taken from the page.
+ // task already carried: a submission or a schedule that neither the first
+ // answer nor the question the user just answered held, or a recipient the
+ // first answer did not name. Those stay questions for the user. A schedule
+ // of the kind the task carried may be planned (a pause for schedule_resume
+ // never becomes a recurring schedule_task): the user's answer is often its
+ // timing ("every five minutes"), and in the planner gate the plan is still
+ // checked for alignment with the task and that answer. A recipient counts for a draft
+ // too: normalizePlan moves the addressees of a message that is not sent
+ // into draft_recipients, and a draft written into the open conversation is
+ // still a recipient taken from the page.
_plannerSecondLookWidens(firstPlan, plan, followUpContext = {}) {
const submissionCarried = firstPlan?.requires_submission === true
|| followUpContext?.plannerClarification?.requiresSubmission === true;
if (plan?.requires_submission === true && !submissionCarried) return true;
const named = JSON.stringify(firstPlan?.messaging || firstPlan?.draft_recipients || null);
if ([plan?.messaging, plan?.draft_recipients].some(target => target && JSON.stringify(target) !== named)) return true;
- return !!plan?.scheduling;
+ const carriedSchedules = [firstPlan?.scheduling?.tool, followUpContext?.answeredQuestionSchedulingTool];
+ return !!plan?.scheduling && !carriedSchedules.includes(plan.scheduling.tool);
}
// A planner question gets one more look before it reaches the user. The
@@ -27354,6 +27372,9 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
if (gate.requestKind === 'clarify' && gate.plannerClarification === true) {
message.webbrainPlannerClarification = {
requiresSubmission: gate.requiresSubmission === true,
+ // The schedule of the task this question is about, so the second look
+ // at the user's answer may plan it (_plannerSecondLookWidens).
+ schedulingTool: ['schedule_task', 'schedule_resume'].includes(gate.schedulingTool) ? gate.schedulingTool : null,
pageUrl: String(tabInfo?.tabUrl || ''),
taskText: this._progressTaskTextKey(activeTaskText).slice(0, 1600),
taskKey: /^tk_[0-9a-f]{8}$/i.test(String(activeTaskKey || ''))
@@ -28198,6 +28219,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
responseLanguagePolicy: plan.response_language,
requiresStateChange: false,
requiresSubmission: plan.request_kind === 'clarify' && plan.requires_submission === true,
+ schedulingTool: plan.request_kind === 'clarify' ? plan.scheduling?.tool || null : null,
};
}
if (runOptions?.cloudRun === true && runOptions?.trustedContinuation !== true
@@ -28221,7 +28243,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
});
if (!present) return {
proceed: false, reason: 'active_recipient_unverified', requestKind: 'clarify', plannerClarification: true,
- requiresStateChange: false, requiresSubmission: false, messaging: null,
+ requiresStateChange: false, requiresSubmission: false, schedulingTool: plan.scheduling?.tool || null, messaging: null,
message: 'The recipient could not be verified from the current task. Name the exact recipient and retry. No page tools ran.',
};
}
@@ -28236,6 +28258,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
plannerClarification: true,
requiresStateChange: false,
requiresSubmission: true,
+ schedulingTool: plan.scheduling?.tool || null,
};
}
plan.messaging = messagingPin.target;
@@ -28256,6 +28279,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
plannerClarification: true,
requiresStateChange: false,
requiresSubmission: false,
+ schedulingTool: plan.scheduling?.tool || null,
};
}
plan.draft_recipients = draftPin.target;
@@ -28525,6 +28549,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
responseLanguagePolicy: candidate.response_language,
requiresStateChange: false,
requiresSubmission: candidate.request_kind === 'clarify' && candidate.requires_submission === true,
+ schedulingTool: candidate.request_kind === 'clarify' ? candidate.scheduling?.tool || null : null,
};
}
return null;
@@ -28742,6 +28767,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
plannerClarification: true,
requiresStateChange: false,
requiresSubmission: true,
+ schedulingTool: plan.scheduling?.tool || null,
};
}
plan.messaging = messagingPin.target;
@@ -28762,6 +28788,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
plannerClarification: true,
requiresStateChange: false,
requiresSubmission: false,
+ schedulingTool: plan.scheduling?.tool || null,
};
}
plan.draft_recipients = draftPin.target;
diff --git a/src/chrome/src/agent/planner.js b/src/chrome/src/agent/planner.js
index d4c247e0a..c7b7bff89 100644
--- a/src/chrome/src/agent/planner.js
+++ b/src/chrome/src/agent/planner.js
@@ -1318,7 +1318,11 @@ export function normalizePlan(obj, opts = {}) {
? (memory.use_progress_ledger === true ? 'enabled' : 'disabled')
: 'auto',
},
- scheduling: executablePlan ? normalizedScheduling : null,
+ // A question keeps the schedule of the task it asks about, as it keeps
+ // the submission. Nothing runs from it: the agent records that the task
+ // carries a schedule, and the planner's second look at the user's answer
+ // may then plan one (Agent._plannerSecondLookWidens).
+ scheduling: executablePlan || requestKind === 'clarify' ? normalizedScheduling : null,
risks,
localized,
response_language: responseLanguage,
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 5f1a14af9..2bac7d2f9 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -23786,9 +23786,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const historyDigest = this._buildPlannerHistoryDigest(priorMessages);
const followUpContext = cloudIntent ? { authenticTaskText: this._plannerUserAuthoredText(enriched) }
: { ...this._buildPlannerFollowUpContext(priorMessages), authenticTaskText: this._plannerAuthenticTaskText(messages, runOptions.steeringRevision != null ? null : enriched),
- answersPlannerQuestion: runOptions.steeringRevision == null
- && runOptions?.scheduledRun !== true && runOptions?.scheduledResume !== true
- && this._turnAnswersPlannerQuestion(messages, messages.lastIndexOf(submittedUserMessage)) };
+ ...this._plannerQuestionAnswerContext(messages, messages.lastIndexOf(submittedUserMessage), runOptions) };
let gate;
if (runOptions.steeringRevision == null && this._shouldSkipPlannerForShortFollowUp(tabId, priorMessages, enriched, plannerMode)) {
this.plannerFollowUpSkipTabs.delete(tabId);
@@ -24206,6 +24204,21 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
return this._plannerClarificationIndexBefore(messages, index) >= 0;
}
+ // For the planner's second look (_plannerClarifyRetry): whether the user
+ // turn at `index` answers the planner's previous question, and the schedule
+ // tool of the task that question was about (_plannerSecondLookWidens). A
+ // correction or a scheduled run answers no question.
+ _plannerQuestionAnswerContext(messages, index, runOptions = {}) {
+ const answersPlannerQuestion = runOptions?.steeringRevision == null
+ && runOptions?.scheduledRun !== true && runOptions?.scheduledResume !== true
+ && this._turnAnswersPlannerQuestion(messages, index);
+ const question = answersPlannerQuestion ? messages[this._plannerClarificationIndexBefore(messages, index)] : null;
+ return {
+ answersPlannerQuestion,
+ answeredQuestionSchedulingTool: question?.webbrainPlannerClarification?.schedulingTool || null,
+ };
+ }
+
// Whether a second look may think: only a model planning tells not to
// think (/no_think). Reasoning turned off in the provider's settings or in
// its extra request body stays off (mergeProviderRequestBody merges both
@@ -24223,19 +24236,24 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
}
// A second look told not to re-ask may not take on more than the user's
- // task already carried: a submission neither the first answer nor the
- // question the user just answered held, a recipient the first answer did
- // not name, or a schedule. Those stay questions for the user. A recipient
- // counts for a draft too: normalizePlan moves the addressees of a message
- // that is not sent into draft_recipients, and a draft written into the open
- // conversation is still a recipient taken from the page.
+ // task already carried: a submission or a schedule that neither the first
+ // answer nor the question the user just answered held, or a recipient the
+ // first answer did not name. Those stay questions for the user. A schedule
+ // of the kind the task carried may be planned (a pause for schedule_resume
+ // never becomes a recurring schedule_task): the user's answer is often its
+ // timing ("every five minutes"), and in the planner gate the plan is still
+ // checked for alignment with the task and that answer. A recipient counts for a draft
+ // too: normalizePlan moves the addressees of a message that is not sent
+ // into draft_recipients, and a draft written into the open conversation is
+ // still a recipient taken from the page.
_plannerSecondLookWidens(firstPlan, plan, followUpContext = {}) {
const submissionCarried = firstPlan?.requires_submission === true
|| followUpContext?.plannerClarification?.requiresSubmission === true;
if (plan?.requires_submission === true && !submissionCarried) return true;
const named = JSON.stringify(firstPlan?.messaging || firstPlan?.draft_recipients || null);
if ([plan?.messaging, plan?.draft_recipients].some(target => target && JSON.stringify(target) !== named)) return true;
- return !!plan?.scheduling;
+ const carriedSchedules = [firstPlan?.scheduling?.tool, followUpContext?.answeredQuestionSchedulingTool];
+ return !!plan?.scheduling && !carriedSchedules.includes(plan.scheduling.tool);
}
// A planner question gets one more look before it reaches the user. The
@@ -24392,6 +24410,9 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
if (gate.requestKind === 'clarify' && gate.plannerClarification === true) {
message.webbrainPlannerClarification = {
requiresSubmission: gate.requiresSubmission === true,
+ // The schedule of the task this question is about, so the second look
+ // at the user's answer may plan it (_plannerSecondLookWidens).
+ schedulingTool: ['schedule_task', 'schedule_resume'].includes(gate.schedulingTool) ? gate.schedulingTool : null,
pageUrl: String(tabInfo?.tabUrl || ''),
taskText: this._progressTaskTextKey(activeTaskText).slice(0, 1600),
taskKey: /^tk_[0-9a-f]{8}$/i.test(String(activeTaskKey || ''))
@@ -25225,6 +25246,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
responseLanguagePolicy: plan.response_language,
requiresStateChange: false,
requiresSubmission: plan.request_kind === 'clarify' && plan.requires_submission === true,
+ schedulingTool: plan.request_kind === 'clarify' ? plan.scheduling?.tool || null : null,
};
}
if (runOptions?.cloudRun === true && runOptions?.trustedContinuation !== true
@@ -25248,7 +25270,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
});
if (!present) return {
proceed: false, reason: 'active_recipient_unverified', requestKind: 'clarify', plannerClarification: true,
- requiresStateChange: false, requiresSubmission: false, messaging: null,
+ requiresStateChange: false, requiresSubmission: false, schedulingTool: plan.scheduling?.tool || null, messaging: null,
message: 'The recipient could not be verified from the current task. Name the exact recipient and retry. No page tools ran.',
};
}
@@ -25263,6 +25285,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
plannerClarification: true,
requiresStateChange: false,
requiresSubmission: true,
+ schedulingTool: plan.scheduling?.tool || null,
};
}
plan.messaging = messagingPin.target;
@@ -25283,6 +25306,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
plannerClarification: true,
requiresStateChange: false,
requiresSubmission: false,
+ schedulingTool: plan.scheduling?.tool || null,
};
}
plan.draft_recipients = draftPin.target;
@@ -25548,6 +25572,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
responseLanguagePolicy: candidate.response_language,
requiresStateChange: false,
requiresSubmission: candidate.request_kind === 'clarify' && candidate.requires_submission === true,
+ schedulingTool: candidate.request_kind === 'clarify' ? candidate.scheduling?.tool || null : null,
};
}
return null;
@@ -25765,6 +25790,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
plannerClarification: true,
requiresStateChange: false,
requiresSubmission: true,
+ schedulingTool: plan.scheduling?.tool || null,
};
}
plan.messaging = messagingPin.target;
@@ -25785,6 +25811,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
plannerClarification: true,
requiresStateChange: false,
requiresSubmission: false,
+ schedulingTool: plan.scheduling?.tool || null,
};
}
plan.draft_recipients = draftPin.target;
diff --git a/src/firefox/src/agent/planner.js b/src/firefox/src/agent/planner.js
index d4c247e0a..c7b7bff89 100644
--- a/src/firefox/src/agent/planner.js
+++ b/src/firefox/src/agent/planner.js
@@ -1318,7 +1318,11 @@ export function normalizePlan(obj, opts = {}) {
? (memory.use_progress_ledger === true ? 'enabled' : 'disabled')
: 'auto',
},
- scheduling: executablePlan ? normalizedScheduling : null,
+ // A question keeps the schedule of the task it asks about, as it keeps
+ // the submission. Nothing runs from it: the agent records that the task
+ // carries a schedule, and the planner's second look at the user's answer
+ // may then plan one (Agent._plannerSecondLookWidens).
+ scheduling: executablePlan || requestKind === 'clarify' ? normalizedScheduling : null,
risks,
localized,
response_language: responseLanguage,
diff --git a/test/planner-clarify-loop.mjs b/test/planner-clarify-loop.mjs
index dc09081e6..7e0e2c7aa 100644
--- a/test/planner-clarify-loop.mjs
+++ b/test/planner-clarify-loop.mjs
@@ -9,8 +9,8 @@
// planner told not to think (/no_think) thinks, and on the turn that
// answers the planner's previous question the planner is told it cannot
// see the page and may ask again only for values that must come from the
-// user. That plan may not add a submission, a recipient or a schedule, and
-// then goes through the usual checks.
+// user. That plan may not add a submission, a recipient or a schedule the
+// task did not carry, and then goes through the usual checks.
import assert from 'node:assert/strict';
import { test } from 'node:test';
@@ -88,6 +88,10 @@ const user = (content, extra = {}) => ({ role: 'user', content, ...extra });
const assistant = content => ({ role: 'assistant', content });
const contentText = content => (Array.isArray(content) ? content.map(block => block?.text || '').join('') : String(content || ''));
const REASK = /Second look before asking again/;
+const OPEN_SCHEDULE = { tool: 'schedule_task', hint: 'The user wants the page checked on a schedule; how often is still open.' };
+const EVERY_FIVE = { tool: 'schedule_task', hint: 'Every 5 minutes, as the user answered.' };
+const HOW_OFTEN = 'How often should I check this page for a new release?';
+const PAUSE = { tool: 'schedule_resume', hint: 'Wait until the deploy finishes, then continue.' };
for (const build of ['chrome', 'firefox']) {
const { Agent } = await import(`../src/${build}/src/agent/agent.js`);
@@ -234,6 +238,46 @@ for (const build of ['chrome', 'firefox']) {
assert.equal(agent._turnAnswersPlannerQuestion(messages, -1), false);
});
+ test(`${build}: the answer context names the schedule of the question's task, and only for a direct answer`, () => {
+ const agent = newAgent();
+ const answer = user('every five minutes');
+ const asked = gate => {
+ const messages = [{ role: 'system', content: 'sys' }, user('Check this page for a new release on a schedule')];
+ messages.push(agent._plannerTerminalAssistantMessage({ requestKind: 'clarify', plannerClarification: true, message: HOW_OFTEN, ...gate },
+ TAB, messages[1].content, agent._progressTaskKeyForText(messages[1].content)));
+ return [...messages, answer];
+ };
+ const scheduled = asked({ schedulingTool: 'schedule_task' });
+ assert.equal(scheduled[2].webbrainPlannerClarification.schedulingTool, 'schedule_task', 'the question records the schedule');
+ assert.equal(asked({})[2].webbrainPlannerClarification.schedulingTool, null);
+ assert.equal(asked({ schedulingTool: 'schedule_everything' })[2].webbrainPlannerClarification.schedulingTool, null, 'only a known tool');
+ assert.deepEqual(agent._plannerQuestionAnswerContext(scheduled, 3), { answersPlannerQuestion: true, answeredQuestionSchedulingTool: 'schedule_task' });
+ assert.deepEqual(agent._plannerQuestionAnswerContext(asked({}), 3), { answersPlannerQuestion: true, answeredQuestionSchedulingTool: null });
+ for (const runOptions of [{ steeringRevision: 1 }, { scheduledRun: true }, { scheduledResume: true }]) {
+ assert.deepEqual(agent._plannerQuestionAnswerContext(scheduled, 3, runOptions),
+ { answersPlannerQuestion: false, answeredQuestionSchedulingTool: null }, JSON.stringify(runOptions));
+ }
+ const newRequest = [...scheduled.slice(0, 3), { ...answer, webbrainTurnKind: 'request' }];
+ assert.deepEqual(agent._plannerQuestionAnswerContext(newRequest, 3), { answersPlannerQuestion: false, answeredQuestionSchedulingTool: null },
+ 'a new request answers no question');
+ });
+
+ test(`${build}: a question keeps the schedule of the task it asks about, and nothing runs from it`, async () => {
+ const { parsePlanFromContent } = await import(`../src/${build}/src/agent/planner.js`);
+ const parse = plan => parsePlanFromContent(JSON.stringify(plan), { requireIntent: true, locale: 'en' });
+ const question = parse(clarifyPlan({ requires_submission: false, summary: HOW_OFTEN, scheduling: OPEN_SCHEDULE }));
+ assert.deepEqual(question.scheduling, OPEN_SCHEDULE);
+ assert.deepEqual([question.request_kind, question.requires_state_change], ['clarify', false]);
+ assert.deepEqual(parse(plannerPlan({ requires_submission: false, scheduling: EVERY_FIVE })).scheduling, EVERY_FIVE);
+ for (const request_kind of ['respond', 'plan_only']) {
+ const plan = parse(plannerPlan({
+ request_kind, read_scope: 'none', requires_state_change: false, requires_submission: false, scheduling: EVERY_FIVE,
+ }));
+ assert.equal(plan?.request_kind, request_kind, `fixture: ${request_kind} parses`);
+ assert.equal(plan.scheduling, null, request_kind);
+ }
+ });
+
// ── The second look ─────────────────────────────────────────────────
test(`${build}: a planner question on the turn that answers the last one gets a second look, and its plan runs`, async () => {
@@ -319,7 +363,7 @@ for (const build of ['chrome', 'firefox']) {
assert.equal(second.options.extraBody?.chat_template_kwargs?.enable_thinking, false);
});
- test(`${build}: a second look told not to re-ask may not add a submission, a recipient or a schedule`, async () => {
+ test(`${build}: a second look told not to re-ask may not add a submission, a recipient or a schedule the task did not carry`, async () => {
const named = { target_kind: 'named', recipients: [{ identity: 'Ali Veli', role: 'to' }] };
const cases = [
['a submission nobody asked for', clarifyPlan({ requires_submission: false }), plannerPlan(), {}, false],
@@ -334,14 +378,26 @@ for (const build of ['chrome', 'firefox']) {
plannerPlan({ requires_submission: false, messaging: named }), {}, false],
['a draft for the recipient the first answer named', clarifyPlan({ messaging: named }),
plannerPlan({ requires_submission: false, messaging: named }), {}, true],
- ['a schedule', clarifyPlan(), plannerPlan({ scheduling: { tool: 'schedule_task', hint: 'Every 43200 minutes.' } }), {}, false],
+ ['a schedule the task did not carry', clarifyPlan(), plannerPlan({ scheduling: { tool: 'schedule_task', hint: 'Every 43200 minutes.' } }), {}, false],
+ ['a schedule the first answer carried', clarifyPlan({ scheduling: OPEN_SCHEDULE }), plannerPlan({ scheduling: EVERY_FIVE }), {}, true],
+ ['a schedule the answered question carried', clarifyPlan(), plannerPlan({ scheduling: EVERY_FIVE }),
+ { answeredQuestionSchedulingTool: 'schedule_task' }, true],
+ ['a recurring schedule where the first answer carried only a pause', clarifyPlan({ scheduling: PAUSE }),
+ plannerPlan({ scheduling: EVERY_FIVE }), {}, false],
+ ['a recurring schedule where the answered question carried only a pause', clarifyPlan(),
+ plannerPlan({ scheduling: EVERY_FIVE }), { answeredQuestionSchedulingTool: 'schedule_resume' }, false],
];
for (const [label, first, second, extraContext, accepted] of cases) {
- const { agent, calls } = scriptedAgent({ provider: PLAIN_MODEL, answers: [first, second] });
- const result = await fullGate(agent, { followUpContext: { answersPlannerQuestion: true, ...extraContext } });
- assert.equal(calls.length, 2, label);
- if (accepted) assert.equal(result.requestKind, 'execute', `${label}: ${JSON.stringify(result)}`);
- else assert.deepEqual([result.proceed, result.requestKind, result.message], [false, 'clarify', QUESTION], `${label}: ${JSON.stringify(result)}`);
+ for (const gate of ['planner', 'intent']) {
+ const answers = gate === 'planner' ? [first, second] : [intentPlan(first), intentPlan(second)];
+ const { agent, calls } = scriptedAgent({ provider: PLAIN_MODEL, answers });
+ const followUpContext = { answersPlannerQuestion: true, ...extraContext };
+ const result = gate === 'planner' ? await fullGate(agent, { followUpContext }) : await intentGate(agent, { followUpContext });
+ assert.equal(calls.length, 2, `${gate} ${label}`);
+ if (accepted) assert.equal(result.requestKind, 'execute', `${gate} ${label}: ${JSON.stringify(result)}`);
+ else assert.deepEqual([result.proceed, result.requestKind, result.message], [false, 'clarify', QUESTION], `${gate} ${label}: ${JSON.stringify(result)}`);
+ if (accepted && second.scheduling) assert.equal(result.requiredSchedulingTool, 'schedule_task', `${gate} ${label}`);
+ }
}
// A rethink without the guidance is an ordinary plan: a schedule the
// task asked for may come out of it.
@@ -433,4 +489,54 @@ for (const build of ['chrome', 'firefox']) {
assert.ok(messages.includes(answer), 'the answer is recorded as the user turn');
assert.ok(!JSON.stringify(messages).includes('Second look before asking again'), 'the guidance is not stored in the conversation');
});
+
+ test(`${build}: an answer that gives a scheduled task its timing is planned, not asked again`, async () => {
+ const timed = plannerPlan({
+ requires_submission: false, deliverables: ['A recurring check of this page for a new release'],
+ summary: 'Schedule a check of this page every 5 minutes.', scheduling: EVERY_FIVE,
+ });
+ for (const [label, firstQuestion, accepted] of [
+ ['a question about a scheduled task', clarifyPlan({ requires_submission: false, summary: HOW_OFTEN, scheduling: OPEN_SCHEDULE }), true],
+ ['a question about a task without a schedule', clarifyPlan({ requires_submission: false, summary: HOW_OFTEN }), false],
+ ]) {
+ const tabId = accepted ? 37 : 38;
+ // Asked on the first turn; on the answer the planner asks again without
+ // naming the schedule, and its second look plans the schedule.
+ const repeated = clarifyPlan({ requires_submission: false, summary: HOW_OFTEN });
+ const { agent, calls, alignmentChecks } = scriptedAgent({ provider: PLAIN_MODEL, answers: [firstQuestion, repeated, timed] });
+ const messages = [{ role: 'system', content: 'sys' }];
+ agent.conversations.set(tabId, messages);
+ agent._persistSubmittedTurn = async () => {};
+ agent._persist = () => {};
+ const asked = await agent._maybeRunPlannerGate(tabId, messages, user('Check this page for a new release on a schedule'), () => {}, 'act', null, null, TAB, {});
+ assert.deepEqual([asked.proceed, asked.requestKind, asked.message], [false, 'clarify', HOW_OFTEN], `${label}: ${JSON.stringify(asked)}`);
+ assert.equal(messages.at(-1).webbrainPlannerClarification?.schedulingTool, accepted ? 'schedule_task' : null,
+ `${label}: the question records its task's schedule`);
+ const gate = await agent._maybeRunPlannerGate(tabId, messages, user('every five minutes'), () => {}, 'act', null, null, TAB, {});
+ assert.equal(calls.length, 3, label);
+ assert.match(calls[2].messages[0].content, REASK, `${label}: the answer got a second look`);
+ if (accepted) {
+ assert.equal(gate.proceed, true, `${label}: ${JSON.stringify(gate)}`);
+ assert.equal(gate.requiredSchedulingTool, 'schedule_task', label);
+ assert.equal(alignmentChecks.length, 1, `${label}: the schedule is checked against the task and the answer`);
+ assert.match(String(alignmentChecks[0].current_request), /every five minutes/);
+ } else {
+ assert.deepEqual([gate.proceed, gate.requestKind, gate.message], [false, 'clarify', HOW_OFTEN], `${label}: ${JSON.stringify(gate)}`);
+ }
+ }
+ });
+
+ test(`${build}: a recipient question about a scheduled task records the schedule`, async () => {
+ const scheduledMessage = plannerPlan({ messaging: { target_kind: 'active_conversation', recipients: [] }, scheduling: EVERY_FIVE });
+ for (const gate of ['planner', 'intent']) {
+ for (const [label, plan, scheduled] of [['scheduled', scheduledMessage, true], ['unscheduled', plannerPlan({ messaging: scheduledMessage.messaging }), false]]) {
+ const { agent } = scriptedAgent({ provider: PLAIN_MODEL, answers: [gate === 'planner' ? plan : intentPlan(plan)] });
+ agent._pinActiveConversationMessagingTarget = async () => ({ ok: false, error: 'Open the conversation first.' });
+ const result = gate === 'planner' ? await fullGate(agent) : await intentGate(agent);
+ assert.deepEqual([result.reason, result.plannerClarification, result.schedulingTool],
+ ['active_recipient_unverified', true, scheduled ? 'schedule_task' : null],
+ `${gate} ${label}: ${JSON.stringify(result)}`);
+ }
+ }
+ });
}