Skip to content

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

Decide Ask's API-mutation block by the run's own mode

Claude08d86fe55dff
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index 0de17f669..4cbcc602a 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -15772,8 +15772,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
// Ask is read-only, including a turn that automatic mode starts in Ask:
// a POST/PUT/PATCH/DELETE request changes something on the server, so
// neither /allow-api nor the API-mutations setting lets one out of Ask.
+ // The run's own mode decides; a side panel opening mid-run can change
+ // the conversation's mode without changing the run's.
const apiMutationsDeniedForRun = runOptions.apiMutationsDenied === true
- || this.conversationModes.get(tabId) === 'ask';
+ || this._effectiveRunMode(tabId, '') === 'ask';
const apiMutationsAllowedForRun = () =>
!apiMutationsDeniedForRun && this.isApiMutationsAllowed(tabId);
const promptTier = this._resolvePromptTier(provider);
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index d3e12ecb1..3714344a1 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -14022,8 +14022,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
// Ask is read-only, including a turn that automatic mode starts in Ask:
// a POST/PUT/PATCH/DELETE request changes something on the server, so
// neither /allow-api nor the API-mutations setting lets one out of Ask.
+ // The run's own mode decides; a side panel opening mid-run can change
+ // the conversation's mode without changing the run's.
const apiMutationsDeniedForRun = runOptions.apiMutationsDenied === true
- || this.conversationModes.get(tabId) === 'ask';
+ || this._effectiveRunMode(tabId, '') === 'ask';
const apiMutationsAllowedForRun = () =>
!apiMutationsDeniedForRun && this.isApiMutationsAllowed(tabId);
const promptTier = this._resolvePromptTier(provider);
diff --git a/test/run.js b/test/run.js
index c4ecb65f2..c120dc4c7 100644
--- a/test/run.js
+++ b/test/run.js
@@ -85956,8 +85956,9 @@ test('a local Ask run keeps API mutations off even with the API-mutations settin
agent._skipPermissionGate = true;
agent.alwaysAllowApiMutations = true;
agent.setApiMutationsAllowed(tabId, true);
- const send = async (mode) => {
- agent.conversationModes.set(tabId, mode);
+ const send = async (mode, conversationMode = mode) => {
+ agent._runModeOverrides.set(tabId, mode);
+ agent.conversationModes.set(tabId, conversationMode);
const messages = [];
const updates = [];
await agent._executeToolBatch(
@@ -85990,6 +85991,13 @@ test('a local Ask run keeps API mutations off even with the API-mutations settin
await send('act');
assert.equal(executed, 1, `${AgentClass.name}: Act still honors the API-mutations setting`);
+
+ // A side panel opened mid-run may set the conversation's mode; the run's
+ // own mode decides.
+ await send('ask', 'act');
+ assert.equal(executed, 1, `${AgentClass.name}: an Ask run sent a POST after the conversation mode changed`);
+ await send('act', 'ask');
+ assert.equal(executed, 2, `${AgentClass.name}: an Act run was blocked by the conversation mode`);
}
});