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
Leave schedule changes to the alignment check
Claudebf8c04e0950e
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex a6445f9d5..cbe2cd91d 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. With the Planner on (Try or Strict), 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; the plan is then checked against your words. So an answer such as "every five minutes" to a question about a scheduled task, the name of the person to write to, "yes, send it" or opening the conversation it asked you to open is planned. It never takes who a message goes to, an account or an amount from the page, never adds a person or a schedule your request did not carry, and never runs a task you asked to repeat just once instead. With the Planner off, nothing checks a plan against your words, so it takes no second look at your answer. A planner running Qwen 3, QwQ or DeepSeek R1, which is told not to think so that it answers faster, now thinks before it asks you a first question, and with the Planner on also before asking again, 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. With the Planner on (Try or Strict), 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; the plan is then checked against your words. So an answer such as "every five minutes" to a question about a scheduled task, the name of the person to write to, "yes, send it" or opening the conversation it asked you to open is planned. It never takes who a message goes to, an account or an amount from the page, and never writes to anyone your request or answer did not name; a schedule follows what you said, including "just do it once". With the Planner off, nothing checks a plan against your words, so it takes no second look at your answer. A planner running Qwen 3, QwQ or DeepSeek R1, which is told not to think so that it answers faster, now thinks before it asks you a first question, and with the Planner on also before asking again, unless reasoning is turned off for that provider. Chrome and Firefox.## [42.3.1] - 2026-10-20diff --git a/docs/architecture.md b/docs/architecture.mdindex 033cced50..fc1ad74b1 100644--- a/docs/architecture.md+++ b/docs/architecture.md@@ -936,9 +936,9 @@ The recent-history digest (`_buildPlannerHistoryDigest()`) takes the last ten auA `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). That rethink is the same request and is judged like the first answer.-In the full planner gate, on the turn that answers the planner's previous question (`_turnAnswersPlannerQuestion()`, which reads an answer as the task binding does; not in scheduled runs), the second look also re-asks: `PLANNER_REASK_GUIDANCE` is added to the system prompt. It says 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. A turn that answers a planner question always has history, so its plan is then checked for alignment with the user's words, answer included, and that check is what reads which person the answer chose, whether it gave a schedule's timing ("every five minutes", not "I'm not sure yet") and whether it approved sending ("yes, send it"). The intent check (Planner off) has no alignment check, so it takes no second look at an answer at all, neither a re-ask nor a rethink: a retry that read the answer could run a recipient, schedule or submission nothing there checks, so its first answer stands.+In the full planner gate, on the turn that answers the planner's previous question (`_turnAnswersPlannerQuestion()`, which reads an answer as the task binding does; not in scheduled runs), the second look also re-asks: `PLANNER_REASK_GUIDANCE` is added to the system prompt. It says 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. A turn that answers a planner question always has history, so its plan is then checked for alignment with the user's words, answer included, and that check is what reads which person the answer chose, whether it approved sending ("yes, send it"), and a schedule it gave, changed or dropped ("every five minutes", "just do it once"). The intent check (Planner off) has no alignment check, so it takes no second look at an answer at all, neither a re-ask nor a rethink: a retry that read the answer could run a recipient, schedule or submission nothing there checks, so its first answer stands.-An execute plan from a re-ask is also measured against what the user backed, the question they answered as the app stored it and their own words in the task, so that it cannot take what the alignment check could miss (`_plannerSecondLookRejection()`, trace note `planner_second_look_rejected` with the reason). The first answer on that turn is model output like the second look: it can keep the question but never authorizes more. A planner question keeps the people to address and the schedule of the task it asks about (`normalizePlan()` keeps `scheduling` and, for a message it does not send, `draft_recipients` on a `clarify` plan; nothing runs from it), and the stored question records them as `messageTarget` and `schedulingTool`. A question asked because the open conversation could not be pinned records that conversation too, so the reply can be planned once the user has opened it; it is pinned again before anything is sent. The plan may not address a recipient, for a message or a draft, other than the people the answered question addressed (in any order or casing), unless the user's own words in the task name every person (`adds_recipient`; the task binding is built from user turns only, and the open conversation is never taken from the page); plan a schedule of another kind than the answered question carried (`adds_schedule`: a `schedule_resume` pause never becomes a recurring `schedule_task`); or drop a `schedule_task` that the answered question or the first answer carried (`drops_schedule`: the run would do the task once instead). Another question, an answer or a plan to show runs nothing and is not checked. A plan the alignment check has the planner replace is held to the same limits, and when it goes beyond them the user keeps the question (`planner_alignment_repair` in the trace note).+An execute plan from a re-ask may still not address anyone the user did not back (`_plannerSecondLookRejection()`, trace note `planner_second_look_rejected` with the reason `adds_recipient`): the alignment check cannot keep out a recipient taken from the page when the answer points at it ("use the current chat", "look at the screen"), and the re-ask guidance forbids taking one. A planner question keeps the people to address of the task it asks about (`normalizePlan()` keeps `draft_recipients` on a `clarify` plan for a message it does not send; nothing runs from it), and the stored question records them as `messageTarget`. A question asked because the open conversation could not be pinned records that conversation too, so the reply can be planned once the user has opened it; it is pinned again before anything is sent. The plan may address only the people the answered question addressed (in any order or casing) or people the user's own words in the task name, every one of them (the task binding is built from user turns only). The open conversation is never taken from the page, and the first answer on that turn, model output like the second look, addresses no one. Another question, an answer or a plan to show runs nothing and is not checked. A plan the alignment check has the planner replace is held to the same limit, and when it goes beyond it the user keeps the question (`planner_alignment_repair` in the trace note).The trace phase is `planner_rethink` or `planner_reask` (`intent_rethink` 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.diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.jsindex 5cc03043b..272e21bb8 100644--- a/src/chrome/src/agent/agent.js+++ b/src/chrome/src/agent/agent.js@@ -27168,20 +27168,19 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d// For the planner's second look (_plannerClarifyRetry): whether the user// turn at `index` answers the planner's previous question, and what the- // user backed (_plannerSecondLookRejection): the message target and- // schedule tool that question stored, and the user's own words in the task.- // A correction or a scheduled run answers no question.+ // user backed (_plannerSecondLookRejection): the message target that+ // question stored, and the user's own words in the task. 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);if (!answersPlannerQuestion) {- return { answersPlannerQuestion: false, answeredQuestionSchedulingTool: null, answeredQuestionMessageTarget: null, taskUserText: '' };+ return { answersPlannerQuestion: false, answeredQuestionMessageTarget: null, taskUserText: '' };}const question = messages[this._plannerClarificationIndexBefore(messages, index)]?.webbrainPlannerClarification || {};return {answersPlannerQuestion: true,- answeredQuestionSchedulingTool: question.schedulingTool || null,answeredQuestionMessageTarget: normalizeMessageTarget(question.messageTarget),// The task binding is built from user turns only: the request and each// answer, never the page or an assistant turn.@@ -27252,30 +27251,25 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d|| effortOff(extra.reasoning_effort);}- // What a second look told not to re-ask may run, measured against what the- // user backed: the question they just answered, as the app stored it (a- // question keeps the people to address and the schedule of the task it- // asks about), and their own words in the task. The first answer on this- // turn is model output like the second look itself: it may keep the- // question but never authorizes more. Returns why an execute plan is- // rejected, or null. Another question, an answer or a plan to show runs- // nothing and passes. A rejected plan leaves the question with the user.- // A second look re-asks only in the full planner gate, whose alignment- // check then reads the plan against the user's words, answer included. It- // alone tells which person the answer chose, whether it gave a schedule's- // timing ("every five minutes", not "I'm not sure yet") and whether it- // approved sending ("yes, send it"); these rules keep out what it could- // take from the page or from an earlier model answer.- // - adds_recipient: a recipient, for a message or a draft (normalizePlan- // keeps a draft's addressees in draft_recipients), other than the people- // the answered question addressed, unless the user's own words name every- // person. The open conversation is never taken from the page.- // - adds_schedule: a schedule of another kind than the answered question- // carried: a schedule_resume pause never becomes a recurring- // schedule_task.- // - drops_schedule: no schedule_task where the answered question or the- // first answer carried one: the run would do the task once instead.- _plannerSecondLookRejection(firstPlan, plan, followUpContext = {}) {+ // What a second look told not to re-ask may address, measured against what+ // the user backed: the question they just answered, as the app stored it (a+ // question keeps the people to address of the task it asks about), and+ // their own words in the task. A second look re-asks only in the full+ // planner gate, whose alignment check then reads the plan against the+ // user's words, answer included: which person the answer chose, whether it+ // approved sending ("yes, send it"), and a schedule it gave, changed or+ // dropped ("every five minutes", "just do it once"). That check cannot keep+ // a recipient taken from the page out when the answer points at it ("use+ // the current chat", "look at the screen"), and the re-ask guidance forbids+ // taking one, so an execute plan is rejected (adds_recipient) for a+ // recipient, for a message or a draft (normalizePlan keeps a draft's+ // addressees in draft_recipients), other than the people the answered+ // question addressed, unless the user's own words name every person. The+ // first answer on this turn is model output like the second look itself,+ // so it addresses no one. Returns the reason, or null; another question, an+ // answer or a plan to show runs nothing and passes. A rejected plan leaves+ // the question with the user.+ _plannerSecondLookRejection(plan, followUpContext = {}) {if (plan?.request_kind !== 'execute') return null;for (const target of [plan.messaging, plan.draft_recipients]) {if (!target || this._sameMessageTarget(followUpContext?.answeredQuestionMessageTarget, target)) continue;@@ -27283,10 +27277,6 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d&& this._userTextNamesRecipients(followUpContext?.taskUserText, target.recipients)) continue;return 'adds_recipient';}- const carriedSchedule = followUpContext?.answeredQuestionSchedulingTool || null;- if (plan.scheduling && plan.scheduling.tool !== carriedSchedule) return 'adds_schedule';- if (plan.scheduling?.tool !== 'schedule_task'- && [carriedSchedule, firstPlan?.scheduling?.tool].includes('schedule_task')) return 'drops_schedule';return null;}@@ -27303,9 +27293,9 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d// question, in the full planner gate, PLANNER_REASK_GUIDANCE reminds the// planner that the executor can see what it cannot, and leaves a question// only for values that have to come from the user. An execute plan from- // it may not add a recipient or a schedule the user did not back, or drop- // a recurring schedule the task carried (_plannerSecondLookRejection), and- // the alignment check then reads it against the user's words.+ // it may not address anyone the user did not back+ // (_plannerSecondLookRejection), and the alignment check then reads it+ // against the user's words.// The answer is parsed and checked like the first one, and an execute plan// then goes through alignment, recipient pinning and review like any other.// Returns null to keep the first answer: nothing to retry, or the retry@@ -27313,7 +27303,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d// consistency repair.async _plannerClarifyRetry(tabId, provider, plannerMessages, {parseOptions = {}, intentOnly = false, reask = false, portable = false, costState = null, runId = null,- runtimeMode = 'act', onUpdate = null, followUpContext = {}, firstPlan = null,+ runtimeMode = 'act', onUpdate = null, followUpContext = {},} = {}) {const rethink = this._plannerCanRethink(provider);if (!rethink && !reask) return null;@@ -27344,7 +27334,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dawait this._tracePlannerAttemptResponse(runId, 0, provider, result, phase, 1, startedAt, chatOptions);const plan = parsePlanFromContent(result?.content, parseOptions);if (!plan || this._plannerIntentConsistencyIssue(plan, followUpContext)) return null;- const rejection = reask ? this._plannerSecondLookRejection(firstPlan, plan, followUpContext) : null;+ const rejection = reask ? this._plannerSecondLookRejection(plan, followUpContext) : null;if (rejection) {this._tracePlannerSecondLookRejection(runId, phase, rejection);return null;@@ -27449,10 +27439,9 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dif (gate.requestKind === 'clarify' && gate.plannerClarification === true) {message.webbrainPlannerClarification = {requiresSubmission: gate.requiresSubmission === true,- // The schedule and the people to address of the task this question is- // about, so the second look at the user's answer may plan them+ // The people to address of the task this question is about, so the+ // second look at the user's answer may address them// (_plannerSecondLookRejection).- schedulingTool: ['schedule_task', 'schedule_resume'].includes(gate.schedulingTool) ? gate.schedulingTool : null,messageTarget: normalizeMessageTarget(gate.messageTarget),pageUrl: String(tabInfo?.tabUrl || ''),taskText: this._progressTaskTextKey(activeTaskText).slice(0, 1600),@@ -28303,7 +28292,6 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dresponseLanguagePolicy: plan.response_language,requiresStateChange: false,requiresSubmission: plan.request_kind === 'clarify' && plan.requires_submission === true,- schedulingTool: plan.request_kind === 'clarify' ? plan.scheduling?.tool || null : null,messageTarget: plan.request_kind === 'clarify' ? plan.messaging || plan.draft_recipients || null : null,};}@@ -28315,7 +28303,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dconst present = this._userTextNamesRecipients(this._plannerUserAuthoredText(enriched), plan.messaging.recipients);if (!present) return {proceed: false, reason: 'active_recipient_unverified', requestKind: 'clarify', plannerClarification: true,- requiresStateChange: false, requiresSubmission: false, schedulingTool: plan.scheduling?.tool || null, messaging: null,+ requiresStateChange: false, requiresSubmission: false, messaging: null,message: 'The recipient could not be verified from the current task. Name the exact recipient and retry. No page tools ran.',};}@@ -28330,7 +28318,6 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dplannerClarification: true,requiresStateChange: false,requiresSubmission: true,- schedulingTool: plan.scheduling?.tool || null,// The open conversation could not be pinned yet. Once the user has// opened it, a second look may address it again, and it is pinned// again before anything is sent (_plannerSecondLookRejection).@@ -28355,7 +28342,6 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dplannerClarification: true,requiresStateChange: false,requiresSubmission: false,- schedulingTool: plan.scheduling?.tool || null,// The same for the conversation a draft is written into.messageTarget: plan.draft_recipients,};@@ -28591,7 +28577,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dreturn { proceed: false, steeringSuperseded: true };}const secondLook = await this._plannerClarifyRetry(tabId, provider, plannerMessages, {- parseOptions: plannerParseOptions, reask, firstPlan: plan,+ parseOptions: plannerParseOptions, reask,portable: plannerPortable, costState, runId, runtimeMode, onUpdate, followUpContext,});if (this._checkAbort(tabId)) return { proceed: false, message: '[Stopped by user]' };@@ -28639,7 +28625,6 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dresponseLanguagePolicy: candidate.response_language,requiresStateChange: false,requiresSubmission: candidate.request_kind === 'clarify' && candidate.requires_submission === true,- schedulingTool: candidate.request_kind === 'clarify' ? candidate.scheduling?.tool || null : null,messageTarget: candidate.request_kind === 'clarify' ? candidate.messaging || candidate.draft_recipients || null : null,};}@@ -28802,7 +28787,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d// limits, and is checked for alignment next. Otherwise the user// keeps the question that plan answered.const replacementRejection = reaskFirstPlan- ? this._plannerSecondLookRejection(reaskFirstPlan, plan, followUpContext)+ ? this._plannerSecondLookRejection(plan, followUpContext): null;if (replacementRejection) {this._tracePlannerSecondLookRejection(runId, 'planner_alignment_repair', replacementRejection);@@ -28868,7 +28853,6 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dplannerClarification: true,requiresStateChange: false,requiresSubmission: true,- schedulingTool: plan.scheduling?.tool || null,// The open conversation could not be pinned yet. Once the user has// opened it, a second look may address it again, and it is pinned// again before anything is sent (_plannerSecondLookRejection).@@ -28893,7 +28877,6 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dplannerClarification: true,requiresStateChange: false,requiresSubmission: false,- schedulingTool: plan.scheduling?.tool || null,// The same for the conversation a draft is written into.messageTarget: plan.draft_recipients,};diff --git a/src/chrome/src/agent/planner.js b/src/chrome/src/agent/planner.jsindex ebcf514f9..decec2fa5 100644--- a/src/chrome/src/agent/planner.js+++ b/src/chrome/src/agent/planner.js@@ -1245,7 +1245,7 @@ export function normalizePlan(obj, opts = {}) {// An open-thread draft arrives as target_kind="active_conversation" and is// pinned to its verified recipients before execution, so both kinds are kept// here; dropping the conversation kind would leave the draft unbound. A- // question about such a draft keeps them too, as it keeps its schedule.+ // question about such a draft keeps them too (Agent._plannerSecondLookRejection).const draftRecipients = submissionBearingPlan && requiresSubmission !== true? normalizeMessageTarget(obj.messaging): null;@@ -1319,11 +1319,7 @@ export function normalizePlan(obj, opts = {}) {? (memory.use_progress_ledger === true ? 'enabled' : 'disabled'): 'auto',},- // 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._plannerSecondLookRejection).- scheduling: executablePlan || requestKind === 'clarify' ? normalizedScheduling : null,+ scheduling: executablePlan ? normalizedScheduling : null,risks,localized,response_language: responseLanguage,diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.jsindex b1f624af6..d42d53589 100644--- a/src/firefox/src/agent/agent.js+++ b/src/firefox/src/agent/agent.js@@ -24206,20 +24206,19 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d// For the planner's second look (_plannerClarifyRetry): whether the user// turn at `index` answers the planner's previous question, and what the- // user backed (_plannerSecondLookRejection): the message target and- // schedule tool that question stored, and the user's own words in the task.- // A correction or a scheduled run answers no question.+ // user backed (_plannerSecondLookRejection): the message target that+ // question stored, and the user's own words in the task. 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);if (!answersPlannerQuestion) {- return { answersPlannerQuestion: false, answeredQuestionSchedulingTool: null, answeredQuestionMessageTarget: null, taskUserText: '' };+ return { answersPlannerQuestion: false, answeredQuestionMessageTarget: null, taskUserText: '' };}const question = messages[this._plannerClarificationIndexBefore(messages, index)]?.webbrainPlannerClarification || {};return {answersPlannerQuestion: true,- answeredQuestionSchedulingTool: question.schedulingTool || null,answeredQuestionMessageTarget: normalizeMessageTarget(question.messageTarget),// The task binding is built from user turns only: the request and each// answer, never the page or an assistant turn.@@ -24290,30 +24289,25 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d|| effortOff(extra.reasoning_effort);}- // What a second look told not to re-ask may run, measured against what the- // user backed: the question they just answered, as the app stored it (a- // question keeps the people to address and the schedule of the task it- // asks about), and their own words in the task. The first answer on this- // turn is model output like the second look itself: it may keep the- // question but never authorizes more. Returns why an execute plan is- // rejected, or null. Another question, an answer or a plan to show runs- // nothing and passes. A rejected plan leaves the question with the user.- // A second look re-asks only in the full planner gate, whose alignment- // check then reads the plan against the user's words, answer included. It- // alone tells which person the answer chose, whether it gave a schedule's- // timing ("every five minutes", not "I'm not sure yet") and whether it- // approved sending ("yes, send it"); these rules keep out what it could- // take from the page or from an earlier model answer.- // - adds_recipient: a recipient, for a message or a draft (normalizePlan- // keeps a draft's addressees in draft_recipients), other than the people- // the answered question addressed, unless the user's own words name every- // person. The open conversation is never taken from the page.- // - adds_schedule: a schedule of another kind than the answered question- // carried: a schedule_resume pause never becomes a recurring- // schedule_task.- // - drops_schedule: no schedule_task where the answered question or the- // first answer carried one: the run would do the task once instead.- _plannerSecondLookRejection(firstPlan, plan, followUpContext = {}) {+ // What a second look told not to re-ask may address, measured against what+ // the user backed: the question they just answered, as the app stored it (a+ // question keeps the people to address of the task it asks about), and+ // their own words in the task. A second look re-asks only in the full+ // planner gate, whose alignment check then reads the plan against the+ // user's words, answer included: which person the answer chose, whether it+ // approved sending ("yes, send it"), and a schedule it gave, changed or+ // dropped ("every five minutes", "just do it once"). That check cannot keep+ // a recipient taken from the page out when the answer points at it ("use+ // the current chat", "look at the screen"), and the re-ask guidance forbids+ // taking one, so an execute plan is rejected (adds_recipient) for a+ // recipient, for a message or a draft (normalizePlan keeps a draft's+ // addressees in draft_recipients), other than the people the answered+ // question addressed, unless the user's own words name every person. The+ // first answer on this turn is model output like the second look itself,+ // so it addresses no one. Returns the reason, or null; another question, an+ // answer or a plan to show runs nothing and passes. A rejected plan leaves+ // the question with the user.+ _plannerSecondLookRejection(plan, followUpContext = {}) {if (plan?.request_kind !== 'execute') return null;for (const target of [plan.messaging, plan.draft_recipients]) {if (!target || this._sameMessageTarget(followUpContext?.answeredQuestionMessageTarget, target)) continue;@@ -24321,10 +24315,6 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d&& this._userTextNamesRecipients(followUpContext?.taskUserText, target.recipients)) continue;return 'adds_recipient';}- const carriedSchedule = followUpContext?.answeredQuestionSchedulingTool || null;- if (plan.scheduling && plan.scheduling.tool !== carriedSchedule) return 'adds_schedule';- if (plan.scheduling?.tool !== 'schedule_task'- && [carriedSchedule, firstPlan?.scheduling?.tool].includes('schedule_task')) return 'drops_schedule';return null;}@@ -24341,9 +24331,9 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d// question, in the full planner gate, PLANNER_REASK_GUIDANCE reminds the// planner that the executor can see what it cannot, and leaves a question// only for values that have to come from the user. An execute plan from- // it may not add a recipient or a schedule the user did not back, or drop- // a recurring schedule the task carried (_plannerSecondLookRejection), and- // the alignment check then reads it against the user's words.+ // it may not address anyone the user did not back+ // (_plannerSecondLookRejection), and the alignment check then reads it+ // against the user's words.// The answer is parsed and checked like the first one, and an execute plan// then goes through alignment, recipient pinning and review like any other.// Returns null to keep the first answer: nothing to retry, or the retry@@ -24351,7 +24341,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d// consistency repair.async _plannerClarifyRetry(tabId, provider, plannerMessages, {parseOptions = {}, intentOnly = false, reask = false, portable = false, costState = null, runId = null,- runtimeMode = 'act', onUpdate = null, followUpContext = {}, firstPlan = null,+ runtimeMode = 'act', onUpdate = null, followUpContext = {},} = {}) {const rethink = this._plannerCanRethink(provider);if (!rethink && !reask) return null;@@ -24382,7 +24372,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dawait this._tracePlannerAttemptResponse(runId, 0, provider, result, phase, 1, startedAt, chatOptions);const plan = parsePlanFromContent(result?.content, parseOptions);if (!plan || this._plannerIntentConsistencyIssue(plan, followUpContext)) return null;- const rejection = reask ? this._plannerSecondLookRejection(firstPlan, plan, followUpContext) : null;+ const rejection = reask ? this._plannerSecondLookRejection(plan, followUpContext) : null;if (rejection) {this._tracePlannerSecondLookRejection(runId, phase, rejection);return null;@@ -24487,10 +24477,9 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dif (gate.requestKind === 'clarify' && gate.plannerClarification === true) {message.webbrainPlannerClarification = {requiresSubmission: gate.requiresSubmission === true,- // The schedule and the people to address of the task this question is- // about, so the second look at the user's answer may plan them+ // The people to address of the task this question is about, so the+ // second look at the user's answer may address them// (_plannerSecondLookRejection).- schedulingTool: ['schedule_task', 'schedule_resume'].includes(gate.schedulingTool) ? gate.schedulingTool : null,messageTarget: normalizeMessageTarget(gate.messageTarget),pageUrl: String(tabInfo?.tabUrl || ''),taskText: this._progressTaskTextKey(activeTaskText).slice(0, 1600),@@ -25330,7 +25319,6 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dresponseLanguagePolicy: plan.response_language,requiresStateChange: false,requiresSubmission: plan.request_kind === 'clarify' && plan.requires_submission === true,- schedulingTool: plan.request_kind === 'clarify' ? plan.scheduling?.tool || null : null,messageTarget: plan.request_kind === 'clarify' ? plan.messaging || plan.draft_recipients || null : null,};}@@ -25342,7 +25330,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dconst present = this._userTextNamesRecipients(this._plannerUserAuthoredText(enriched), plan.messaging.recipients);if (!present) return {proceed: false, reason: 'active_recipient_unverified', requestKind: 'clarify', plannerClarification: true,- requiresStateChange: false, requiresSubmission: false, schedulingTool: plan.scheduling?.tool || null, messaging: null,+ requiresStateChange: false, requiresSubmission: false, messaging: null,message: 'The recipient could not be verified from the current task. Name the exact recipient and retry. No page tools ran.',};}@@ -25357,7 +25345,6 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dplannerClarification: true,requiresStateChange: false,requiresSubmission: true,- schedulingTool: plan.scheduling?.tool || null,// The open conversation could not be pinned yet. Once the user has// opened it, a second look may address it again, and it is pinned// again before anything is sent (_plannerSecondLookRejection).@@ -25382,7 +25369,6 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dplannerClarification: true,requiresStateChange: false,requiresSubmission: false,- schedulingTool: plan.scheduling?.tool || null,// The same for the conversation a draft is written into.messageTarget: plan.draft_recipients,};@@ -25614,7 +25600,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dreturn { proceed: false, steeringSuperseded: true };}const secondLook = await this._plannerClarifyRetry(tabId, provider, plannerMessages, {- parseOptions: plannerParseOptions, reask, firstPlan: plan,+ parseOptions: plannerParseOptions, reask,portable: plannerPortable, costState, runId, runtimeMode, onUpdate, followUpContext,});if (this._checkAbort(tabId)) return { proceed: false, message: '[Stopped by user]' };@@ -25662,7 +25648,6 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dresponseLanguagePolicy: candidate.response_language,requiresStateChange: false,requiresSubmission: candidate.request_kind === 'clarify' && candidate.requires_submission === true,- schedulingTool: candidate.request_kind === 'clarify' ? candidate.scheduling?.tool || null : null,messageTarget: candidate.request_kind === 'clarify' ? candidate.messaging || candidate.draft_recipients || null : null,};}@@ -25825,7 +25810,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d// limits, and is checked for alignment next. Otherwise the user// keeps the question that plan answered.const replacementRejection = reaskFirstPlan- ? this._plannerSecondLookRejection(reaskFirstPlan, plan, followUpContext)+ ? this._plannerSecondLookRejection(plan, followUpContext): null;if (replacementRejection) {this._tracePlannerSecondLookRejection(runId, 'planner_alignment_repair', replacementRejection);@@ -25891,7 +25876,6 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dplannerClarification: true,requiresStateChange: false,requiresSubmission: true,- schedulingTool: plan.scheduling?.tool || null,// The open conversation could not be pinned yet. Once the user has// opened it, a second look may address it again, and it is pinned// again before anything is sent (_plannerSecondLookRejection).@@ -25916,7 +25900,6 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dplannerClarification: true,requiresStateChange: false,requiresSubmission: false,- schedulingTool: plan.scheduling?.tool || null,// The same for the conversation a draft is written into.messageTarget: plan.draft_recipients,};diff --git a/src/firefox/src/agent/planner.js b/src/firefox/src/agent/planner.jsindex ebcf514f9..decec2fa5 100644--- a/src/firefox/src/agent/planner.js+++ b/src/firefox/src/agent/planner.js@@ -1245,7 +1245,7 @@ export function normalizePlan(obj, opts = {}) {// An open-thread draft arrives as target_kind="active_conversation" and is// pinned to its verified recipients before execution, so both kinds are kept// here; dropping the conversation kind would leave the draft unbound. A- // question about such a draft keeps them too, as it keeps its schedule.+ // question about such a draft keeps them too (Agent._plannerSecondLookRejection).const draftRecipients = submissionBearingPlan && requiresSubmission !== true? normalizeMessageTarget(obj.messaging): null;@@ -1319,11 +1319,7 @@ export function normalizePlan(obj, opts = {}) {? (memory.use_progress_ledger === true ? 'enabled' : 'disabled'): 'auto',},- // 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._plannerSecondLookRejection).- scheduling: executablePlan || requestKind === 'clarify' ? normalizedScheduling : null,+ scheduling: executablePlan ? normalizedScheduling : null,risks,localized,response_language: responseLanguage,diff --git a/test/planner-clarify-loop.mjs b/test/planner-clarify-loop.mjsindex 95f405bb7..6e1fccc4d 100644--- a/test/planner-clarify-loop.mjs+++ b/test/planner-clarify-loop.mjs@@ -9,10 +9,10 @@// planner told not to think (/no_think) thinks, and in the full planner// gate, 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 take a recipient or a-// schedule the user did not back, and the alignment check then reads it-// against the user's words. The intent check, which has no alignment-// check, takes no second look at an answer.+// that must come from the user. That plan may not address anyone the user+// did not back, and the alignment check then reads it against the user's+// words. The intent check, which has no alignment check, takes no second+// look at an answer.import assert from 'node:assert/strict';import { test } from 'node:test';@@ -93,10 +93,8 @@ 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.' };const ALI = { target_kind: 'named', recipients: [{ identity: 'Ali Veli', role: 'to' }] };const OPEN_CHAT = { target_kind: 'active_conversation', recipients: [] };const OPEN_CHAT_CC = { target_kind: 'active_conversation', recipients: [{ identity: 'Ali Veli', role: 'cc' }, { identity: 'Ayse Yilmaz', role: 'cc' }] };@@ -251,53 +249,41 @@ for (const build of ['chrome', 'firefox']) {assert.equal(agent._turnAnswersPlannerQuestion(messages, -1), false);});- test(`${build}: the answer context names what the question's task carried, and only for a direct answer`, () => {+ test(`${build}: the answer context names the people the question's task addresses, and only for a direct answer`, () => {const agent = newAgent();- const answer = user('every five minutes');+ const answer = user('It is Ali Veli');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 },+ const messages = [{ role: 'system', content: 'sys' }, user('Send the monthly report to my accountant')];+ messages.push(agent._plannerTerminalAssistantMessage({ requestKind: 'clarify', plannerClarification: true, message: 'Who is your accountant?', ...gate },TAB, messages[1].content, agent._progressTaskKeyForText(messages[1].content)));return [...messages, answer];};- const scheduled = asked({ schedulingTool: 'schedule_task', messageTarget: ALI });- const stored = scheduled[2].webbrainPlannerClarification;- assert.deepEqual([stored.schedulingTool, stored.messageTarget], ['schedule_task', ALI], 'the question records the schedule and the people');- assert.deepEqual([asked({})[2].webbrainPlannerClarification.schedulingTool, asked({})[2].webbrainPlannerClarification.messageTarget], [null, null]);- const invalid = asked({ schedulingTool: 'schedule_everything', messageTarget: { target_kind: 'everyone', recipients: [] } })[2].webbrainPlannerClarification;- assert.deepEqual([invalid.schedulingTool, invalid.messageTarget], [null, null], 'only a known tool and a valid target');- const context = agent._plannerQuestionAnswerContext(scheduled, 3);- assert.deepEqual([context.answersPlannerQuestion, context.answeredQuestionSchedulingTool, context.answeredQuestionMessageTarget],- [true, 'schedule_task', ALI]);- assert.match(context.taskUserText, /Check this page for a new release on a schedule[\s\S]*every five minutes/, 'the user\'s words: request and answer');- assert.doesNotMatch(context.taskUserText, /How often/, 'never the question');- assert.deepEqual(agent._plannerQuestionAnswerContext(asked({}), 3).answeredQuestionSchedulingTool, null);- const none = { answersPlannerQuestion: false, answeredQuestionSchedulingTool: null, answeredQuestionMessageTarget: null, taskUserText: '' };+ const addressed = asked({ messageTarget: ALI });+ assert.deepEqual(addressed[2].webbrainPlannerClarification.messageTarget, ALI, 'the question records the people');+ assert.equal(asked({})[2].webbrainPlannerClarification.messageTarget, null);+ assert.equal(asked({ messageTarget: { target_kind: 'everyone', recipients: [] } })[2].webbrainPlannerClarification.messageTarget, null,+ 'only a valid target');+ const context = agent._plannerQuestionAnswerContext(addressed, 3);+ assert.deepEqual([context.answersPlannerQuestion, context.answeredQuestionMessageTarget], [true, ALI]);+ assert.match(context.taskUserText, /Send the monthly report to my accountant[\s\S]*It is Ali Veli/, 'the user\'s words: request and answer');+ assert.doesNotMatch(context.taskUserText, /Who is your accountant/, 'never the question');+ const none = { answersPlannerQuestion: false, answeredQuestionMessageTarget: null, taskUserText: '' };for (const runOptions of [{ steeringRevision: 1 }, { scheduledRun: true }, { scheduledResume: true }]) {- assert.deepEqual(agent._plannerQuestionAnswerContext(scheduled, 3, runOptions), none, JSON.stringify(runOptions));+ assert.deepEqual(agent._plannerQuestionAnswerContext(addressed, 3, runOptions), none, JSON.stringify(runOptions));}- const newRequest = [...scheduled.slice(0, 3), { ...answer, webbrainTurnKind: 'request' }];+ const newRequest = [...addressed.slice(0, 3), { ...answer, webbrainTurnKind: 'request' }];assert.deepEqual(agent._plannerQuestionAnswerContext(newRequest, 3), none, 'a new request answers no question');});- test(`${build}: a question keeps the schedule and the people of the task it asks about, and nothing runs from it`, async () => {+ test(`${build}: a question about a draft keeps its people, never send authority, 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]);const aboutDraft = parse(clarifyPlan({ requires_submission: false, messaging: ALI }));assert.deepEqual([aboutDraft.messaging, aboutDraft.draft_recipients], [null, ALI], 'a draft\'s people, never send authority');const aboutMessage = parse(clarifyPlan({ messaging: ALI }));assert.deepEqual([aboutMessage.messaging, aboutMessage.draft_recipients], [ALI, null]);- 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);- }+ const aboutSchedule = parse(clarifyPlan({ requires_submission: false, summary: HOW_OFTEN, scheduling: EVERY_FIVE }));+ assert.deepEqual([aboutSchedule.scheduling, aboutSchedule.requires_state_change], [null, false], 'a question schedules nothing');});// ββ The second look βββββββββββββββββββββββββββββββββββββββββββββββββ@@ -404,7 +390,6 @@ for (const build of ['chrome', 'firefox']) {test(`${build}: a second look told not to re-ask runs only what the user backed`, async () => {const named = ALI;- const task = { tool: 'schedule_task' };// [label, first answer on this turn, second look, what the user backed, accepted]// The alignment check, which follows in the planner gate, approves here:// these are the limits it cannot be relied on for.@@ -435,17 +420,8 @@ for (const build of ['chrome', 'firefox']) {{ taskUserText: userWords('Draft a reply', 'use the current chat') }, false],['the open conversation the answered question addressed', clarifyPlan({ requires_submission: false }),plannerPlan({ requires_submission: false, messaging: OPEN_CHAT }), { answeredQuestionMessageTarget: OPEN_CHAT }, true],- ['a schedule the task did not carry', clarifyPlan(), plannerPlan({ scheduling: { ...task, hint: 'Every 43200 minutes.' } }), {}, false],- ['a schedule only the first answer on this turn carried', clarifyPlan({ scheduling: OPEN_SCHEDULE }), plannerPlan({ scheduling: EVERY_FIVE }), {}, false],- ['a schedule the answered question carried', clarifyPlan(), plannerPlan({ scheduling: EVERY_FIVE }),- { answeredQuestionSchedulingTool: 'schedule_task' }, true],- ['a recurring schedule where the answered question carried only a pause', clarifyPlan(),- plannerPlan({ scheduling: EVERY_FIVE }), { answeredQuestionSchedulingTool: 'schedule_resume' }, false],- ['a run without the recurring schedule the answered question carried', clarifyPlan(), plannerPlan(),- { answeredQuestionSchedulingTool: 'schedule_task' }, false],- ['a run without the recurring schedule the first answer on this turn carried', clarifyPlan({ scheduling: OPEN_SCHEDULE }), plannerPlan(), {}, false],- ['a run without the pause the answered question carried', clarifyPlan(), plannerPlan(),- { answeredQuestionSchedulingTool: 'schedule_resume' }, true],+ ['a schedule the answer gave, which the alignment check reads', clarifyPlan(), plannerPlan({ scheduling: EVERY_FIVE }), {}, true],+ ['one run where a schedule was asked about, which the alignment check reads', clarifyPlan({ summary: HOW_OFTEN }), plannerPlan(), {}, true],];for (const [label, first, second, extraContext, accepted] of cases) {const { agent, calls, alignmentChecks } = scriptedAgent({ provider: PLAIN_MODEL, answers: [first, second] });@@ -473,18 +449,15 @@ for (const build of ['chrome', 'firefox']) {const { parsePlanFromContent } = await import(`../src/${build}/src/agent/planner.js`);const parse = plan => parsePlanFromContent(JSON.stringify(plan), { requireIntent: true, locale: 'en' });const agent = newAgent();- const reason = (second, context = {}, first = clarifyPlan()) => agent._plannerSecondLookRejection(parse(first), parse(second), context);+ const reason = (second, context = {}) => agent._plannerSecondLookRejection(parse(second), context);assert.equal(reason(plannerPlan()), null, 'whether the answer approved sending is the alignment check\'s to read');- assert.equal(reason(plannerPlan({ messaging: ALI }), {}, clarifyPlan({ messaging: ALI })), 'adds_recipient',- 'a first answer on this turn authorizes no one');+ assert.equal(reason(plannerPlan({ scheduling: EVERY_FIVE })), null, 'and so is a schedule it gave, changed or dropped');+ assert.equal(reason(plannerPlan({ messaging: ALI })), 'adds_recipient', 'a first answer on this turn addresses no one');const namedByUser = { taskUserText: userWords('Send it to my accountant', 'Ali Veli') };assert.equal(reason(plannerPlan({ messaging: ALI }), namedByUser), null);+ assert.equal(reason(plannerPlan({ messaging: OPEN_CHAT }), { taskUserText: userWords('Reply to her', 'use the current chat') }), 'adds_recipient',+ 'the open conversation is never taken from the page');assert.equal(reason(plannerPlan({ requires_submission: false, messaging: ALI })), 'adds_recipient', 'a draft\'s recipient too');- assert.equal(reason(plannerPlan({ scheduling: EVERY_FIVE }), {}, clarifyPlan({ scheduling: OPEN_SCHEDULE })), 'adds_schedule');- const carried = { answeredQuestionSchedulingTool: 'schedule_task' };- assert.equal(reason(plannerPlan({ scheduling: EVERY_FIVE }), carried), null);- assert.equal(reason(plannerPlan(), carried), 'drops_schedule');- assert.equal(reason(plannerPlan(), {}, clarifyPlan({ scheduling: OPEN_SCHEDULE })), 'drops_schedule', 'the first answer may keep the question');for (const request_kind of ['clarify', 'respond', 'plan_only']) {const second = request_kind === 'clarify'? clarifyPlan({ summary: SECOND_QUESTION, messaging: ALI, scheduling: EVERY_FIVE })@@ -537,7 +510,7 @@ for (const build of ['chrome', 'firefox']) {const followUpContext = { answersPlannerQuestion: true };for (const [label, replacement, accepted] of [['a replacement that adds a recipient', plannerPlan({ messaging: ALI }), false],- ['a replacement that adds a recurring schedule', plannerPlan({ scheduling: EVERY_FIVE }), false],+ ['a replacement that addresses the open conversation', plannerPlan({ messaging: OPEN_CHAT }), false],['a replacement within what the user backed', plannerPlan({ summary: 'Publish the same post on LinkedIn and check that it is live.' }), true],]) {const { agent, calls, alignmentChecks } = scriptedAgent({@@ -646,39 +619,35 @@ for (const build of ['chrome', 'firefox']) {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 () => {+ test(`${build}: an answer that sets or drops a schedule is planned, and the alignment check reads it`, 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 once = plannerPlan({ requires_submission: false, summary: 'Check this page for a new release now.' });+ for (const [label, answerText, plan, tool] of [+ ['a timing', 'every five minutes', timed, 'schedule_task'],+ ['one run instead', 'never mind, just check it once now', once, null],]) {- 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 tabId = tool ? 37 : 38;+ // Asked on the first turn; on the answer the planner asks again, and+ // its second look plans what the answer said.+ const question = clarifyPlan({ requires_submission: false, summary: HOW_OFTEN });+ const { agent, calls, alignmentChecks } = scriptedAgent({ provider: PLAIN_MODEL, answers: [question, question, plan] });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, {});+ const gate = await agent._maybeRunPlannerGate(tabId, messages, user(answerText), () => {}, '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)}`);- }+ assert.equal(gate.proceed, true, `${label}: ${JSON.stringify(gate)}`);+ assert.equal(gate.requiredSchedulingTool ?? null, tool, label);+ assert.equal(alignmentChecks.length, 1, `${label}: the alignment check reads the plan against the answer`);+ assert.deepEqual(alignmentChecks[0].proposed_plan.scheduling ?? null, plan.scheduling, label);+ assert.ok(String(alignmentChecks[0].current_request).includes(answerText), label);}});@@ -706,20 +675,19 @@ for (const build of ['chrome', 'firefox']) {}});- test(`${build}: a question about a conversation that could not be pinned records it and the schedule`, async () => {+ test(`${build}: a question about a conversation that could not be pinned records it`, async () => {const cases = [- ['a scheduled message', plannerPlan({ messaging: OPEN_CHAT, scheduling: EVERY_FIVE }), true, 'schedule_task'],- ['a message', plannerPlan({ messaging: OPEN_CHAT }), true, null],- ['a draft', plannerPlan({ requires_submission: false, messaging: OPEN_CHAT }), false, null],+ ['a message', plannerPlan({ messaging: OPEN_CHAT }), true],+ ['a draft', plannerPlan({ requires_submission: false, messaging: OPEN_CHAT }), false],];for (const gate of ['planner', 'intent']) {- for (const [label, plan, sends, schedulingTool] of cases) {+ for (const [label, plan, sends] of cases) {const { agent } = scriptedAgent({ provider: PLAIN_MODEL, answers: [gate === 'planner' ? plan : intentPlan(plan)] });agent._pinActiveConversationMessagingTarget = async (_tabId, target) => (target? { ok: false, error: 'Open the conversation first.' } : { ok: true, target: null });const result = gate === 'planner' ? await fullGate(agent) : await intentGate(agent);- assert.deepEqual([result.reason, result.plannerClarification, result.requiresSubmission, result.schedulingTool, result.messageTarget],- ['active_recipient_unverified', true, sends, schedulingTool, OPEN_CHAT], `${gate} ${label}: ${JSON.stringify(result)}`);+ assert.deepEqual([result.reason, result.plannerClarification, result.requiresSubmission, result.messageTarget],+ ['active_recipient_unverified', true, sends, OPEN_CHAT], `${gate} ${label}: ${JSON.stringify(result)}`);}}});