Skip to content

An agentic browser harness: an AI side panel & orb in your own logged-in Chrome, Edge, Arc, Brave or even Firefox run by the agent/subscription you already use (Claude Code, Codex, Antigravity). Free, open source, no API key. Also an MCP server.

fix(agents): point a Codex run at the browser tools it cannot see, and switch off the web search it answered from instead, because Codex defers every MCP tool and no longer knows the key that disabled searching

Shahriar9bc5c3aca889
diff --git a/docs/internals/guardrails.md b/docs/internals/guardrails.md
index 1c6ea2a..0d0913a 100644
--- a/docs/internals/guardrails.md
+++ b/docs/internals/guardrails.md
@@ -341,7 +341,7 @@ type LocalTools = 'allowlist' | 'sandbox' | 'host'
| Agent | Mode | What that means |
| --- | --- | --- |
| **Claude Code** | `allowlist` | A per-run tool allowlist plus an explicit deny list. `Read` is denied for a browser run — it reads pages, never the disk |
-| **Codex** | `sandbox` | No per-run tool list; the read-only sandbox is the whole containment, **so the agent can still read any file the user can** |
+| **Codex** | `sandbox` | No per-run tool list; the read-only sandbox is the whole containment, **so the agent can still read any file the user can**. `features.multi_agent=false` is required too: a sub-agent is spawned outside the run's gate and reports nothing to the panel |
| **Antigravity** | `host` | No tool list and no sandbox flag; its built-in tools are governed by the user's own CLI settings, so a sealed environment is the only containment Browsentic applies |
| **Mistral Vibe** | `allowlist` | `--enabled-tools` is the whole of what loads: Browsentic's MCP tools, plus web search and fetch on a research run. The shell and file tools never exist in the run, and `--auto-approve` is a forbidden flag |
| **Grok Build** | `allowlist` | A per-run built-in tool list, `--permission-mode dontAsk`, deny rules, and a kernel sandbox for writes. Reads are closed by the tool list and a `Read` deny rather than the sandbox, and MCP servers the user set up in Grok itself still load |
diff --git a/src/daemon/agent/runners/codex.test.ts b/src/daemon/agent/runners/codex.test.ts
index dc1e874..dab0931 100644
--- a/src/daemon/agent/runners/codex.test.ts
+++ b/src/daemon/agent/runners/codex.test.ts
@@ -3,17 +3,29 @@ import { join } from 'node:path';
import { describe, expect, test } from 'vitest';
import { stateDir } from '../../lockfile';
import { codexRunner } from './codex';
+import type { Plan } from './types';
import { jsonContext, readThrough, shown, streamContext, transcript } from './fixtures/support';
const settings = { bin: 'codex' };
const stream = (overrides: Parameters<typeof streamContext>[1] = {}) => codexRunner.stream(streamContext(settings, overrides));
+
+const INSTRUCTIONS = 'developer_instructions=';
+
+/** The prompt is asserted on its own below; a snapshot of the flags reads better without it. */
+const flagsOf = (plan: Plan): Plan => ({
+ ...plan,
+ args: plan.args.map((arg) => (arg.startsWith(INSTRUCTIONS) ? `${INSTRUCTIONS}<prompt>` : arg)),
+});
+
+const instructionsIn = (args: string[]): string =>
+ JSON.parse(args.find((arg) => arg.startsWith(INSTRUCTIONS))?.slice(INSTRUCTIONS.length) ?? '""') as string;
const read = (name: string, only?: Parameters<typeof readThrough>[2]) => readThrough(codexRunner, transcript('codex', name), only);
const readLines = (...lines: object[]) => readThrough(codexRunner, lines.map((line) => JSON.stringify(line)));
const recorded = (name: string) => transcript('codex', name).join('\n');
describe('a streamed run', () => {
test('a fresh run registers the browser as its only server and stays in a read-only sandbox', () => {
- expect(shown(stream())).toMatchInlineSnapshot(`
+ expect(flagsOf(shown(stream()))).toMatchInlineSnapshot(`
{
"args": [
"exec",
@@ -24,6 +36,14 @@ describe('a streamed run', () => {
"approval_policy="never"",
"--skip-git-repo-check",
"-c",
+ "features.multi_agent=false",
+ "-c",
+ "features.goals=false",
+ "-c",
+ "features.tool_suggest=false",
+ "-c",
+ "include_apps_instructions=false",
+ "-c",
"mcp_servers.browsentic.command="/usr/local/bin/node"",
"-c",
"mcp_servers.browsentic.args=["/usr/local/lib/node_modules/browsentic/dist/cli.js","mcp"]",
@@ -34,9 +54,9 @@ describe('a streamed run', () => {
"-c",
"mcp_servers.browsentic.default_tools_approval_mode="approve"",
"-c",
- "developer_instructions="You are Browsentic."",
+ "developer_instructions=<prompt>",
"-c",
- "tools.web_search=false",
+ "web_search="disabled"",
"--",
"what does this page cost",
],
@@ -62,11 +82,34 @@ describe('a streamed run', () => {
expect(stream().args).toContain('mcp_servers.browsentic.default_tools_approval_mode="approve"');
});
+ // The `tools.web_search` this used to pass is a key Codex 0.155 no longer knows, and an unknown
+ // key is ignored in silence — so every run had web search, and reached for it before the browser.
test('research turns web search on, and it is off otherwise', () => {
- expect([stream({ research: true }).args, stream().args].map((args) => args.find((arg) => arg.startsWith('tools.web_search=')))).toEqual([
- 'tools.web_search=true',
- 'tools.web_search=false',
+ expect([stream({ research: true }).args, stream().args].map((args) => args.find((arg) => arg.startsWith('web_search=')))).toEqual([
+ 'web_search="live"',
+ 'web_search="disabled"',
]);
+ expect(stream().args.some((arg) => arg.startsWith('tools.web_search'))).toBe(false);
+ });
+
+ test('a run is not offered sub-agents, goals, connector apps or plugin suggestions', () => {
+ expect(stream().args.filter((arg) => arg.startsWith('features.') || arg.startsWith('include_'))).toEqual([
+ 'features.multi_agent=false',
+ 'features.goals=false',
+ 'features.tool_suggest=false',
+ 'include_apps_instructions=false',
+ ]);
+ });
+
+ // Codex defers an MCP server's tools behind tool_search, so a run that says nothing about them
+ // watches the model answer from the tools it can see: its own memory and a web search.
+ test('the prompt says how to reach tools Codex has not loaded, and to read the page rather than recall it', () => {
+ const instructions = instructionsIn(stream().args);
+ expect(instructions.startsWith('You are Browsentic.')).toBe(true);
+ expect(instructions).toContain('tool_search');
+ expect(instructions).toContain('tools.mcp__browsentic__');
+ expect(instructions).toContain('image(result.content[0])');
+ expect(instructions).toMatch(/never answer from memory/i);
});
test('the chosen model and effort are passed through', () => {
@@ -87,8 +130,10 @@ describe('a streamed run', () => {
});
test('a system prompt with quotes and line breaks survives as one TOML string', () => {
- const instructions = stream({ systemPrompt: 'Rule one.\nSay "done" when done.' }).args.find((arg) => arg.startsWith('developer_instructions='));
- expect(instructions).toBe('developer_instructions="Rule one.\\nSay \\"done\\" when done."');
+ const args = stream({ systemPrompt: 'Rule one.\nSay "done" when done.' }).args;
+ const raw = args.find((arg) => arg.startsWith('developer_instructions='));
+ expect(raw?.startsWith('developer_instructions="Rule one.\\nSay \\"done\\" when done.\\n\\n')).toBe(true);
+ expect(instructionsIn(args).startsWith('Rule one.\nSay "done" when done.\n\n')).toBe(true);
});
test('it runs in the state directory, where its saved threads are looked up', () => {
@@ -110,9 +155,17 @@ describe('a one-shot task', () => {
"approval_policy="never"",
"--skip-git-repo-check",
"-c",
+ "features.multi_agent=false",
+ "-c",
+ "features.goals=false",
+ "-c",
+ "features.tool_suggest=false",
+ "-c",
+ "include_apps_instructions=false",
+ "-c",
"mcp_servers={}",
"-c",
- "tools.web_search=false",
+ "web_search="disabled"",
"--",
"summarize this",
],
diff --git a/src/daemon/agent/runners/codex.ts b/src/daemon/agent/runners/codex.ts
index 1836df9..9cc0b6e 100644
--- a/src/daemon/agent/runners/codex.ts
+++ b/src/daemon/agent/runners/codex.ts
@@ -13,8 +13,46 @@ import type { JsonContext, Plan, Runner, StreamContext, StreamReader } from './t
*/
const SANDBOX = ['-c', 'sandbox_mode="read-only"', '-c', 'approval_policy="never"', '--skip-git-repo-check'];
+/**
+ * Codex features a browsing run has no use for, each of which costs a tool or a block of
+ * instructions in every turn: sub-agents, its goal memory, connector apps, and the list of
+ * plugins it suggests installing. A feature name Codex no longer knows is ignored rather than
+ * refused, so these stay harmless as it moves on.
+ */
+const QUIETED = [
+ '-c',
+ 'features.multi_agent=false',
+ '-c',
+ 'features.goals=false',
+ '-c',
+ 'features.tool_suggest=false',
+ '-c',
+ 'include_apps_instructions=false',
+];
+
const WEB_TOOL = 'web_search';
+/**
+ * Codex 0.155 dropped `tools.web_search` for a top-level mode and ignores a key it does not know
+ * without saying so, which left web search switched on for every run — the one tool a model whose
+ * browser tools are deferred can still see, and so the one it reached for.
+ */
+const searching = (research: boolean): string[] => ['-c', `web_search=${tomlString(research ? 'live' : 'disabled')}`];
+
+/**
+ * Codex keeps an MCP server's tools out of the model's tool list: they are deferred behind
+ * `tool_search`, and a code-mode model reaches them only from inside `exec`. A run that does not
+ * say so watches the model answer from memory or a web search, because those it can see. Codex
+ * also cuts a tool result at about 10,000 tokens, which a whole-page snapshot passes.
+ */
+const REACHING_THE_BROWSER = `# Reaching the browser from Codex
+
+Your browsentic tools are not in your tool list yet, because Codex defers them. Before you plan anything, call \`tool_search\` for what this job needs — query "browsentic page", limit 20 — and search again for a tool you have not loaded. If the only way you can call a tool is \`exec\`, the same tools are there as \`tools.mcp__browsentic__<name>({ ... })\`: find them by filtering \`ALL_TOOLS\`, and pass a screenshot on with \`image(result.content[0])\`, because \`text()\` alone drops the picture.
+
+The page the user means is the one open in their browser. Read it with these tools. Never answer from memory, from a web search, or by fetching the page from the shell.
+
+Codex truncates a tool result over roughly 10,000 tokens, so ask for less at a time — \`page_getPageInfo\` with a small \`maxPerKind\`, \`page_extractText\` with the cursor it hands back — rather than one large read whose middle goes missing.`;
+
interface Item {
id?: string;
type?: string;
@@ -75,6 +113,7 @@ export const codexRunner: Runner = {
...(context.sessionId ? ['resume', context.sessionId] : []),
'--json',
...SANDBOX,
+ ...QUIETED,
'-c',
`${server}.command=${tomlString(mcp.command)}`,
'-c',
@@ -87,9 +126,8 @@ export const codexRunner: Runner = {
'-c',
`${server}.default_tools_approval_mode="approve"`,
'-c',
- `developer_instructions=${tomlString(context.systemPrompt)}`,
- '-c',
- `tools.web_search=${research}`,
+ `developer_instructions=${tomlString(`${context.systemPrompt.trim()}\n\n${REACHING_THE_BROWSER}`)}`,
+ ...searching(research),
...(settings.model ? ['--model', settings.model] : []),
...(effort ? ['-c', `model_reasoning_effort=${tomlString(effort)}`] : []),
'--',
@@ -202,10 +240,10 @@ export const codexRunner: Runner = {
'--json',
'--ephemeral',
...SANDBOX,
+ ...QUIETED,
'-c',
'mcp_servers={}',
- '-c',
- 'tools.web_search=false',
+ ...searching(false),
...(settings.model ? ['--model', settings.model] : []),
...(effort ? ['-c', `model_reasoning_effort=${tomlString(effort)}`] : []),
'--',
diff --git a/src/daemon/guardrails/spawn.ts b/src/daemon/guardrails/spawn.ts
index ab8fdd7..93afa06 100644
--- a/src/daemon/guardrails/spawn.ts
+++ b/src/daemon/guardrails/spawn.ts
@@ -152,12 +152,13 @@ export const CONTAINMENT: Record<AgentKind, Containment> = {
keepsEnv: ['OPENAI_', 'CODEX_', 'AZURE_OPENAI_'],
note: 'no per-run tool list; the read-only sandbox is the whole containment, so the agent can still read any file the user can',
run: {
- required: ['sandbox_mode="read-only"', 'approval_policy="never"'],
+ // Sub-agents are spawned outside the run's gate and report nothing to the panel.
+ required: ['sandbox_mode="read-only"', 'approval_policy="never"', 'features.multi_agent=false'],
pairs: [],
files: [],
},
task: {
- required: ['sandbox_mode="read-only"', 'approval_policy="never"', 'mcp_servers={}'],
+ required: ['sandbox_mode="read-only"', 'approval_policy="never"', 'mcp_servers={}', 'features.multi_agent=false'],
pairs: [],
files: [],
},