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): stop an agent whose run its reader has failed, because the process went on spending and acting unwatched
Shahriar0004c7c816cc
diff --git a/src/daemon/agent/runners/drive.test.ts b/src/daemon/agent/runners/drive.test.tsindex baaae97..db233d9 100644--- a/src/daemon/agent/runners/drive.test.ts+++ b/src/daemon/agent/runners/drive.test.ts@@ -119,6 +119,16 @@ describe('a streamed run', () => {});});+ test('a failure the reader reports stops the agent, rather than leaving it running unwatched', async () => {+ const stopped = join(stateDir, 'stopped-after-fail');+ const script =+ `process.on('SIGTERM', () => { require('node:fs').writeFileSync(${JSON.stringify(stopped)}, 'stopped'); process.exit(0); });` ++ `${printing(['fail', 'AGENT_UNSAFE', 'offered the shell'])} setInterval(() => {}, 1000);`;+ const refused = await failure(run(standIn(script)));+ await vi.waitFor(() => expect(existsSync(stopped)).toBe(true));+ expect(refused).toEqual({ code: 'AGENT_UNSAFE', message: 'offered the shell' });+ });+test("an agent that exits early fails with the runner's explanation of what it printed", async () => {expect(await failure(run(standIn(`process.stderr.write('Error: no credentials found\\n'); process.exit(1);`)))).toEqual({code: 'AGENT_FAILED',diff --git a/src/daemon/agent/runners/drive.ts b/src/daemon/agent/runners/drive.tsindex 1ce82a8..e55372d 100644--- a/src/daemon/agent/runners/drive.ts+++ b/src/daemon/agent/runners/drive.ts@@ -36,7 +36,7 @@ export function launch(settings: AgentSettings,plan: Plan,signal: AbortSignal,-): { child: Child; release: () => void } {+): { child: Child; release: () => void; stop: () => void } {const problems = vetPlan(kind, mode, plan, stateDir);if (problems.length) {throw new RunError(@@ -72,7 +72,7 @@ export function launch(};if (signal.aborted) kill();else signal.addEventListener('abort', kill, { once: true });- return { child, release: () => signal.removeEventListener('abort', kill) };+ return { child, release: () => signal.removeEventListener('abort', kill), stop: kill };}function notInstalled(runner: Runner, settings: AgentSettings): RunError {@@ -99,7 +99,7 @@ export function runStream(const label = AGENTS[runner.kind].label;return new Promise<RunOutcome>((resolve, reject) => {- const { child, release } = launch(runner.kind, 'run', context.settings, plan, signal);+ const { child, release, stop } = launch(runner.kind, 'run', context.settings, plan, signal);let sessionId: string | null = null;let settled = false;@@ -130,9 +130,11 @@ export function runStream(flush();resolve({ stopReason, sessionId });}),+ // A run the reader has failed is over, and its process would otherwise go on spending and acting.fail: (code, message) =>settle(() => {flush();+ stop();reject(new RunError(code, message));}),};