gemini-cli - 💡(How to fix) Fix [BUG] Browser Agent action counter persists across task delegations [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
google-gemini/gemini-cli#25979Fetched 2026-04-26 05:24:20
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
0
Author
Timeline (top)
commented ×1labeled ×1

Root Cause

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.

RAW_BUFFERClick to expand / collapse

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

extent analysis

TL;DR

Move the reset logic of the actionCounter to the acquire() method in BrowserManager to ensure it resets on every task delegation.

Guidance

  • Identify the current implementation of the connectMcp() method in BrowserManager and understand how it resets the actionCounter.
  • Modify the acquire() method in BrowserManager to reset the actionCounter to 0 at the start of every task delegation.
  • Refresh the maxActionsPerTask setting from the latest configuration at the start of every task in the acquire() method.
  • Verify the fix by testing multiple browser tasks in a single session and checking that the actionCounter resets correctly.

Example

// Example of how the acquire() method could be modified
acquire() {
  // Reset the actionCounter to 0 at the start of every task delegation
  this.actionCounter = 0;
  // Refresh the maxActionsPerTask setting from the latest configuration
  this.maxActionsPerTask = getLatestConfig().maxActionsPerTask;
  // ... rest of the acquire() method implementation
}

Notes

This fix assumes that the acquire() method is called at the start of every task delegation, and that the connectMcp() method is only called when a fresh CDP connection is established.

Recommendation

Apply the workaround by modifying the acquire() method in BrowserManager to reset the actionCounter and refresh the maxActionsPerTask setting, as this directly addresses the root cause of the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

gemini-cli - 💡(How to fix) Fix [BUG] Browser Agent action counter persists across task delegations [1 comments, 2 participants]