Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: describe empty browser bridge results accurately (#5061)

[._.]/ Adam Eivyefbcc1a6a3eb
diff --git a/server/services/agentPromptBuilder.js b/server/services/agentPromptBuilder.js
index af155becce..789d3b9b92 100644
--- a/server/services/agentPromptBuilder.js
+++ b/server/services/agentPromptBuilder.js
@@ -84,7 +84,7 @@ export const UI_AUDIT_TASK_TYPES = Object.freeze([
const UI_AUDIT_TASK_TYPE_SET = new Set(UI_AUDIT_TASK_TYPES);
export const UI_AUDIT_RUNTIME_RULE = `## UI Audit Runtime (PortOS local system)
-This is an unattended run, but it is not browserless when the target has a web UI. PortOS provides a managed Chromium browser for CoS agents over Chrome DevTools Protocol (CDP). The agent-facing browser bridge is separate from that managed browser: the empty-registry case (agent.browsers.list() === []), getForUrl() returning "No browser is available", or an otherwise unusable agent-browser binding is a provider-bridge failure, not evidence that PortOS's managed Chromium or CDP endpoint is unavailable. Do not skip live UI verification because the provider bridge is empty, unusable, or no human is present.
+This is an unattended run, but it is not browserless when the target has a web UI. PortOS provides a managed Chromium browser for CoS agents over Chrome DevTools Protocol (CDP). The agent-facing browser bridge is separate from that managed browser: an empty array returned by agent.browsers.list() ([]), getForUrl() returning "No browser is available", or an otherwise unusable agent-browser binding is a provider-bridge failure, not evidence that PortOS's managed Chromium or CDP endpoint is unavailable. Do not skip live UI verification because the provider bridge is empty, unusable, or no human is present.
- When the agent browser bridge is empty or unusable, query the configured PortOS health endpoint (usually /api/browser/health) and the CDP /json/version or /json/list endpoints before stopping. A healthy PortOS health/CDP response overrides the provider's "No browser is available" response.
- Reuse the PortOS-managed browser over CDP instead of launching a separate browser. Check the browser status/configuration when needed; the CDP endpoint is local and its port is configurable (the shipped default is 127.0.0.1:5556). For a local smoke check, select a normal type: "page" target from /json/list and attach to its webSocketDebuggerUrl with Node's WebSocket or another installed CDP client; if /json/list is empty, create an about:blank page target with PUT /json/new?about:blank. Navigate the page with Page.navigate, then inspect it with Runtime.evaluate on that same page socket. Do not send Page or Runtime commands to the browser-level socket from /json/version; use Page, Runtime, Log, and Network domains on the page socket for live evidence.
diff --git a/server/services/agentPromptBuilder.test.js b/server/services/agentPromptBuilder.test.js
index 707cbcd831..bd4331a6ff 100644
--- a/server/services/agentPromptBuilder.test.js
+++ b/server/services/agentPromptBuilder.test.js
@@ -382,6 +382,8 @@ describe('buildLightContextPrompt', () => {
expect(prompt).toContain(UI_AUDIT_RUNTIME_RULE);
expect(prompt).toContain('not browserless');
expect(prompt).toContain('agent.browsers.list()');
+ expect(prompt).toContain('empty array returned by agent.browsers.list() ([])');
+ expect(prompt).not.toContain('agent.browsers.list() === []');
expect(prompt).toContain('getForUrl()');
expect(prompt).toContain('No browser is available');
expect(prompt).toContain('provider-bridge failure');