Skip to content

[BUG] Browser Agent action counter persists across task delegations #25979

@hsm207

Description

@hsm207

[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:

  1. User starts a browser task.
  2. The agent uses 80 actions.
  3. The task completes, but the session/connection stays open.
  4. User starts a second browser task.
  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/agentIssues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Qualitykind/bugpriority/p2Important but can be addressed in a future release.status/bot-triaged

    Type

    No fields configured for Bug.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions