Skip to content

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

Ask cards: a user's answer survives Continue of the same task

Barack Sokullu94312ce6928e
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index 99eb0e3f5..aaf7a2fe1 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -30387,6 +30387,14 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
return entry;
}
+ // The answers a trusted Continue of the same task keeps: the user's own,
+ // newest last. An answer WebBrain chose (timeout, Instant, unattended, no
+ // card) is not carried; the continued run lets the user answer.
+ _carriedUnverifiedStepDecisions(guard) {
+ return (Array.isArray(guard?.unverifiedStepDecisions) ? guard.unverifiedStepDecisions : [])
+ .filter(entry => entry?.source === 'user' && entry.taskKey === guard.taskKey).slice(-32);
+ }
+
_rememberUnverifiedStepDecision(tabId, ask, reading, choice, source) {
const guard = this._planExecutionGuards.get(tabId);
if (!guard) return null;
@@ -38251,6 +38259,13 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
// The user's answers on WebBrain's deletion card hold for the same task.
deletionDecisions: carryMatches && Array.isArray(carried.deletionDecisions)
? structuredClone(carried.deletionDecisions.slice(-32)) : [],
+ // So do the user's own answers on its unverified-step card. They are
+ // authorization, not execution evidence, so they need only the same task
+ // scope: a "Don't" is not asked again for the same step and content, and
+ // a one-use "Go ahead" keeps its consumed state. The task token still
+ // binds them (_unverifiedStepDecisions).
+ unverifiedStepDecisions: carryScopeMatches && Array.isArray(carried.unverifiedStepDecisions)
+ ? structuredClone(carried.unverifiedStepDecisions.slice(-32)) : [],
approvedPlan: this._hasApprovedExecutionPlan(this.conversations.get(tabId) || []),
// Only the app-owned Continue action can carry verified evidence from
// the immediately preceding run; ordinary user turns always start at 0.
@@ -38738,6 +38753,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
|| guard.verifiedSubmissionEvidence === true
|| !!guard.steeringPriorSubmission
|| (guard.deletionDecisions || []).length > 0
+ || this._carriedUnverifiedStepDecisions(guard).length > 0
|| !!guard.workflowTerminalEvidence
|| !!guard.workflowLedgerReconciliation
|| !!guard.workflowInventoryEvidence
@@ -38788,6 +38804,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
steeringPriorSubmissionReconciliation: structuredClone(guard.steeringPriorSubmissionReconciliation || null),
resourceMutationDispatches: structuredClone(guard.resourceMutationDispatches || []),
deletionDecisions: structuredClone((guard.deletionDecisions || []).slice(-32)),
+ unverifiedStepDecisions: structuredClone(this._carriedUnverifiedStepDecisions(guard)),
socialPublication: guard.socialPublication ? structuredClone(guard.socialPublication) : null,
socialPublicationClarifications: structuredClone(guard.socialPublicationClarifications || []),
socialPublicationSteering: guard.socialPublicationSteering ? structuredClone(guard.socialPublicationSteering) : null,
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 6d486657f..fff4ec74b 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -27499,6 +27499,14 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
return entry;
}
+ // The answers a trusted Continue of the same task keeps: the user's own,
+ // newest last. An answer WebBrain chose (timeout, Instant, unattended, no
+ // card) is not carried; the continued run lets the user answer.
+ _carriedUnverifiedStepDecisions(guard) {
+ return (Array.isArray(guard?.unverifiedStepDecisions) ? guard.unverifiedStepDecisions : [])
+ .filter(entry => entry?.source === 'user' && entry.taskKey === guard.taskKey).slice(-32);
+ }
+
_rememberUnverifiedStepDecision(tabId, ask, reading, choice, source) {
const guard = this._planExecutionGuards.get(tabId);
if (!guard) return null;
@@ -35120,6 +35128,13 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
// The user's answers on WebBrain's deletion card hold for the same task.
deletionDecisions: carryMatches && Array.isArray(carried.deletionDecisions)
? structuredClone(carried.deletionDecisions.slice(-32)) : [],
+ // So do the user's own answers on its unverified-step card. They are
+ // authorization, not execution evidence, so they need only the same task
+ // scope: a "Don't" is not asked again for the same step and content, and
+ // a one-use "Go ahead" keeps its consumed state. The task token still
+ // binds them (_unverifiedStepDecisions).
+ unverifiedStepDecisions: carryScopeMatches && Array.isArray(carried.unverifiedStepDecisions)
+ ? structuredClone(carried.unverifiedStepDecisions.slice(-32)) : [],
approvedPlan: this._hasApprovedExecutionPlan(this.conversations.get(tabId) || []),
// Only the app-owned Continue action can carry verified evidence from
// the immediately preceding run; ordinary user turns always start at 0.
@@ -35607,6 +35622,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
|| guard.verifiedSubmissionEvidence === true
|| !!guard.steeringPriorSubmission
|| (guard.deletionDecisions || []).length > 0
+ || this._carriedUnverifiedStepDecisions(guard).length > 0
|| !!guard.workflowTerminalEvidence
|| !!guard.workflowLedgerReconciliation
|| !!guard.workflowInventoryEvidence
@@ -35657,6 +35673,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
steeringPriorSubmissionReconciliation: structuredClone(guard.steeringPriorSubmissionReconciliation || null),
resourceMutationDispatches: structuredClone(guard.resourceMutationDispatches || []),
deletionDecisions: structuredClone((guard.deletionDecisions || []).slice(-32)),
+ unverifiedStepDecisions: structuredClone(this._carriedUnverifiedStepDecisions(guard)),
socialPublication: guard.socialPublication ? structuredClone(guard.socialPublication) : null,
socialPublicationClarifications: structuredClone(guard.socialPublicationClarifications || []),
socialPublicationSteering: guard.socialPublicationSteering ? structuredClone(guard.socialPublicationSteering) : null,
diff --git a/test/guard-ask-cards.mjs b/test/guard-ask-cards.mjs
index 042d3849a..0a9027c50 100644
--- a/test/guard-ask-cards.mjs
+++ b/test/guard-ask-cards.mjs
@@ -371,6 +371,98 @@ for (const { build, Agent, adapters, Scheduler } of builds) {
assert.equal(dispatched.length, 0);
});
+ // A trusted Continue (the app's Continue after the step limit) starts a new
+ // run of the same task: a new plan guard, built from what the last run
+ // carried. The planner resolves the commit's metadata in each run; the
+ // fixture's requirements stand in for it.
+ function planGuard(agent, tab, { trustedContinuation = false } = {}) {
+ const previous = agent._planExecutionGuards.get(tab);
+ const guard = agent._startPlanExecutionGuard(tab, 'act', { requestKind: 'execute', siteWorkflow: previous.siteWorkflow,
+ requiresStateChange: true, requiresSubmission: true }, trustedContinuation ? { trustedContinuation: true } : {});
+ Object.assign(guard, { workflowMetadataRequirements: previous.workflowMetadataRequirements.map(item => ({ ...item })),
+ workflowMetadataRequirementsResolved: true, workflowMetadataRequirementsIncomplete: false });
+ return guard;
+ }
+ const continueTask = (agent, tab) => {
+ agent._storeContinuationExecutionEvidence(tab);
+ return planGuard(agent, tab, { trustedContinuation: true });
+ };
+
+ test(`${build}: a denied commit stays denied after Continue of the same task, even when a timeout would go ahead`, async () => {
+ const { agent, tab, provider, page } = await githubFixture();
+ const first = planGuard(agent, tab);
+ const denied = pipeline(agent, provider, 'deny');
+ await denied.run(tab, [call('commit-1', 'click_ax', { ref_id: 'ref_7' })]);
+ assert.equal(denied.cards.length, 1);
+ assert.equal(denied.dispatched.length, 0);
+ const continued = continueTask(agent, tab);
+ assert.notEqual(continued, first, 'the continued run has its own plan guard');
+ assert.deepEqual(continued.unverifiedStepDecisions.map(entry => [entry.choice, entry.source]), [['deny', 'user']]);
+ // Nobody answers now, and the timeout setting would let a card go ahead.
+ agent.clarifyTimeoutPolicy = 'finish';
+ agent.clarifyTimeoutSec = 1;
+ const unanswered = pipeline(agent, provider, null);
+ const { messages } = await unanswered.run(tab, [call('commit-2', 'click_ax', { ref_id: 'ref_7' })]);
+ assert.equal(unanswered.cards.length, 0, 'the declined text is not asked about again');
+ assert.equal(unanswered.dispatched.length, 0, 'the commit never goes ahead');
+ const refused = resultFor(messages, 'commit-2');
+ assert.equal(refused.unverifiedStepDeclined, true);
+ assert.match(refused.error, /The user already chose not to go ahead/);
+ // Different editor text is a different step to ask about.
+ page.editor = `${POST_BODY}Late edit.\n`;
+ const changed = pipeline(agent, provider, 'once');
+ await changed.run(tab, [call('commit-3', 'click_ax', { ref_id: 'ref_7' })]);
+ assert.equal(changed.cards.length, 1, 'changed content is asked about again');
+ assert.equal(changed.cards[0].unverifiedStepConfirmation.content, page.editor);
+ assert.equal(changed.dispatched.length, 1);
+ });
+
+ test(`${build}: a denial is not carried into a run that is not a Continue, and a timeout's answer is not carried at all`, async () => {
+ // An ordinary new run (not the app's Continue) builds its guard afresh.
+ const fresh = await githubFixture();
+ planGuard(fresh.agent, fresh.tab);
+ await pipeline(fresh.agent, fresh.provider, 'deny').run(fresh.tab, [call('commit-1', 'click_ax', { ref_id: 'ref_7' })]);
+ fresh.agent._storeContinuationExecutionEvidence(fresh.tab);
+ const next = planGuard(fresh.agent, fresh.tab);
+ assert.deepEqual(next.unverifiedStepDecisions, []);
+ const asked = pipeline(fresh.agent, fresh.provider, 'once');
+ await asked.run(fresh.tab, [call('commit-2', 'click_ax', { ref_id: 'ref_7' })]);
+ assert.equal(asked.cards.length, 1, 'a new run asks the user again');
+ assert.equal(asked.dispatched.length, 1);
+ // An unanswered card under "Play it safe" is WebBrain's answer, not the
+ // user's: the continued run asks the user instead of refusing for them.
+ const timed = await githubFixture();
+ planGuard(timed.agent, timed.tab);
+ timed.agent.clarifyTimeoutPolicy = 'safe';
+ timed.agent.clarifyTimeoutSec = 1;
+ const unanswered = pipeline(timed.agent, timed.provider, null);
+ await unanswered.run(timed.tab, [call('commit-1', 'click_ax', { ref_id: 'ref_7' })]);
+ assert.equal(unanswered.dispatched.length, 0);
+ assert.equal(timed.agent._planExecutionGuards.get(timed.tab).unverifiedStepDecisions[0].source, 'timeout');
+ const continued = continueTask(timed.agent, timed.tab);
+ assert.deepEqual(continued.unverifiedStepDecisions, []);
+ const answered = pipeline(timed.agent, timed.provider, 'once');
+ await answered.run(timed.tab, [call('commit-2', 'click_ax', { ref_id: 'ref_7' })]);
+ assert.equal(answered.cards.length, 1, 'the user is asked again after Continue');
+ assert.equal(answered.dispatched.length, 1);
+ });
+
+ test(`${build}: a one-use answer carried by Continue stays one-use`, async () => {
+ const { agent, tab } = await githubFixture();
+ planGuard(agent, tab);
+ const remember = (stepKey, choice) => agent._rememberUnverifiedStepDecision(tab,
+ { guardId: 'github-commit-split-write-required', stepKey }, { sha256: '', length: null }, choice, 'user');
+ remember('step-used', 'once');
+ assert.ok(agent._unverifiedStepApproval(tab, 'github-commit-split-write-required', 'step-used', { consume: true }));
+ remember('step-unused', 'once');
+ continueTask(agent, tab);
+ assert.equal(agent._unverifiedStepApproval(tab, 'github-commit-split-write-required', 'step-used', { consume: true }), null,
+ 'an approval used before Continue is not usable again');
+ assert.ok(agent._unverifiedStepApproval(tab, 'github-commit-split-write-required', 'step-unused', { consume: true }),
+ 'an approval not yet used covers its one action');
+ assert.equal(agent._unverifiedStepApproval(tab, 'github-commit-split-write-required', 'step-unused', { consume: true }), null);
+ });
+
test(`${build}: an unanswered commit card goes ahead under 'finish' and not under 'safe'`, async () => {
for (const [policy, goesAhead] of [['finish', true], ['safe', false]]) {
const { agent, tab, provider } = await githubFixture();