[BUG] Browser Agent action counter persists across task delegations
What happened?
The actionCounter in BrowserManager (which enforces the maxActionsPerTask limit) is currently only reset when a fresh CDP connection is established in connectMcp().
If a user performs multiple browser tasks in a single session and the browser connection remains open, the counter continues to increment across tasks.
Critical Detail: Manually closing the browser window that the agent opened does not reset the counter, as the BrowserManager instance remains cached and maintains its internal state.
Example Scenario:
- User starts a browser task.
- The agent uses 80 actions.
- The task completes, but the session/connection stays open.
- User starts a second browser task.
- BUG: The counter is still at 80. The agent only has 20 actions left before hitting the limit, even though it's a completely new task.
What did you expect to happen?
Every unique browser task delegation (every time BrowserManager.acquire() is called) should reset the actionCounter to 0.
Additionally, the maxActionsPerTask setting should be refreshed from the latest configuration at the start of every task to allow users to adjust limits without restarting the CLI.
Client information
- Platform: Linux
- Gemini CLI Version: 0.41.0-nightly.20260423
- Commit SHA:
14e50a1b7c99eafdd3c0eab179e7d928ecdcf2a6
Additional Context
The root cause is that the reset logic is tied to the connection lifecycle rather than the task delegation lifecycle. Moving the reset and config refresh to the acquire() method in BrowserManager ensures every delegation gets a clean budget and honors the latest user settings.
I've verified this fix locally and am happy to submit a Pull Request to resolve this once the issue is reviewed and marked with the help-wanted label.
[BUG] Browser Agent action counter persists across task delegations
What happened?
The
actionCounterinBrowserManager(which enforces themaxActionsPerTasklimit) is currently only reset when a fresh CDP connection is established inconnectMcp().If a user performs multiple browser tasks in a single session and the browser connection remains open, the counter continues to increment across tasks.
Critical Detail: Manually closing the browser window that the agent opened does not reset the counter, as the
BrowserManagerinstance remains cached and maintains its internal state.Example Scenario:
What did you expect to happen?
Every unique browser task delegation (every time
BrowserManager.acquire()is called) should reset theactionCounterto 0.Additionally, the
maxActionsPerTasksetting should be refreshed from the latest configuration at the start of every task to allow users to adjust limits without restarting the CLI.Client information
14e50a1b7c99eafdd3c0eab179e7d928ecdcf2a6Additional Context
The root cause is that the reset logic is tied to the connection lifecycle rather than the task delegation lifecycle. Moving the reset and config refresh to the
acquire()method inBrowserManagerensures every delegation gets a clean budget and honors the latest user settings.I've verified this fix locally and am happy to submit a Pull Request to resolve this once the issue is reviewed and marked with the
help-wantedlabel.