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
Forget the runtime's Ask limitation text when its run ends or the next begins
Claude40c83e7fdc7a
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.jsindex ef3d44ebc..de04acc59 100644--- a/src/chrome/src/agent/agent.js+++ b/src/chrome/src/agent/agent.js@@ -1359,6 +1359,8 @@ export class Agent extends LoopDetector {}async _beginReadCompleteness(tabId, userMessage, runOptions = {}) {+ // A limitation text remembered for an earlier run is not this run's.+ this._runtimeAskLimitations?.delete(tabId);this._readCompletenessRunCounter += 1;const token = `read_${tabId}_${Date.now()}_${this._readCompletenessRunCounter}`;if (this._isStandaloneChatRun(runOptions)) {@@ -1378,6 +1380,7 @@ export class Agent extends LoopDetector {if (!state) return;if (runToken && state.runToken !== runToken) return;this.readCompletenessStates.delete(tabId);+ this._runtimeAskLimitations?.delete(tabId);}diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.jsindex b7584e79b..fdc5a58a8 100644--- a/src/firefox/src/agent/agent.js+++ b/src/firefox/src/agent/agent.js@@ -988,6 +988,8 @@ export class Agent extends LoopDetector {}async _beginReadCompleteness(tabId, userMessage, runOptions = {}) {+ // A limitation text remembered for an earlier run is not this run's.+ this._runtimeAskLimitations?.delete(tabId);this._readCompletenessRunCounter += 1;const token = `read_${tabId}_${Date.now()}_${this._readCompletenessRunCounter}`;if (this._isStandaloneChatRun(runOptions)) {@@ -1007,6 +1009,7 @@ export class Agent extends LoopDetector {if (!state) return;if (runToken && state.runToken !== runToken) return;this.readCompletenessStates.delete(tabId);+ this._runtimeAskLimitations?.delete(tabId);}diff --git a/test/auto-mode.mjs b/test/auto-mode.mjsindex ec9339447..5463a3c68 100644--- a/test/auto-mode.mjs+++ b/test/auto-mode.mjs@@ -843,6 +843,22 @@ for (const build of BUILDS) {assert.equal(classified, 0, 'the runtime limitation is offered without asking the classifier');});+ test(`${build}: the runtime's Ask limitation text is forgotten when its run ends or the next begins`, async () => {+ const f = fixture(Agent, { replies: [done('Unused.')] });+ const state = { required: true, complete: false, requiresExpansionEvidence: true, treeCoverageComplete: true };+ f.agent.readCompletenessStates.set(f.tab, state);+ const limitation = f.agent._readCompletenessLimitation(f.tab);+ assert.equal(f.agent._runtimeAskLimitations.get(f.tab), limitation);+ f.agent._clearReadCompleteness(f.tab);+ assert.equal(f.agent._runtimeAskLimitations.has(f.tab), false, 'cleared with the read state');+ f.agent.readCompletenessStates.set(f.tab, state);+ f.agent._readCompletenessLimitation(f.tab);+ delete f.agent._beginReadCompleteness; // the fixture stubs it+ f.agent._currentUrl = async () => 'https://example.test/';+ await f.agent._beginReadCompleteness(f.tab, 'Summarize this thread', {});+ assert.equal(f.agent._runtimeAskLimitations.has(f.tab), false, 'cleared when the next run begins');+ });+test(`${build}: a slow decision model leaves the turn read-only after the grace period`, async () => {// The decision never answers; the turn goes on without it.const f = fixture(Agent, { decide: () => new Promise(() => {}), replies: [done('Read-only answer.')] });