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): read Antigravity's stream as agy 1.2.11 prints it — its call_mcp_tool calls to Browsentic and the schema and spilled-result files it opens to make them stay off the timeline, each tool of its own closes when it finishes, SUCCESS ends a turn without a notice, and token usage is reported

Shahriar366166e775b2
diff --git a/src/daemon/agent/runners/antigravity.test.ts b/src/daemon/agent/runners/antigravity.test.ts
index dc02323..19f0e40 100644
--- a/src/daemon/agent/runners/antigravity.test.ts
+++ b/src/daemon/agent/runners/antigravity.test.ts
@@ -128,18 +128,57 @@ describe('a one-shot task', () => {
});
describe('reading the stream', () => {
- test('a run establishes the conversation, announces its own tool once, streams the answer and finishes', () => {
- expect(read('run.hand-written.jsonl')).toEqual([
- ['session', '9a1b2c3d-4e5f-4061-8a7b-8c9d0e1f2a3b'],
- ['session', '9a1b2c3d-4e5f-4061-8a7b-8c9d0e1f2a3b'],
- ['tool', expect.any(String), 'search_web'],
- ['text', 'It costs '],
- ['text', '$12 a month.'],
- ['session', '9a1b2c3d-4e5f-4061-8a7b-8c9d0e1f2a3b'],
+ const step = (index: number, state: string, name: string, parameters: object = {}) => ({
+ event: 'step_update',
+ step_update: { step_index: index, state, step_type: 'tool', tool_name: name, tool_info: { name, parameters } },
+ });
+ const withoutSessions = (calls: ReturnType<typeof read>) => calls.filter(([signal]) => signal !== 'session');
+
+ test('a Browsentic call and the schema read before it stay off the timeline, which the daemon draws itself', () => {
+ expect(withoutSessions(read('1.2.11-mcp-call.jsonl'))).toEqual([
+ ['usage', { contextTokens: 14_733, outputTokens: 509 }],
+ ['usage', { contextTokens: 15_127, outputTokens: 760 }],
+ ['text', 'echo: hello'],
+ ['usage', { contextTokens: 15_253, outputTokens: 851 }],
+ ['text', '\n'],
['done', 'end_turn'],
]);
});
+ test('every line carries the conversation', () => {
+ expect(new Set(read('1.2.11-mcp-call.jsonl').filter(([signal]) => signal === 'session').map(([, id]) => id))).toEqual(
+ new Set(['cc91cfe3-dda5-41df-96e3-88d226320b41']),
+ );
+ });
+
+ test('a large result Antigravity spilled to a file is read back without a row', () => {
+ const spilled = '/Users/you/.gemini/antigravity-cli/brain/47835b7b/.system_generated/steps/10/output.txt';
+ expect(readLines(step(12, 'ACTIVE', 'view_file', { AbsolutePath: spilled }), step(12, 'DONE', 'view_file', { AbsolutePath: spilled }))).toEqual([]);
+ });
+
+ test('its own tool gets one row, closed once when it is done', () => {
+ const calls = readLines(step(3, 'ACTIVE', 'search_web'), step(3, 'DONE', 'search_web'), step(3, 'DONE', 'search_web'));
+ expect(calls).toEqual([
+ ['tool', expect.any(String), 'search_web'],
+ ['toolResult', calls[0][1], true],
+ ]);
+ });
+
+ test('a file it reads for the task is shown, and a step that errors closes as failed', () => {
+ const notes = { AbsolutePath: '/Users/you/notes.txt' };
+ expect(readLines(step(4, 'ACTIVE', 'view_file', notes), step(4, 'ERROR', 'view_file', notes))).toEqual([
+ ['tool', expect.any(String), 'view_file'],
+ ['toolResult', expect.any(String), false],
+ ]);
+ });
+
+ test("another server's call is shown under that server's name", () => {
+ expect(readLines(step(6, 'DONE', 'call_mcp_tool', { ServerName: 'github', ToolName: 'list_issues' }))).toEqual([
+ ['tool', expect.any(String), 'github:list_issues'],
+ ['toolResult', expect.any(String), true],
+ ]);
+ });
+
test('an answer that only arrives on the result line is still said', () => {
expect(read('response-only.hand-written.jsonl')).toEqual([
['session', '0f1e2d3c-4b5a-4968-8776-655443322110'],
diff --git a/src/daemon/agent/runners/antigravity.ts b/src/daemon/agent/runners/antigravity.ts
index cb6b504..1a18edc 100644
--- a/src/daemon/agent/runners/antigravity.ts
+++ b/src/daemon/agent/runners/antigravity.ts
@@ -33,6 +33,22 @@ interface Settings {
[key: string]: unknown;
}
+/** Every MCP call, whichever server it reaches; the server and tool are in its parameters. */
+const MCP_CALL = 'call_mcp_tool';
+
+/**
+ * Files Antigravity reads as part of an MCP call rather than for the task: the schema it saved for
+ * each tool, which the model opens before calling it, and a large result it spilled to disk.
+ */
+const CALL_PLUMBING = /\/antigravity-cli\/(mcp\/[^/]+\/[^/]+\.json|brain\/[^/]+\/\.system_generated\/)/;
+
+interface Usage {
+ input_tokens?: number;
+ cache_read_tokens?: number;
+ output_tokens?: number;
+ thinking_tokens?: number;
+}
+
interface StepUpdate {
conversation_id?: string;
step_index?: number;
@@ -40,7 +56,8 @@ interface StepUpdate {
state?: string;
text_delta?: string;
tool_name?: string;
- tool_info?: { name?: string };
+ tool_info?: { name?: string; parameters?: { ServerName?: string; ToolName?: string; AbsolutePath?: string } };
+ usage?: Usage;
}
interface Result {
@@ -110,7 +127,10 @@ export const antigravityRunner: Runner = {
reader(): StreamReader {
let streamed = 0;
- const reported = new Set<string>();
+ let generated = 0;
+ // A step is reported while it runs and again when it finishes: one row, closed once.
+ const rows = new Map<string, string>();
+ const closed = new Set<string>();
return (line, sink) => {
const frame = parseJsonLine<Frame>(line);
@@ -126,18 +146,29 @@ export const antigravityRunner: Runner = {
const step = frame.step_update;
if (!step) return;
if (step.conversation_id) sink.session(step.conversation_id);
+ if (step.usage) {
+ const { input_tokens = 0, cache_read_tokens = 0, output_tokens = 0, thinking_tokens = 0 } = step.usage;
+ generated += output_tokens + thinking_tokens;
+ sink.usage({ contextTokens: input_tokens + cache_read_tokens + output_tokens, outputTokens: generated });
+ }
if (step.text_delta) {
streamed += step.text_delta.length;
return sink.text(step.text_delta);
}
- const tool = step.tool_name ?? step.tool_info?.name;
- if (step.step_type !== 'tool' || !tool || ownTool(tool)) return;
- // A step is reported while it runs and again when it finishes; announce it once.
- const seen = `${step.step_index ?? tool}:${tool}`;
- if (reported.has(seen)) return;
- reported.add(seen);
- sink.tool(randomUUID(), tool);
- return;
+ if (step.step_type !== 'tool') return;
+ const name = shownAs(step);
+ if (!name) return;
+ const key = String(step.step_index ?? name);
+ let id = rows.get(key);
+ if (!id) {
+ id = randomUUID();
+ rows.set(key, id);
+ sink.tool(id, name);
+ }
+ const outcome = outcomeOf(step.state);
+ if (outcome === 'running' || closed.has(key)) return;
+ closed.add(key);
+ return sink.toolResult(id, outcome === 'ok');
}
case 'result': {
@@ -148,7 +179,7 @@ export const antigravityRunner: Runner = {
return sink.fail('AGENT_FAILED', `Antigravity ended the run: ${result.status}`);
}
if (!streamed && result.response) sink.text(result.response);
- return sink.done(result.status && result.status !== 'success' ? result.status : 'end_turn');
+ return sink.done(result.status && !/^success$/i.test(result.status) ? result.status : 'end_turn');
}
default:
@@ -275,7 +306,25 @@ function lastFrame(stdout: string): Frame | null {
return null;
}
-const ownTool = (name: string) => /browsentic|^mcp/i.test(name);
+/**
+ * How a tool step appears on the timeline, or null for one the timeline already shows: a call to
+ * Browsentic's own server, which the daemon draws itself, and the files Antigravity opens to make one.
+ */
+function shownAs(step: StepUpdate): string | null {
+ const name = step.tool_name ?? step.tool_info?.name;
+ const parameters = step.tool_info?.parameters;
+ if (!name) return null;
+ if (name === MCP_CALL) {
+ const server = parameters?.ServerName;
+ if (server === MCP_SERVER_NAME) return null;
+ return server ? `${server}:${parameters?.ToolName ?? name}` : name;
+ }
+ if (parameters?.AbsolutePath && CALL_PLUMBING.test(parameters.AbsolutePath)) return null;
+ return name;
+}
+
+const outcomeOf = (state: string | undefined): 'running' | 'ok' | 'failed' =>
+ /^done$/i.test(state ?? '') ? 'ok' : /error|fail|cancel/i.test(state ?? '') ? 'failed' : 'running';
/** `agy models` prints one `id<TAB>label` line per model, and exits 1 when signed out. */
function listedModels({ stdout, code }: Listing): string[] | null {
diff --git a/src/daemon/agent/runners/drive.ts b/src/daemon/agent/runners/drive.ts
index 663f804..df222f6 100644
--- a/src/daemon/agent/runners/drive.ts
+++ b/src/daemon/agent/runners/drive.ts
@@ -130,6 +130,7 @@ export function runStream(
const sink: StreamSink = {
text: (delta) => delta && say(outbound.push(delta)),
tool: (toolId, name) => emit({ kind: 'tool', toolId, action: name, input: {} }),
+ toolResult: (toolId, ok) => emit({ kind: 'toolResult', toolId, ok, summary: ok ? 'done' : 'failed' }),
session: (id) => {
if (id) sessionId = id;
},
diff --git a/src/daemon/agent/runners/fixtures/antigravity/1.2.11-mcp-call.jsonl b/src/daemon/agent/runners/fixtures/antigravity/1.2.11-mcp-call.jsonl
new file mode 100644
index 0000000..729872c
--- /dev/null
+++ b/src/daemon/agent/runners/fixtures/antigravity/1.2.11-mcp-call.jsonl
@@ -0,0 +1,12 @@
+# Recorded from agy 1.2.11 on 2026-09-26 against a stand-in MCP server named browsentic that offers one tool, page_echo; paths became /Users/you. It reads the tool schema Antigravity wrote for itself, calls the tool through call_mcp_tool, and answers.
+{"event":"init","conversation_id":"cc91cfe3-dda5-41df-96e3-88d226320b41","init":{"model":"gemini-3.6-flash-high","cwd":"/Users/you/.browsentic/agents/antigravity/run/run-1","tools":["ask_custom_permission","ask_permission","ask_question","browser_click_element","browser_drag_pixel_to_pixel","browser_get_dom","browser_get_network_request","browser_input","browser_list_network_requests","browser_mouse_down","browser_mouse_up","browser_move_mouse","browser_press_key","browser_refresh_page","browser_resize_window","browser_scroll","browser_scroll_dom","browser_select_option","browser_subagent","call_mcp_tool","capture_browser_console_logs","capture_browser_screenshot","click_browser_pixel","command_status","define_subagent","delete_knowledge","execute_browser_javascript","find_by_name","finish","generate_image","grep_search","invoke_subagent","list_browser_pages","list_dir","list_permissions","list_resources","manage_inbox","manage_subagents","manage_task","multi_replace_file_content","notebook_edit","notebook_execution","open_browser_url","read_browser_page","read_resource","read_url_content","replace_file_content","run_command","schedule","search_web","sed_file","send_command_input","send_message","view_file","wait","wait_5_seconds","write_to_file"],"permission_mode":"request-review"}}
+{"event":"step_update","step_update":{"conversation_id":"cc91cfe3-dda5-41df-96e3-88d226320b41","step_index":0,"state":"DONE","step_type":"user_input"}}
+{"event":"step_update","step_update":{"conversation_id":"cc91cfe3-dda5-41df-96e3-88d226320b41","step_index":1,"state":"DONE","step_type":"agent_response","duration_seconds":3.127358,"usage":{"input_tokens":6312,"output_tokens":288,"thinking_tokens":221,"cache_read_tokens":8133,"total_tokens":6600}}}
+{"event":"step_update","step_update":{"conversation_id":"cc91cfe3-dda5-41df-96e3-88d226320b41","step_index":2,"state":"ACTIVE","step_type":"tool","tool_name":"view_file","tool_info":{"name":"view_file","parameters":{"AbsolutePath":"/Users/you/.gemini/antigravity-cli/mcp/browsentic/page_echo.json"}}}}
+{"event":"step_update","step_update":{"conversation_id":"cc91cfe3-dda5-41df-96e3-88d226320b41","step_index":2,"state":"DONE","step_type":"tool","tool_name":"view_file","duration_seconds":0.017346,"tool_info":{"name":"view_file","parameters":{"AbsolutePath":"/Users/you/.gemini/antigravity-cli/mcp/browsentic/page_echo.json"},"output":"1 lines, 155 bytes"}}}
+{"event":"step_update","step_update":{"conversation_id":"cc91cfe3-dda5-41df-96e3-88d226320b41","step_index":3,"state":"DONE","step_type":"agent_response","duration_seconds":3.675036,"usage":{"input_tokens":2775,"output_tokens":157,"thinking_tokens":94,"cache_read_tokens":12195,"total_tokens":2932}}}
+{"event":"step_update","step_update":{"conversation_id":"cc91cfe3-dda5-41df-96e3-88d226320b41","step_index":4,"state":"ACTIVE","step_type":"tool","tool_name":"call_mcp_tool","tool_info":{"name":"call_mcp_tool","parameters":{"Arguments":{"text":"hello"},"ServerName":"browsentic","ToolName":"page_echo"}}}}
+{"event":"step_update","step_update":{"conversation_id":"cc91cfe3-dda5-41df-96e3-88d226320b41","step_index":4,"state":"DONE","step_type":"tool","tool_name":"call_mcp_tool","duration_seconds":0.155363,"tool_info":{"name":"call_mcp_tool","parameters":{"Arguments":{"text":"hello"},"ServerName":"browsentic","ToolName":"page_echo"},"output":"echo: hello"}}}
+{"event":"step_update","step_update":{"conversation_id":"cc91cfe3-dda5-41df-96e3-88d226320b41","step_index":5,"state":"ACTIVE","step_type":"agent_response","text_delta":"echo: hello"}}
+{"event":"step_update","step_update":{"conversation_id":"cc91cfe3-dda5-41df-96e3-88d226320b41","step_index":5,"state":"DONE","step_type":"agent_response","text_delta":"\n","duration_seconds":4.515084,"usage":{"input_tokens":15206,"output_tokens":47,"thinking_tokens":44,"cache_read_tokens":0,"total_tokens":15253}}}
+{"event":"result","result":{"conversation_id":"cc91cfe3-dda5-41df-96e3-88d226320b41","status":"SUCCESS","response":"echo: hello\n","duration_seconds":11.44621,"num_turns":1,"usage":{"input_tokens":24293,"output_tokens":492,"thinking_tokens":359,"cache_read_tokens":20328,"total_tokens":24785}}}
diff --git a/src/daemon/agent/runners/fixtures/antigravity/run.hand-written.jsonl b/src/daemon/agent/runners/fixtures/antigravity/run.hand-written.jsonl
deleted file mode 100644
index 2619417..0000000
--- a/src/daemon/agent/runners/fixtures/antigravity/run.hand-written.jsonl
+++ /dev/null
@@ -1,9 +0,0 @@
-# Hand-written from antigravity.ts's reader, not recorded: agy is not installed where this was written. A run that streams its answer, calls one Browsentic tool and one of its own, and reports each step while it runs and again when it finishes.
-{"event":"init","conversation_id":"9a1b2c3d-4e5f-4061-8a7b-8c9d0e1f2a3b"}
-{"event":"step_update","step_update":{"conversation_id":"9a1b2c3d-4e5f-4061-8a7b-8c9d0e1f2a3b","step_index":0,"step_type":"tool","state":"running","tool_name":"browsentic/page_getPageInfo"}}
-{"event":"step_update","step_update":{"step_index":0,"step_type":"tool","state":"done","tool_name":"browsentic/page_getPageInfo"}}
-{"event":"step_update","step_update":{"step_index":1,"step_type":"tool","state":"running","tool_info":{"name":"search_web"}}}
-{"event":"step_update","step_update":{"step_index":1,"step_type":"tool","state":"done","tool_info":{"name":"search_web"}}}
-{"event":"step_update","step_update":{"step_index":2,"step_type":"response","text_delta":"It costs "}}
-{"event":"step_update","step_update":{"step_index":2,"step_type":"response","text_delta":"$12 a month."}}
-{"event":"result","result":{"conversation_id":"9a1b2c3d-4e5f-4061-8a7b-8c9d0e1f2a3b","status":"success","response":"It costs $12 a month."}}
diff --git a/src/daemon/agent/runners/fixtures/support.ts b/src/daemon/agent/runners/fixtures/support.ts
index 297255d..c4bca2b 100644
--- a/src/daemon/agent/runners/fixtures/support.ts
+++ b/src/daemon/agent/runners/fixtures/support.ts
@@ -38,6 +38,7 @@ export function readThrough(runner: Runner, lines: string[], only?: Signal): Cal
const sink: StreamSink = {
text: record('text'),
tool: record('tool'),
+ toolResult: record('toolResult'),
session: record('session'),
usage: record('usage'),
done: record('done'),
diff --git a/src/daemon/agent/runners/types.ts b/src/daemon/agent/runners/types.ts
index 6e3d1d7..1e7e67c 100644
--- a/src/daemon/agent/runners/types.ts
+++ b/src/daemon/agent/runners/types.ts
@@ -53,6 +53,8 @@ export interface StreamSink {
text(delta: string): void;
/** A tool the daemon cannot see itself — web search and the like. MCP calls report themselves. */
tool(toolId: string, name: string): void;
+ /** That tool finished. A CLI that never says so leaves the row open until the turn ends. */
+ toolResult(toolId: string, ok: boolean): void;
session(id: string): void;
/** Token counts this CLI reported, normalized to the shared shape. Optional — not every CLI reports them. */
usage(usage: TokenUsage): void;