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): tell Antigravity's model the page is in the user's browser and reached only through call_mcp_tool, because agy ranks AGENTS.md as a rule beneath its own coding-agent identity and read "how is the browsentic repo doing" as git status in the scratch folder

Shahriar82048698b0bb
diff --git a/src/daemon/agent/runners/antigravity.test.ts b/src/daemon/agent/runners/antigravity.test.ts
index a29f113..c2ed1d9 100644
--- a/src/daemon/agent/runners/antigravity.test.ts
+++ b/src/daemon/agent/runners/antigravity.test.ts
@@ -12,7 +12,7 @@ const read = (name: string) => readThrough(antigravityRunner, transcript('antigr
const readLines = (...lines: object[]) => readThrough(antigravityRunner, lines.map((line) => JSON.stringify(line)));
describe('a streamed run', () => {
- test("a run is written into its conversation's folder: the browser server and the system prompt", () => {
+ test("a run is written into its conversation's folder: the browser server, the system prompt, and where the page is", () => {
expect(shown(stream())).toMatchInlineSnapshot(`
{
"args": [
@@ -48,6 +48,12 @@ describe('a streamed run', () => {
},
{
"content": "You are Browsentic.
+
+ # Where the page is
+
+ The user is looking at a page in their own browser, and a question is about that page unless they say otherwise: "this repo" is the repository page they have open, not a folder on disk. This folder is Browsentic's scratch space and holds no project.
+
+ Reach that page only through the browsentic MCP server — call_mcp_tool with ServerName "browsentic", starting with page_getPageInfo. Never run a command, read or write a file, or open a browser of your own to answer, and never search the web or fetch a URL: none of them sees the user's page. If the browsentic tools cannot be reached at all, say so instead of answering another way.
",
"path": "AGENTS.md",
},
@@ -76,9 +82,11 @@ describe('a streamed run', () => {
expect(stream({ conversation: '../../escape me' }).cwd).toBe(`${stateDir}/agents/antigravity/run/______escape_me`);
});
- // Antigravity takes no per-run tool list; its own settings decide whether it may search.
- test('research changes nothing about the plan', () => {
- expect(stream({ research: true })).toEqual(stream());
+ // Antigravity takes no per-run tool list, so only the prompt keeps it off the web.
+ test('research changes only whether the prompt allows a web search', () => {
+ const prompt = (research: boolean) => stream({ research }).files?.find((file) => file.path === 'AGENTS.md')?.content;
+ expect([prompt(false), prompt(true)].map((text) => text?.includes('never search the web'))).toEqual([true, false]);
+ expect({ ...stream({ research: true }), files: [] }).toEqual({ ...stream(), files: [] });
});
test('the chosen model and effort are passed through', () => {
diff --git a/src/daemon/agent/runners/antigravity.ts b/src/daemon/agent/runners/antigravity.ts
index b8b013f..c15560f 100644
--- a/src/daemon/agent/runners/antigravity.ts
+++ b/src/daemon/agent/runners/antigravity.ts
@@ -33,6 +33,17 @@ interface Settings {
[key: string]: unknown;
}
+/**
+ * Antigravity offers the model its whole built-in toolset — a shell, files, a browser of its own,
+ * web search — and reads AGENTS.md as project notes rather than its instructions. Left unsaid,
+ * "this repo" became `git status` in the scratch folder, and a refused page read became a web search.
+ */
+const wherePageIs = (research: boolean) => `# Where the page is
+
+The user is looking at a page in their own browser, and a question is about that page unless they say otherwise: "this repo" is the repository page they have open, not a folder on disk. This folder is Browsentic's scratch space and holds no project.
+
+Reach that page only through the ${MCP_SERVER_NAME} MCP server — call_mcp_tool with ServerName "${MCP_SERVER_NAME}", starting with page_getPageInfo. Never run a command, read or write a file, or open a browser of your own to answer${research ? '' : ', and never search the web or fetch a URL'}: none of them sees the user's page.${research ? ' Keep web searches to background the page cannot give you.' : ''} If the ${MCP_SERVER_NAME} tools cannot be reached at all, say so instead of answering another way.`;
+
/** Every MCP call, whichever server it reaches; the server and tool are in its parameters. */
const MCP_CALL = 'call_mcp_tool';
@@ -100,7 +111,7 @@ export const antigravityRunner: Runner = {
},
stream(context: StreamContext): Plan {
- const { settings } = context;
+ const { settings, research } = context;
const effort = effortOf(settings, this.efforts);
const base = this.workspace('run');
sweepRunDirs(base);
@@ -112,7 +123,7 @@ export const antigravityRunner: Runner = {
env: { BROWSENTIC_AGENT_RUN: context.runId },
files: [
{ path: MCP_CONFIG, content: mcpConfig(context.mcp) },
- { path: INSTRUCTIONS, content: `${context.systemPrompt.trim()}\n` },
+ { path: INSTRUCTIONS, content: `${context.systemPrompt.trim()}\n\n${wherePageIs(research)}\n` },
],
args: [
'-p',
diff --git a/src/daemon/agent/runners/drive.test.ts b/src/daemon/agent/runners/drive.test.ts
index c59d164..9df6d58 100644
--- a/src/daemon/agent/runners/drive.test.ts
+++ b/src/daemon/agent/runners/drive.test.ts
@@ -108,7 +108,7 @@ describe('a streamed run', () => {
directory: statSync(cwd).mode & 0o777,
instructions: statSync(join(cwd, 'AGENTS.md')).mode & 0o777,
mcpConfig: statSync(join(cwd, '.agents', 'mcp_config.json')).mode & 0o777,
- }).toEqual({ said: 'You are Browsentic.\n', directory: 0o700, instructions: 0o600, mcpConfig: 0o600 });
+ }).toEqual({ said: expect.stringMatching(/^You are Browsentic\.\n/), directory: 0o700, instructions: 0o600, mcpConfig: 0o600 });
});
test("a folder a conversation keeps is new again on every turn, so the sweep ages it from its last", async () => {