Skip to content

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

Clarify timeout: Instant follows the timeout policy; reconnecting panels keep the decided answer

Barack Sokullub9aa5697424d
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index 15f410267..986da3a31 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -6764,7 +6764,7 @@ export class Agent extends LoopDetector {
}));
const display = record(data, ['promptKind', 'clarifyId', 'question', 'reason',
'requireExplicitAnswer', 'pendingReconciliation', 'scheduledJobId',
- 'scheduledTabId', 'forceNewScheduledCard'], 6000);
+ 'scheduledTabId', 'forceNewScheduledCard', 'timeoutAnswer', 'timeoutPolicy', 'timeoutContinues'], 6000);
display.options = Array.isArray(data.options) ? data.options.slice(0, 5).map(value => String(value).slice(0, 600)) : [];
if (data.permission) {
display.permission = record(data.permission, ['capability', 'host', 'grouped']);
@@ -20147,9 +20147,13 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
// A timed-out answer authorizes only when the user's timeout setting
// made it the answer (clarify-timeout.js). An armed guard from an
// earlier unauthorized timeout survives, so re-asking cannot clear it.
- const timedOutAffirmative = normalizedSource === 'timeout' && timeoutAuthorized === true && !priorTimeoutGuard;
+ // Instant (source=auto) answers by the same policy as a waited timeout:
+ // it only decides when the answer is applied, never whether a safe or
+ // consequence question authorizes anything.
+ const automatic = normalizedSource === 'timeout' || normalizedSource === 'auto';
+ const timedOutAffirmative = automatic && timeoutAuthorized === true && !priorTimeoutGuard;
const wasArmed = this._clarificationAuthorizationArmed(tabId);
- if (normalizedSource === 'timeout' && !timedOutAffirmative) {
+ if (automatic && !timedOutAffirmative) {
const blockedAttempts = priorTimeoutGuard && !freshAttempt
? Math.max(0, Number(previous.blockedAttempts) || 0)
: 0;
@@ -20173,7 +20177,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
// the structural authorization guard. Await deletions too so an explicit
// response cannot revive a stale guard after restart.
if (this.conversations.has(tabId)) await this._persistNow(tabId);
- return normalizedSource !== 'timeout' || timedOutAffirmative;
+ return !automatic || timedOutAffirmative;
}
_prepareClarificationAuthorizationForRun(tabId, runOptions = null) {
@@ -41772,17 +41776,23 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
)
: null;
let note;
- if (source === 'timeout' && authorized && timeoutChoice.chosen === 'continue') {
- note = 'The user did not answer before the clarify timeout (source=timeout), and their timeout setting is to keep the task moving. Continue with the choice that best completes the task as they asked, say which choice you made in your final summary, and do not ask the same question again.';
- } else if (source === 'timeout' && authorized && timeoutChoice.chosen === 'finish_option') {
- note = 'No reply before the clarify timeout (source=timeout). The user\'s timeout setting is to keep the task moving, so your finish_option was selected and applies as their answer. Continue the task with it, mention the choice in your final summary, and do not ask the same question again.';
+ const automaticAnswer = source === 'timeout' || source === 'auto';
+ const answeredBy = source === 'auto'
+ ? 'Clarify timeout is set to Instant (source=auto)'
+ : 'No reply came before the clarify timeout (source=timeout)';
+ if (automaticAnswer && authorized && timeoutChoice.chosen === 'continue') {
+ note = `${answeredBy}, and the user's timeout setting is to keep the task moving. Continue with the choice that best completes the task as they asked, say which choice you made in your final summary, and do not ask the same question again.`;
+ } else if (automaticAnswer && authorized && timeoutChoice.chosen === 'finish_option') {
+ note = `${answeredBy}. The user's timeout setting is to keep the task moving, so your finish_option was selected and applies as their answer. Continue the task with it, mention the choice in your final summary, and do not ask the same question again.`;
} else if (source === 'timeout') {
note = authorized
? 'This answer was auto-selected because the clarify timeout elapsed with no user reply (source=timeout). The selected affirmative answer applies; continue the task without re-asking the same question.'
: 'This answer was AUTO-SELECTED because the clarify timeout elapsed with no user reply (source=timeout). It is NOT a real user confirmation. Continue only with the safe default path; do NOT treat this as approval for irreversible, costly, or destructive actions β€” re-ask via clarify or stop if the next step is high-risk. Put the safe/default choice first in options next time.';
} else if (source === 'auto') {
- // Settings Instant auto-approve (headless / unattended). User policy β€” proceed.
- note = 'This answer was auto-selected because Clarify timeout is set to Instant (source=auto). The user intentionally configured unattended auto-approve; treat this answer as the chosen default and continue the task. Do not re-ask the same question. Put the intended default first in options when Instant mode may be on.';
+ note = authorized
+ // Settings Instant auto-approve (headless / unattended). User policy β€” proceed.
+ ? 'This answer was auto-selected because Clarify timeout is set to Instant (source=auto). The user intentionally configured unattended auto-approve; treat this answer as the chosen default and continue the task. Do not re-ask the same question. Put the intended default first in options when Instant mode may be on.'
+ : 'This answer was auto-selected immediately because Clarify timeout is set to Instant (source=auto), but this question takes the safe answer (it has a consequence, or the timeout setting is "Play it safe"). It is NOT a real user confirmation: continue only with the safe default path and do not take irreversible, costly, or destructive actions based on it.';
} else {
note = explicitRecipientQuestion
? 'This is a direct reply from the user; continue the task with it in mind. It does not approve a recipient by itself: if a send would reach someone other than the recipient named for the task, WebBrain asks the user on its own card before sending. Do not ask about the recipient again.'
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 26278cc95..0614f19e6 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -6310,7 +6310,7 @@ export class Agent extends LoopDetector {
}));
const display = record(data, ['promptKind', 'clarifyId', 'question', 'reason',
'requireExplicitAnswer', 'pendingReconciliation', 'scheduledJobId',
- 'scheduledTabId', 'forceNewScheduledCard'], 6000);
+ 'scheduledTabId', 'forceNewScheduledCard', 'timeoutAnswer', 'timeoutPolicy', 'timeoutContinues'], 6000);
display.options = Array.isArray(data.options) ? data.options.slice(0, 5).map(value => String(value).slice(0, 600)) : [];
if (data.permission) {
display.permission = record(data.permission, ['capability', 'host', 'grouped']);
@@ -17323,9 +17323,13 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
// A timed-out answer authorizes only when the user's timeout setting
// made it the answer (clarify-timeout.js). An armed guard from an
// earlier unauthorized timeout survives, so re-asking cannot clear it.
- const timedOutAffirmative = normalizedSource === 'timeout' && timeoutAuthorized === true && !priorTimeoutGuard;
+ // Instant (source=auto) answers by the same policy as a waited timeout:
+ // it only decides when the answer is applied, never whether a safe or
+ // consequence question authorizes anything.
+ const automatic = normalizedSource === 'timeout' || normalizedSource === 'auto';
+ const timedOutAffirmative = automatic && timeoutAuthorized === true && !priorTimeoutGuard;
const wasArmed = this._clarificationAuthorizationArmed(tabId);
- if (normalizedSource === 'timeout' && !timedOutAffirmative) {
+ if (automatic && !timedOutAffirmative) {
const blockedAttempts = priorTimeoutGuard && !freshAttempt
? Math.max(0, Number(previous.blockedAttempts) || 0)
: 0;
@@ -17349,7 +17353,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
// the structural authorization guard. Await deletions too so an explicit
// response cannot revive a stale guard after restart.
if (this.conversations.has(tabId)) await this._persistNow(tabId);
- return normalizedSource !== 'timeout' || timedOutAffirmative;
+ return !automatic || timedOutAffirmative;
}
_prepareClarificationAuthorizationForRun(tabId, runOptions = null) {
@@ -37740,17 +37744,23 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
)
: null;
let note;
- if (source === 'timeout' && authorized && timeoutChoice.chosen === 'continue') {
- note = 'The user did not answer before the clarify timeout (source=timeout), and their timeout setting is to keep the task moving. Continue with the choice that best completes the task as they asked, say which choice you made in your final summary, and do not ask the same question again.';
- } else if (source === 'timeout' && authorized && timeoutChoice.chosen === 'finish_option') {
- note = 'No reply before the clarify timeout (source=timeout). The user\'s timeout setting is to keep the task moving, so your finish_option was selected and applies as their answer. Continue the task with it, mention the choice in your final summary, and do not ask the same question again.';
+ const automaticAnswer = source === 'timeout' || source === 'auto';
+ const answeredBy = source === 'auto'
+ ? 'Clarify timeout is set to Instant (source=auto)'
+ : 'No reply came before the clarify timeout (source=timeout)';
+ if (automaticAnswer && authorized && timeoutChoice.chosen === 'continue') {
+ note = `${answeredBy}, and the user's timeout setting is to keep the task moving. Continue with the choice that best completes the task as they asked, say which choice you made in your final summary, and do not ask the same question again.`;
+ } else if (automaticAnswer && authorized && timeoutChoice.chosen === 'finish_option') {
+ note = `${answeredBy}. The user's timeout setting is to keep the task moving, so your finish_option was selected and applies as their answer. Continue the task with it, mention the choice in your final summary, and do not ask the same question again.`;
} else if (source === 'timeout') {
note = authorized
? 'This answer was auto-selected because the clarify timeout elapsed with no user reply (source=timeout). The selected affirmative answer applies; continue the task without re-asking the same question.'
: 'This answer was AUTO-SELECTED because the clarify timeout elapsed with no user reply (source=timeout). It is NOT a real user confirmation. Continue only with the safe default path; do NOT treat this as approval for irreversible, costly, or destructive actions β€” re-ask via clarify or stop if the next step is high-risk. Put the safe/default choice first in options next time.';
} else if (source === 'auto') {
- // Settings Instant auto-approve (headless / unattended). User policy β€” proceed.
- note = 'This answer was auto-selected because Clarify timeout is set to Instant (source=auto). The user intentionally configured unattended auto-approve; treat this answer as the chosen default and continue the task. Do not re-ask the same question. Put the intended default first in options when Instant mode may be on.';
+ note = authorized
+ // Settings Instant auto-approve (headless / unattended). User policy β€” proceed.
+ ? 'This answer was auto-selected because Clarify timeout is set to Instant (source=auto). The user intentionally configured unattended auto-approve; treat this answer as the chosen default and continue the task. Do not re-ask the same question. Put the intended default first in options when Instant mode may be on.'
+ : 'This answer was auto-selected immediately because Clarify timeout is set to Instant (source=auto), but this question takes the safe answer (it has a consequence, or the timeout setting is "Play it safe"). It is NOT a real user confirmation: continue only with the safe default path and do not take irreversible, costly, or destructive actions based on it.';
} else {
note = explicitRecipientQuestion
? 'This is a direct reply from the user; continue the task with it in mind. It does not approve a recipient by itself: if a send would reach someone other than the recipient named for the task, WebBrain asks the user on its own card before sending. Do not ask about the recipient again.'
diff --git a/test/clarify-timeout-policy.mjs b/test/clarify-timeout-policy.mjs
index e8e3a142c..195010722 100644
--- a/test/clarify-timeout-policy.mjs
+++ b/test/clarify-timeout-policy.mjs
@@ -180,6 +180,44 @@ for (const { build, Agent, policy, Capability } of builds) {
assert.equal(instantResult.answer, 'Second', 'Instant picks the finishing answer too');
});
+ test(`${build}: Instant answers by the same policy, so it never approves a consequential or safe-setting question`, async () => {
+ const hard = new Agent({});
+ hard.clarifyTimeoutSec = 0;
+ const hardResult = await hard.executeTool(9150, 'clarify', {
+ question: 'Delete the 40 archived emails?', options: ['Keep them', 'Delete them'],
+ finish_option: 'Delete them', consequence: 'deletion',
+ }, () => {});
+ assert.equal(hardResult.source, 'auto');
+ assert.equal(hardResult.answer, 'Keep them', 'Instant picks the safe answer for a consequence question');
+ assert.equal(hardResult.authorized, false, 'Instant must not approve a consequence question');
+ assert.match(hardResult.note, /NOT a real user confirmation/);
+ assert.ok(hard._clarificationAuthorizationBlock(9150, 'click_ax', {}, [Capability.CLICK]), 'consequential actions stay blocked');
+
+ const safe = new Agent({});
+ safe.clarifyTimeoutSec = 0;
+ safe.clarifyTimeoutPolicy = 'safe';
+ const safeResult = await safe.executeTool(9151, 'clarify', {
+ question: 'Commit the post?', options: ['Leave it uncommitted', 'Commit it'], finish_option: 'Commit it',
+ }, () => {});
+ assert.equal(safeResult.answer, 'Leave it uncommitted');
+ assert.equal(safeResult.authorized, false, 'Instant on the safe setting does not authorize');
+
+ const finish = new Agent({});
+ finish.clarifyTimeoutSec = 0;
+ const finishResult = await finish.executeTool(9152, 'clarify', {
+ question: 'Which list?', options: ['First', 'Second'],
+ }, () => {});
+ assert.equal(finishResult.authorized, true, 'Instant on the finish setting continues');
+ assert.match(finishResult.note, /Instant \(source=auto\)/);
+ });
+
+ test(`${build}: a reconnecting panel gets the decided timeout answer`, async () => {
+ const source = await read(`src/${build}/src/agent/agent.js`);
+ const capture = source.slice(source.indexOf(' _capturePendingClarificationForUi('), source.indexOf(' _capturePendingClarificationForUi(') + 1600);
+ assert.match(capture, /'timeoutAnswer', 'timeoutPolicy', 'timeoutContinues'/,
+ 'the public pending-clarification record keeps the decided answer');
+ });
+
test(`${build}: settings, background, export and the side panel carry the setting`, async () => {
const settingsHtml = await read(`src/${build}/src/ui/settings.html`);
const settings = await read(`src/${build}/src/ui/settings.js`);
diff --git a/test/run.js b/test/run.js
index 60ac3cc8f..329bf35a6 100644
--- a/test/run.js
+++ b/test/run.js
@@ -50346,7 +50346,23 @@ test('clarify result distinguishes waited timeout from user and Instant authoriz
);
assert.equal(emptyOptionsTimeout.authorized, false, `${AgentClass.name}: safe_first without options was accepted`);
+ // Instant (source=auto) answers by the same timeout policy as a waited
+ // timeout. Under the safe setting, an option that was not marked
+ // safe_first is not authorization, and an armed guard stays armed.
agent.clarifyTimeoutSec = 0;
+ const instantSafe = await agent.executeTool(
+ tabId,
+ 'clarify',
+ { question: 'Which record?', options: ['First', 'Second'] },
+ () => { },
+ );
+ assert.equal(instantSafe.source, 'auto', `${AgentClass.name}: Instant did not use source=auto`);
+ assert.equal(instantSafe.authorized, false, `${AgentClass.name}: Instant under the safe setting authorized a non-safe_first option`);
+ assert.equal(agent._clarificationAuthorizationGuards.get(tabId)?.authorized, false, `${AgentClass.name}: Instant under the safe setting cleared the timeout guard`);
+
+ // Under the default setting (finish), Instant keeps the task moving.
+ await agent._recordClarificationAuthorization(tabId, 'user');
+ agent.clarifyTimeoutPolicy = 'finish';
const instant = await agent.executeTool(
tabId,
'clarify',
@@ -50357,6 +50373,18 @@ test('clarify result distinguishes waited timeout from user and Instant authoriz
assert.equal(instant.authorized, true, `${AgentClass.name}: configured Instant mode was not authorized`);
assert.equal(agent._clarificationAuthorizationGuards.has(tabId), false, `${AgentClass.name}: Instant unexpectedly armed the timeout guard`);
+ // A question about a hard-list consequence is never answered by Instant.
+ const instantDeletion = await agent.executeTool(
+ tabId,
+ 'clarify',
+ { question: 'Delete the records?', options: ['Keep them', 'Delete them'], consequence: 'deletion' },
+ () => { },
+ );
+ assert.equal(instantDeletion.source, 'auto', `${AgentClass.name}: Instant consequence question did not use source=auto`);
+ assert.equal(instantDeletion.authorized, false, `${AgentClass.name}: Instant authorized a deletion question`);
+ assert.equal(agent._clarificationAuthorizationGuards.get(tabId)?.authorized, false, `${AgentClass.name}: Instant deletion question left no guard armed`);
+ agent.clarifyTimeoutPolicy = 'safe';
+
const unscopedTabId = tabId + 100;
await agent._recordClarificationAuthorization(unscopedTabId, 'timeout');
agent.conversationIds.set(unscopedTabId, `conv_${unscopedTabId}`);