Skip to content

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

Keep planner answers and pending verification through turn and done checks

Emre Sokullu58efd8637602
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index 5c1adb1da..919938ffa 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -22910,6 +22910,22 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
return -1;
}
+ // Index of the planner question that the turn at answerIndex directly
+ // answers, or -1. answerIndex may be one past the end for a turn that is
+ // not recorded yet. A planner clarification is terminal for its turn. Skip
+ // only app-owned state projected around it; any other real conversational
+ // turn breaks the binding so an old clarification cannot capture a later
+ // independent task.
+ _plannerClarificationIndexBefore(messages, answerIndex) {
+ for (let index = answerIndex - 1; index >= 1; index -= 1) {
+ const message = messages[index];
+ if (this._isPinnedAgentStateMessage(message) || this._isLocalConversationStatusMessage(message)) continue;
+ if (message?.role === 'user' && this._isAgentInjectedUserMessage(message)) continue;
+ return message?.role === 'assistant' && message.webbrainPlannerClarification ? index : -1;
+ }
+ return -1;
+ }
+
_plannerClarificationTaskBinding(messages, answerIndex) {
if (!Array.isArray(messages) || answerIndex < 1) return null;
const answerMessage = messages[answerIndex];
@@ -22917,17 +22933,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const answerText = this._plannerUserAuthoredText(answerMessage);
if (!answerText) return null;
- // A planner clarification is terminal for its turn. Skip only app-owned
- // state projected around it; any other real conversational turn breaks the
- // binding so an old clarification cannot capture a later independent task.
- let clarificationIndex = -1;
- for (let index = answerIndex - 1; index >= 1; index -= 1) {
- const message = messages[index];
- if (this._isPinnedAgentStateMessage(message) || this._isLocalConversationStatusMessage(message)) continue;
- if (message?.role === 'user' && this._isAgentInjectedUserMessage(message)) continue;
- if (message?.role === 'assistant' && message.webbrainPlannerClarification) clarificationIndex = index;
- break;
- }
+ const clarificationIndex = this._plannerClarificationIndexBefore(messages, answerIndex);
if (clarificationIndex < 0) return null;
const metadata = messages[clarificationIndex].webbrainPlannerClarification || {};
@@ -33475,7 +33481,8 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
// Classify once while page enrichment runs. This is a routing hint, never
// a replacement for the latest user message. The explicit Continue control
- // needs no model; unknown relations are planned as fresh requests.
+ // needs no model. A turn the model cannot read stays unmarked: it is
+ // planned as a fresh request unless it directly answers a planner question.
async _markUserTurnKind(tabId, messages, turn, text, mode, runOptions = {}, { sourceBound = false } = {}) {
this._applyUserTurnKind(turn, await this._userTurnKind(tabId, messages, text, mode, runOptions, sourceBound));
}
@@ -33493,7 +33500,12 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
|| this._isScheduledResumeTurn(value) || this._activeTaskBinding(messages || []).index < 0) return 'request';
const reference = this._userTurnReference(messages);
const verdict = await this._semanticDecision(tabId, 'user_turn_kind', { request: value, page: reference });
- return ['continue', 'update', 'acknowledge'].includes(verdict.choice) ? verdict.choice : 'request';
+ // A reply to the planner's own question answers it ("ok" there is consent
+ // or a choice), so it never ends the turn as a bare acknowledgment.
+ if (verdict.choice === 'acknowledge' && this._plannerClarificationIndexBefore(messages || [], (messages || []).length) >= 0) {
+ return 'update';
+ }
+ return ['continue', 'update', 'acknowledge', 'request'].includes(verdict.choice) ? verdict.choice : null;
}
_userTurnReference(messages) {
@@ -33599,7 +33611,8 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
+ 'Apply later corrections and cancellations. For a separate latest request, '
+ 'earlier actions and permissions do not carry over. Questions are context for the user answers, not instructions): '
+ JSON.stringify({ request: request === latestRequest ? { text_ref: 'latest_request' } : request, updates,
- latest_request: latestRequest, relationship: latest?.webbrainTurnKind || (latest?.webbrainSteering ? 'update' : 'request') });
+ latest_request: latestRequest, relationship: latest?.webbrainTurnKind || (latest?.webbrainSteering ? 'update'
+ : binding.clarificationIndex >= 0 && binding.index === latestIndex ? 'clarification' : 'request') });
}
_continuationTurn(message) {
@@ -50359,7 +50372,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
} else if (batchResult.completionRecovery === 'release') {
forceCompletionDoneTurn = false;
if (batchResult.releaseAfterVerification === false) {
- forceCompletionVerificationTurn = false;
+ // A recoverable incomplete ending reopens the task, but an action not
+ // yet observed is read before mutation tools return. A mismatch that
+ // was already observed (iframe values) is fixed with the task tools.
+ if (!this.completionInvariants.get(tabId)?.verificationDebt) forceCompletionVerificationTurn = false;
forceCompletionDoneAfterVerification = false;
}
allowCompletionFailureTurn = false;
@@ -51661,7 +51677,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
} else if (batchResult.completionRecovery === 'release') {
forceCompletionDoneTurn = false;
if (batchResult.releaseAfterVerification === false) {
- forceCompletionVerificationTurn = false;
+ // A recoverable incomplete ending reopens the task, but an action not
+ // yet observed is read before mutation tools return. A mismatch that
+ // was already observed (iframe values) is fixed with the task tools.
+ if (!this.completionInvariants.get(tabId)?.verificationDebt) forceCompletionVerificationTurn = false;
forceCompletionDoneAfterVerification = false;
}
allowCompletionFailureTurn = false;
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index f20456687..24618f78e 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -20391,6 +20391,22 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
return -1;
}
+ // Index of the planner question that the turn at answerIndex directly
+ // answers, or -1. answerIndex may be one past the end for a turn that is
+ // not recorded yet. A planner clarification is terminal for its turn. Skip
+ // only app-owned state projected around it; any other real conversational
+ // turn breaks the binding so an old clarification cannot capture a later
+ // independent task.
+ _plannerClarificationIndexBefore(messages, answerIndex) {
+ for (let index = answerIndex - 1; index >= 1; index -= 1) {
+ const message = messages[index];
+ if (this._isPinnedAgentStateMessage(message) || this._isLocalConversationStatusMessage(message)) continue;
+ if (message?.role === 'user' && this._isAgentInjectedUserMessage(message)) continue;
+ return message?.role === 'assistant' && message.webbrainPlannerClarification ? index : -1;
+ }
+ return -1;
+ }
+
_plannerClarificationTaskBinding(messages, answerIndex) {
if (!Array.isArray(messages) || answerIndex < 1) return null;
const answerMessage = messages[answerIndex];
@@ -20398,17 +20414,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const answerText = this._plannerUserAuthoredText(answerMessage);
if (!answerText) return null;
- // A planner clarification is terminal for its turn. Skip only app-owned
- // state projected around it; any other real conversational turn breaks the
- // binding so an old clarification cannot capture a later independent task.
- let clarificationIndex = -1;
- for (let index = answerIndex - 1; index >= 1; index -= 1) {
- const message = messages[index];
- if (this._isPinnedAgentStateMessage(message) || this._isLocalConversationStatusMessage(message)) continue;
- if (message?.role === 'user' && this._isAgentInjectedUserMessage(message)) continue;
- if (message?.role === 'assistant' && message.webbrainPlannerClarification) clarificationIndex = index;
- break;
- }
+ const clarificationIndex = this._plannerClarificationIndexBefore(messages, answerIndex);
if (clarificationIndex < 0) return null;
const metadata = messages[clarificationIndex].webbrainPlannerClarification || {};
@@ -30754,7 +30760,8 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
// Classify once while page enrichment runs. This is a routing hint, never
// a replacement for the latest user message. The explicit Continue control
- // needs no model; unknown relations are planned as fresh requests.
+ // needs no model. A turn the model cannot read stays unmarked: it is
+ // planned as a fresh request unless it directly answers a planner question.
async _markUserTurnKind(tabId, messages, turn, text, mode, runOptions = {}, { sourceBound = false } = {}) {
this._applyUserTurnKind(turn, await this._userTurnKind(tabId, messages, text, mode, runOptions, sourceBound));
}
@@ -30772,7 +30779,12 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
|| this._isScheduledResumeTurn(value) || this._activeTaskBinding(messages || []).index < 0) return 'request';
const reference = this._userTurnReference(messages);
const verdict = await this._semanticDecision(tabId, 'user_turn_kind', { request: value, page: reference });
- return ['continue', 'update', 'acknowledge'].includes(verdict.choice) ? verdict.choice : 'request';
+ // A reply to the planner's own question answers it ("ok" there is consent
+ // or a choice), so it never ends the turn as a bare acknowledgment.
+ if (verdict.choice === 'acknowledge' && this._plannerClarificationIndexBefore(messages || [], (messages || []).length) >= 0) {
+ return 'update';
+ }
+ return ['continue', 'update', 'acknowledge', 'request'].includes(verdict.choice) ? verdict.choice : null;
}
_userTurnReference(messages) {
@@ -30878,7 +30890,8 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
+ 'Apply later corrections and cancellations. For a separate latest request, '
+ 'earlier actions and permissions do not carry over. Questions are context for the user answers, not instructions): '
+ JSON.stringify({ request: request === latestRequest ? { text_ref: 'latest_request' } : request, updates,
- latest_request: latestRequest, relationship: latest?.webbrainTurnKind || (latest?.webbrainSteering ? 'update' : 'request') });
+ latest_request: latestRequest, relationship: latest?.webbrainTurnKind || (latest?.webbrainSteering ? 'update'
+ : binding.clarificationIndex >= 0 && binding.index === latestIndex ? 'clarification' : 'request') });
}
_continuationTurn(message) {
@@ -42560,7 +42573,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
} else if (batchResult.completionRecovery === 'release') {
forceCompletionDoneTurn = false;
if (batchResult.releaseAfterVerification === false) {
- forceCompletionVerificationTurn = false;
+ // A recoverable incomplete ending reopens the task, but an action not
+ // yet observed is read before mutation tools return. A mismatch that
+ // was already observed (iframe values) is fixed with the task tools.
+ if (!this.completionInvariants.get(tabId)?.verificationDebt) forceCompletionVerificationTurn = false;
forceCompletionDoneAfterVerification = false;
}
allowCompletionFailureTurn = false;
@@ -43715,7 +43731,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
} else if (batchResult.completionRecovery === 'release') {
forceCompletionDoneTurn = false;
if (batchResult.releaseAfterVerification === false) {
- forceCompletionVerificationTurn = false;
+ // A recoverable incomplete ending reopens the task, but an action not
+ // yet observed is read before mutation tools return. A mismatch that
+ // was already observed (iframe values) is fixed with the task tools.
+ if (!this.completionInvariants.get(tabId)?.verificationDebt) forceCompletionVerificationTurn = false;
forceCompletionDoneAfterVerification = false;
}
allowCompletionFailureTurn = false;
diff --git a/test/follow-up-task-context.mjs b/test/follow-up-task-context.mjs
index e6866e1c5..c157e1474 100644
--- a/test/follow-up-task-context.mjs
+++ b/test/follow-up-task-context.mjs
@@ -277,6 +277,45 @@ for (const build of ['chrome', 'firefox']) {
assert.equal(agent._plannerAuthenticTaskText(messages), 'Instead explain this article.');
});
+ // An unavailable reading must not turn the answer into a new task, and "ok"
+ // to the planner's own question must not end the turn as an acknowledgment.
+ for (const reading of [null, 'acknowledge']) {
+ test(`${build}: a reply to the planner question answers it when the reading is ${reading || 'unavailable'}`, async () => {
+ const { agent, messages } = fixture();
+ const question = 'Which email should I use?';
+ messages.push({ role: 'assistant', content: question, webbrainPlannerClarification: {
+ taskText: root, taskKey: agent._progressTaskKeyForText(root), requiresSubmission: true } });
+ const answer = reading ? 'ok, the one already filled in' : 'use [email protected]';
+ const calls = installModelStub(agent, { decide: (_kind, { request, page }) => {
+ assert.equal(page.last_question, question);
+ return reading ? { choice: reading, evidence: request } : null;
+ } });
+ const turn = user(answer);
+ await agent._markUserTurnKind(tab, messages, turn, answer, 'act');
+ assert.equal(calls.length, 1);
+ assert.equal(turn.webbrainTurnKind, reading ? 'update' : undefined);
+ const view = [...messages, turn];
+ const binding = agent._activeTaskBinding(view);
+ assert.equal(binding.taskIndex, 1);
+ assert.equal(binding.clarificationIndex, 2);
+ const task = agent._plannerAuthenticTaskText(view);
+ const parsed = JSON.parse(task.slice(task.indexOf('{')));
+ assert.equal(parsed.request, root);
+ assert.equal(parsed.latest_request, answer);
+ assert.equal(parsed.relationship, reading ? 'update' : 'clarification');
+ let planned = null;
+ agent._runPlannerGate = async (_tab, _enriched, _update, _cost, _run, _history, _info, _plannerMode, _mode, _options, follow) => {
+ planned = follow.authenticTaskText;
+ return { proceed: true, requestKind: 'execute', requiresStateChange: true };
+ };
+ const result = await agent._maybeRunPlannerGate(tab, messages, turn, () => {}, 'act', {}, null,
+ { tabUrl: 'https://owned.test/form', tabTitle: 'Form' });
+ assert.equal(result.proceed, true, JSON.stringify(result));
+ assert.equal(planned, task, 'The planner receives the answer with the task it clarifies.');
+ assert.equal(agent._progressTaskAnchorText(tab), binding.text);
+ });
+ }
+
test(`${build}: corrections keep task history while later no-send overrides earlier send intent`, async () => {
const { agent, messages } = fixture();
const calls = installModelStub(agent, { decide: (_kind, { request, page }) => {
@@ -368,7 +407,7 @@ for (const build of ['chrome', 'firefox']) {
const turn = user(latest);
await agent._markUserTurnKind(tab, messages, turn, turn.content, 'act');
messages.push(turn);
- assert.equal(turn.webbrainTurnKind, 'request');
+ assert.equal(turn.webbrainTurnKind, undefined, 'An unread turn stays unmarked.');
assert.equal(agent._plannerAuthenticTaskText(messages), latest);
delete turn.webbrainTurnKind;
assert.equal(agent._plannerAuthenticTaskText(messages), latest);
diff --git a/test/incomplete-completion-recovery.mjs b/test/incomplete-completion-recovery.mjs
index 9c546481b..b4fde1f5a 100644
--- a/test/incomplete-completion-recovery.mjs
+++ b/test/incomplete-completion-recovery.mjs
@@ -227,4 +227,137 @@ for (const build of ['chrome', 'firefox']) {
} finally { api.tabs.executeScript = previousExecute; if (cdp) Object.assign(cdp, previousCdp); }
});
}
+
+ // A full run of the real agent loop over an owned page. `script(names,
+ // request)` plays the model; `execute(name, args)` stands in for the browser.
+ async function runOwnedTask({ streaming, task, url, pageState, judge, script, execute }) {
+ const tab = nextTab++;
+ const next = async (messages, options) => {
+ const fixed = fixtureFixedChoiceReply(messages, { incomplete_task: judge, done_summary: 'result' });
+ if (fixed !== null) return { content: fixed };
+ if (String(messages[0]?.content).startsWith('Evaluate only the observable requirements')) {
+ return { content: '{"outcome":"succeeded","reason":"Fresh owned confirmation observed."}' };
+ }
+ return script(options.tools?.map(tool => tool.function.name) || []);
+ };
+ const provider = { model: 'owned', name: 'Owned', promptTier: 'full', supportsTools: true, supportsVision: false,
+ contextWindow: 128000, config: { category: 'local' }, chat: next,
+ async *chatStream(messages, options) { const result = await next(messages, options);
+ if (result.content) yield { type: 'text', content: result.content };
+ if (result.toolCalls) yield { type: 'tool_call', content: result.toolCalls.map((entry, index) => ({ ...entry, index })) };
+ yield { type: 'done' }; } };
+ const agent = new Agent({ getActive: () => provider, getProvider: () => provider, getVisionProvider: async () => null });
+ Object.assign(agent, {
+ _hydrate: async () => {}, _persist: () => {}, _persistNow: async () => ({ ok: true }), _persistSubmittedTurn: async () => {},
+ _startTraceRun: async () => null, _endTraceRun: async () => {}, _beginReadCompleteness: async () => null,
+ _manageContext: async () => {}, _checkCostAllowance: async () => null, _recordCostUsage: async () => null,
+ _currentUrl: async () => url, _getTabUrlTitle: async () => ({ tabUrl: url, tabTitle: 'Owned task' }),
+ _maybeEmitAskModeHandoff: async () => {}, _maybeReinjectAdapter: async () => {}, _ensureProgressSessionForCurrentTask: async () => {},
+ _enrichUserMessageWithCurrentPage: async (_tab, _messages, content) => ({ role: 'user', content }),
+ _plannerMode: () => 'off',
+ _runPlannerIntentGate: async () => ({ proceed: true, requestKind: 'execute', requiresStateChange: true,
+ requiresSubmission: false, siteWorkflowUrl: url }),
+ _skipPermissionGate: true, _ensureGateSetting: async () => true, _adoptLiveSocialPublishWorkflow: async () => false,
+ _isFormValidationCandidate: () => false, _preflightRichTextToolbarTarget: async () => ({ block: null }),
+ _auditRichTextToolbarTarget: async () => {}, _shouldAutoScreenshot: () => false, _pageFeedbackIdleMs: 0,
+ _completionDocumentStamp: async () => `${url}|1000`, _captureViewportProbe: async () => ({ url, title: 'Owned task' }),
+ });
+ for (const name of ['_chromeProtectedPageFailure', '_captchaMutationPreflight', '_workflowPreSubmitDispatchBlock',
+ '_messageRecipientGuardBlock', '_detectLikelySubmitAction', '_socialPublicationPreSubmitBlock']) agent[name] = async () => null;
+ agent.maxSteps = 12;
+ agent._executeToolWithLifecycle = async (_tab, name, args) => (name === 'done'
+ ? agent._executeToolImpl(tab, name, args) : execute(name, args));
+ const state = () => ({ url, title: 'Owned task', documentIdentity: `${url}|1000`, openDialogCount: 0,
+ relevantFormCount: 0, liveRegionMessages: [], ...pageState() });
+ const previousExecute = api.tabs.executeScript;
+ const previousCdp = cdp && Object.fromEntries(['attach', 'sendCommand', 'evaluate'].map(name => [name, cdp[name]]));
+ api.tabs.executeScript = async () => [state()];
+ if (cdp) { cdp.attach = async () => {}; cdp.sendCommand = async () => ({});
+ cdp.evaluate = async () => ({ result: { value: state() } }); }
+ try {
+ return streaming ? await agent.processMessageStream(tab, task, () => {}, 'act')
+ : await agent.processMessage(tab, task, () => {}, 'act');
+ } finally { api.tabs.executeScript = previousExecute; if (cdp) Object.assign(cdp, previousCdp); }
+ }
+
+ for (const streaming of [false, true]) {
+ // The failure-only turn of an unverifiable action must not become a way
+ // back to mutation tools: a recoverable ending keeps the verification turn
+ // until the dispatched action is observed.
+ test(`${build}: ${streaming ? 'stream' : 'chat'} keeps an unverified action read-only after a recoverable incomplete ending`, async () => {
+ const actions = [];
+ let pageText = 'Saving...\nSubmit', requests = 0, judgments = 0, reads = 0;
+ const result = await runOwnedTask({ streaming, task: 'Submit the owned form.', url: 'https://owned.example.test/form',
+ pageState: () => ({ workflowPageText: pageText, incompleteTaskControls: [{ label: 'Submit',
+ disabled: pageText.startsWith('Saving'), busy: pageText.startsWith('Saving') }] }),
+ judge: () => { judgments++; return 'wait_then_check'; },
+ script: names => {
+ requests++;
+ if (requests === 1) return call('submit', 'click_ax', { ref_id: 'ref_submit' });
+ if (requests === 2) return call('early', 'done', { outcome: 'success', summary: 'Submitted.' });
+ if (requests === 3) { assert.equal(names.includes('click_ax'), false); return call('read-failed', 'get_accessibility_tree', {}); }
+ if (requests === 4) { assert.ok(names.includes('done')); assert.equal(names.includes('click_ax'), false);
+ return call('give-up', 'done', { outcome: 'partial', summary: 'Could not verify the submission.' }); }
+ if (requests === 5) {
+ assert.equal(names.includes('click_ax'), false, `The unverified action reopened mutation tools: ${names.join(', ')}`);
+ assert.ok(names.includes('get_accessibility_tree'));
+ return call('read', 'get_accessibility_tree', {});
+ }
+ assert.equal(requests, 6, 'Observation ends the verification turn.');
+ assert.ok(names.includes('click_ax'), 'Observation clears the debt and restores the task tools.');
+ return call('complete', 'done', { outcome: 'success', summary: 'Owned operation complete.' });
+ },
+ execute: name => {
+ actions.push(name);
+ if (name === 'click_ax') return { success: true, dispatched: true, verified: false };
+ assert.equal(name, 'get_accessibility_tree');
+ // The first observation fails, so the dispatched action stays unverified.
+ if (++reads === 1) return { success: false, error: 'Owned read failure' };
+ pageText = 'Owned operation complete';
+ return { success: true, pageContent: pageText, pageUrl: 'https://owned.example.test/form' };
+ },
+ });
+ assert.equal(result, 'Owned operation complete.');
+ assert.equal(judgments, 1);
+ assert.equal(actions.filter(name => name === 'click_ax').length, 1, 'The action is never repeated.');
+ assert.equal(requests, 6);
+ });
+
+ // An observed mismatch is different: verify_form already read the iframe
+ // field, and only iframe_type can correct it, so the redirect returns the
+ // task tools.
+ test(`${build}: ${streaming ? 'stream' : 'chat'} corrects an observed iframe value mismatch after a recoverable incomplete ending`, async () => {
+ const actions = [], field = { selector: '#email', urlFilter: 'owned-frame.test', text: '[email protected]', clear: true };
+ let requests = 0, judgments = 0, corrected = false, matched = false;
+ const result = await runOwnedTask({ streaming, task: 'Fill the owned email field.', url: 'https://owned.example.test/form',
+ pageState: () => ({ workflowPageText: 'Email: [email protected]', incompleteTaskControls: [] }),
+ judge: () => { judgments++; return 'continue_now'; },
+ script: names => {
+ requests++;
+ if (requests === 1) return call('type', 'iframe_type', field);
+ if (requests === 2) return call('early', 'done', { outcome: 'success', summary: 'Filled.' });
+ const taskTools = names.includes('iframe_type');
+ if (taskTools && judgments && !corrected) { corrected = true; return call('fix', 'iframe_type', field); }
+ if (taskTools && matched) return call('complete', 'done', { outcome: 'success', summary: 'Email field verified.' });
+ if (!taskTools && names.includes('done')) {
+ return call('give-up', 'done', { outcome: 'partial', summary: 'The email field shows a different value.' });
+ }
+ return call(`verify-${requests}`, 'verify_form', { urlFilter: 'owned-frame.test' });
+ },
+ execute: name => {
+ actions.push(name);
+ if (name === 'iframe_type') return { success: true, value: '[email protected]', frameId: 3, matchIndex: 0 };
+ if (name === 'verify_form') {
+ matched = corrected;
+ return { success: true, scope: 'iframe', urlFilter: 'owned-frame.test', targetChecks: [{ matched: true,
+ valueMatchesExpected: corrected, selector: '#email', frameId: 3, matchIndex: 0, scope: 'owned-frame.test' }] };
+ }
+ return { success: true, pageContent: 'Email: [email protected]', pageUrl: 'https://owned.example.test/form' };
+ },
+ });
+ assert.equal(result, 'Email field verified.');
+ assert.equal(judgments, 1);
+ assert.equal(corrected, true, 'The redirect offered iframe_type to correct the observed mismatch.');
+ });
+ }
}
diff --git a/test/user-turn-kind.mjs b/test/user-turn-kind.mjs
index 7edcb922b..58b801be9 100644
--- a/test/user-turn-kind.mjs
+++ b/test/user-turn-kind.mjs
@@ -6,8 +6,8 @@ import { installModelStub } from './semantic-decision-stub.mjs';
// only in English, through word lists. A short Act turn after an earlier task
// is now read by a model in any language, once, when it arrives; the answer is
// stored on the turn, so the task anchor, ledger scope and approved plan read
-// it without words. Anything the model cannot read with confidence is a new
-// request, as an unrecognised word was before.
+// it without words. Anything the model cannot read with confidence stays
+// unmarked and is a new request, as an unrecognised word was before.
const area = { get: async () => ({}), set: async () => {}, remove: async () => {} };
globalThis.chrome = globalThis.browser = { storage: { local: area, session: area }, runtime: { getURL: value => `extension://owned/${value}` } };
const earlier = 'Follow every stargazer on this page and record each one.';
@@ -69,7 +69,9 @@ for (const build of ['chrome', 'firefox']) {
{ choice: 'resume', evidence: 'devam et' }, null]) {
const f = fixture(() => answer);
const turn = await f.mark('devam et');
- assert.equal(turn.webbrainTurnKind, 'request', JSON.stringify(answer));
+ assert.equal(turn.webbrainTurnKind, undefined, JSON.stringify(answer));
+ f.agent.conversations.get(f.tab).push(turn);
+ assert.equal(f.agent._progressTaskAnchorText(f.tab), 'devam et', 'An unread turn is a new request');
}
// The decision model answers first when it is enabled and sure.
const f = fixture(() => { throw new Error('The active model is not asked'); });