When running inside a Dev Container, the AI agent lacks the system libraries to launch a local browser. This workflow explains how to "borrow" the user's host machine browser via remote debugging and a network bridge.
Run the following to check if you are in a constrained container:
if [ -f /.dockerenv ] || grep -q "docker\|lxc" /proc/1/cgroup; then echo "DEBUG: Running in a container. Browser visuals restricted." fi
Ask the user to launch Chrome in remote debugging mode on their Host machine and expose the port.
[!IMPORTANT] User Instructions: Please run the following command in your local terminal (not inside the container):
MacOS:
killall "Google Chrome"; /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222Linux:
google-chrome --remote-debugging-port=9222Windows (PowerShell):
& "C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222Then: In VS Code, go to the Ports tab and ensure port 9222 is forwarded.
Once the user confirms the browser is running, the agent must bridge the networking.
// turbo
Install socat:
sudo apt-get update && sudo apt-get install -y socat
Establish the bridge from the container's loopback to the host's loopback:
# Detect the host IP (usually host.docker.internal) HOST_ADDR="host.docker.internal" socat TCP-LISTEN:9222,fork,reuseaddr TCP:$HOST_ADDR:9222 &
Confirm the agent can communicate with the remote browser:
curl -I http://127.0.0.1:9222/json/version
Now the agent can use browser_subagent or open_browser_url tools. They will automatically connect to the forwarded port at 127.0.0.1:9222.