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.
TypeScript agentic-browseragentic-browsingagy-cliaiai-agentai-browser-extensionai-toolsbrave-extensionbrowser-agentbrowser-automationbrowser-extensionbrowser-usebrowserskillchrome-extensionclaude-codecodexfirefox-addonmcp-servernanobrowserweb-automation
fix(agents): keep one Antigravity folder per conversation, rewritten every turn, because a resumed agy conversation re-reads the folder it began in and every follow-up turn called the browser with the first turn's run id, which the daemon refused
Shahriar84c9f51a659a
diff --git a/docs/guide/agents.md b/docs/guide/agents.mdindex 0755d47..4ca7617 100644--- a/docs/guide/agents.md+++ b/docs/guide/agents.md@@ -281,6 +281,7 @@ Claude runner's settings.| Mistral Vibe: a follow-up turn says *this agent run is no longer active* | Update Browsentic, then start a new conversation. An older one gave each turn its own folder, and Vibe keeps re-reading the first turn's, so a conversation begun before the update stays broken. || "does not understand the flags Browsentic uses" | The CLI is too old. Update it. || Antigravity answers but never touches the page | Its permission rule was removed. `browsentic agent` reports *needs setup* again. |+| Antigravity: a follow-up turn searches the web, or ends with no answer, instead of reading the page | Update Browsentic, then start a new conversation. An older one gave each turn its own folder, and Antigravity keeps re-reading the first turn's, so every browser call in a later turn was refused as *no longer active*. A conversation begun before the update stays broken. || Grok Build sits silent for minutes, then *xAI did not answer* | The Grok account is rate-limited — a free one usually is. Wait, or upgrade the account. || Cursor CLI: *Authentication required* | The daemon inherits no session. Run `cursor-agent login`, or set `CURSOR_API_KEY`, then retry. || Cursor CLI on Windows | Cursor's sandbox has no Windows backend, so only the deny rules apply there. The browser still works; the machine is less fenced off than on macOS or Linux. |diff --git a/docs/guide/troubleshooting.md b/docs/guide/troubleshooting.mdindex d1f03e7..b247310 100644--- a/docs/guide/troubleshooting.md+++ b/docs/guide/troubleshooting.md@@ -65,6 +65,7 @@ Those three answer most questions. The daemon log also lives at `~/.browsentic/d| The model select says *built-in list*, with a reason | Browsentic could not read that CLI's own model list — usually it is signed out | Sign the CLI in, then **Recheck**; `browsentic agent models <name> --refresh` shows the reason in full || Mistral Vibe fails with *has no API key* | Vibe was never set up, or its key lives only in a shell the daemon was not started from | `vibe --setup`, which stores it in `~/.vibe/.env` || Antigravity answers but never touches the page | Its permission rule was removed | `browsentic agent` — it reports *needs setup* again |+| Antigravity: a follow-up turn searches the web, or ends with no answer, instead of reading the page | An older Browsentic gave each turn its own folder, and Antigravity re-reads the first turn's, so later turns carried a run id that had ended | Update Browsentic, then start a new conversation — one begun before the update stays broken || Codex fails with "not logged in" | The daemon inherits no session | `codex login`, then retry || Codex answers about the page without opening it, or from a web search | Codex defers an MCP server's tools until the model searches for them, so a web search is the tool it can see; an older Browsentic also failed to switch that search off | Update Browsentic; the run now says where its browser tools are and switches web search off || Codex sees only part of a long page | Codex cuts a tool result over 25,000 tokens; an older Browsentic left its 10,000 default in place | Update Browsentic, then ask for less at a time: a smaller `maxPerKind`, or `page_extractText` group by group |diff --git a/src/daemon/agent/runners/antigravity.test.ts b/src/daemon/agent/runners/antigravity.test.tsindex 19f0e40..a29f113 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('antigrconst readLines = (...lines: object[]) => readThrough(antigravityRunner, lines.map((line) => JSON.stringify(line)));describe('a streamed run', () => {- test('a fresh run gets its own directory, with the browser server and the system prompt written into it', () => {+ test("a run is written into its conversation's folder: the browser server and the system prompt", () => {expect(shown(stream())).toMatchInlineSnapshot(`{"args": [@@ -23,7 +23,7 @@ describe('a streamed run', () => {"--print-timeout","60m",],- "cwd": "<state>/agents/antigravity/run/run-1",+ "cwd": "<state>/agents/antigravity/run/conversation-1","env": {"BROWSENTIC_AGENT_RUN": "run-1",},@@ -61,6 +61,21 @@ describe('a streamed run', () => {expect(args.slice(args.indexOf('--conversation'), args.indexOf('--conversation') + 2)).toEqual(['--conversation', 'conv-1']);});+ // agy re-reads a resumed conversation from the folder it began in, so a fresh folder per turn+ // handed the second turn the first turn's run id.+ test('every turn of a conversation rewrites the same folder, with its own run id', () => {+ const [first, second] = [stream(), stream({ runId: 'run-2', sessionId: 'conv-1' })];+ expect([second.cwd, second.env]).toEqual([first.cwd, { BROWSENTIC_AGENT_RUN: 'run-2' }]);+ });++ test('a run with no conversation keeps a folder of its own', () => {+ expect(stream({ conversation: null }).cwd).toBe(`${stateDir}/agents/antigravity/run/run-1`);+ });++ test('a conversation id is spelled so it stays one path segment', () => {+ 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());diff --git a/src/daemon/agent/runners/antigravity.ts b/src/daemon/agent/runners/antigravity.tsindex 1a18edc..b8b013f 100644--- a/src/daemon/agent/runners/antigravity.ts+++ b/src/daemon/agent/runners/antigravity.ts@@ -6,7 +6,7 @@ import type { AgentProblem } from '@/lib/agents/catalog';import { stateDir } from '../../lockfile';import { log } from '../../log';import { MCP_SERVER_NAME } from './claude';-import { effortOf, parseJsonLine, sweepRunDirs } from './util';+import { conversationDir, effortOf, parseJsonLine, sweepRunDirs } from './util';import type { JsonContext, Listing, McpServer, Plan, Runner, RunMode, StreamContext, StreamReader } from './types';/** Antigravity reads MCP servers and instructions from the directory it runs in, not from flags. */@@ -104,8 +104,11 @@ export const antigravityRunner: Runner = {const effort = effortOf(settings, this.efforts);const base = this.workspace('run');sweepRunDirs(base);+ // A resumed conversation is re-read from the folder it began in, whatever folder agy is started+ // in now (measured against 1.2.11) — so a conversation keeps one, and every turn rewrites it.+ // Give a run its own and the second turn calls the browser with the first turn's run id.return {- cwd: join(base, context.runId),+ cwd: conversationDir(base, context.conversation ?? context.runId),env: { BROWSENTIC_AGENT_RUN: context.runId },files: [{ path: MCP_CONFIG, content: mcpConfig(context.mcp) },diff --git a/src/daemon/agent/runners/drive.test.ts b/src/daemon/agent/runners/drive.test.tsindex 90fca47..c59d164 100644--- a/src/daemon/agent/runners/drive.test.ts+++ b/src/daemon/agent/runners/drive.test.ts@@ -34,9 +34,12 @@ const printing = (...lines: unknown[]) =>const node = { bin: process.execPath };-const run = async (runner: Runner, { runId = 'drive-run', signal = new AbortController().signal, bin = node.bin } = {}) => {+const run = async (+ runner: Runner,+ { runId = 'drive-run', conversation = 'conversation-1', signal = new AbortController().signal, bin = node.bin } = {},+) => {const events: RunEvent[] = [];- const outcome = await runStream(runner, streamContext({ bin }, { runId }), signal, (event) => events.push(event));+ const outcome = await runStream(runner, streamContext({ bin }, { runId, conversation }), signal, (event) => events.push(event));return { outcome, events, said: events.flatMap((event) => (event.kind === 'text' ? [event.delta] : [])).join('') };};@@ -96,10 +99,10 @@ describe('a streamed run', () => {expect([said.includes('AbCdEfGhIj'), said.includes('⟦api-key:'), said.endsWith(', as asked.')]).toEqual([false, true, true]);});- test("the plan's files are in the run's own directory before the agent starts, readable only by the user", async () => {+ test("the plan's files are in the run's directory before the agent starts, readable only by the user", async () => {const script = `console.log(JSON.stringify(['text', require('node:fs').readFileSync('AGENTS.md', 'utf8')])); console.log('["done","end_turn"]');`;- const { said } = await run(standIn(script), { runId: 'files-run' });- const cwd = join(antigravityRunner.workspace('run'), 'files-run');+ const { said } = await run(standIn(script), { conversation: 'files-conversation' });+ const cwd = join(antigravityRunner.workspace('run'), 'files-conversation');expect({said,directory: statSync(cwd).mode & 0o777,@@ -109,11 +112,11 @@ describe('a streamed run', () => {});test("a folder a conversation keeps is new again on every turn, so the sweep ages it from its last", async () => {- const cwd = join(antigravityRunner.workspace('run'), 'kept-run');- await run(standIn(printing(['done', 'end_turn'])), { runId: 'kept-run' });+ const cwd = join(antigravityRunner.workspace('run'), 'kept-conversation');+ await run(standIn(printing(['done', 'end_turn'])), { runId: 'kept-1', conversation: 'kept-conversation' });const nearlyADayAgo = new Date(Date.now() - 23 * 60 * 60_000);utimesSync(cwd, nearlyADayAgo, nearlyADayAgo);- await run(standIn(printing(['done', 'end_turn'])), { runId: 'kept-run' });+ await run(standIn(printing(['done', 'end_turn'])), { runId: 'kept-2', conversation: 'kept-conversation' });expect(statSync(cwd).mtimeMs).toBeGreaterThan(Date.now() - 60_000);});