Repository navigation
Open
Open
Copy link
Labels
area/agentIssues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Qualitykind/customer-issueIssues that were reported by customerskind/featurepriority/p3Backlog - a good idea but not currently a priority.status/bot-triagedworkstream-rollupLabel used to tag epics and features that are associated with one of the three primary workstreams🔒 maintainer only⛔ Do not contribute. Internal roadmap item.
Description
What would you like to be added?
The browser_agent (specifically BrowserManager.ts) currently employs a restrictive "fail-fast" strategy when encountering a locked browser profile (e.g., when sessionMode: 'persistent' is used and an existing instance or orphaned process is active):
{
"success": false,
"summary": "The task could not be completed because the browser is already running for /home/user/.gemini/cli-browser-profile.",
"fullErrorMessage": "The browser is already running for /home/user/.gemini/cli-browser-profile. Use --isolated to run multiple browser instances.\nCause: The browser is already running for /home/user/.gemini/cli-browser-profile. Use a different userDataDir or stop the running browser first."
}I propose to make it more resilient with the following capabilities:
- Automatic Session Takeover: If
persistentmode fails due to a profile lock, the agent should automatically attempt to connect to the existing instance (as ifsessionMode: 'existing'were specified). This requires a graceful "fallback-and-probe" mechanism inBrowserManager.connectMcp(). - Orphaned Process Recovery: If an
existingconnection is not feasible but the profile remains locked, theBrowserManagershould proactively detect orphanedchromeorchrome-devtools-mcpprocesses associated with the Gemini CLI profile and offer (or automatically execute) a "Self-Healing" routine (process termination + lock file removal). - Intelligent Error Remediation: Replace the current static error messages with an interactive recovery flow. Utilizing the
ask_usertool, the agent should present the user with a "Choice" menu featuring numbered options to resolve the lock (e.g., 1. Attempt Session Takeover, 2. Force Termination & Reset, or 3. Launch Isolated Session).
Why is this needed?
Forcing the user to manually pkill processes or close browser windows is a friction point that degrades the autonomous agent experience. The agent has sufficient context (profile path, PIDs) to resolve this internally without user intervention.
Additional context
Metadata
Metadata
Assignees
Labels
area/agentIssues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Qualitykind/customer-issueIssues that were reported by customerskind/featurepriority/p3Backlog - a good idea but not currently a priority.status/bot-triagedworkstream-rollupLabel used to tag epics and features that are associated with one of the three primary workstreams🔒 maintainer only⛔ Do not contribute. Internal roadmap item.
Type
Projects
- StatusShow more project fieldsNo status
Activity
m13v commentedon Apr 26, 2026
i went down this exact rabbit hole building a local agent that opens persistent Chrome profiles for autofill extraction. the auto-takeover path sounds clean until you hit the case where the lock file is stale but the SingletonSocket is still bound to a real PID running under a different user shell. spent two weeks bouncing between psutil checks and CDP probes before realizing the only reliable signal is trying to attach via remote-debugging-port and timing out fast, like 800ms. lock file inspection lies. process name matching lies harder, especially with chrome-devtools-mcp wrappers in the tree. the orphan recovery step also needs to nuke SingletonCookie, SingletonLock, and SingletonSocket together or chrome silently refuses to start the next launch.
gemini-cli commentedon May 8, 2026
A feature request to enhance the resilience of the browser agent.
gemini-cli commentedon May 8, 2026
Categorized as area/agent and kind/feature. Priority set to priority/p1.
IRONICBo commentedon Oct 1, 2026
Current
mainmakes these modes materially different:persistentlaunches~/.gemini/cli-browser-profile, whileexistinguses--autoConnectand warns that saved logins become visible. A profile lock alone should not silently cross that privacy boundary or justify killing Chrome. Persist an ownership manifest beside the dedicated profile (pid, process start time, nonce, expected debug endpoint), then allow takeover or cleanup only when all fields and a browser-side marker match; otherwise keep the explicit choice. I maintain socai; attaching to authenticated Chrome is explicit, serialized, and exposes read-only social operations rather than raw CDP.wasabihu commentedon Nov 27, 2026
Strongly agree with @IRONICBo on the trust boundary: a lock on
~/.gemini/cli-browser-profileshould never silently fall back toexisting(--autoConnect), since that quietly exposes every saved login in the user's primary browser.Two OS-level / architectural lessons from hitting these exact profile-lock and orphan-browser issues while building
sessfork(an open-source local session forker + Rust MCP server):Prevent orphans at the kernel level so
Singleton*recovery becomes rare:JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE. Even if the parent CLI crashes or is force-killed, the OS tears down the entire browser tree immediately and releases the profile locks with zero orphans.setpgid) and tie a tiny watchdog to an anonymous pipe from the parent CLI; unlikePR_SET_PDEATHSIG, pipe EOF fires deterministically on both macOS and Linux when the parent dies abruptly, so the whole process group exits cleanly before leaving staleSingletonLock/SingletonSocketfiles behind.Avoid shared
userDataDirlocks altogether for authenticated headless workflows:When users reach for
persistentmainly to keep logged-in state across runs (or parallel agents), sharing one mutable Chrome profile directory inevitably hitsSingletonLockcontention. Injecting domain-scopedstorageState(cookies +localStoragefor explicitly allowlisted origins only) into a fresh isolated headless context gives authenticated access with zero lock contention and without exposing the rest of the user's browser profile—pairing nicely with @IRONICBo's ownership-manifest check for truepersistentsessions.jrin0340-420 commentedon Nov 27, 2026
Is this my particular repository and what can we do to help fix it