to2d

A space for ideas, notes, and ongoing work.

Multi-Context Browser Control

Dec 2025

BrowserAgent Update

Custom tools can now spawn isolated browser pages within a shared session context.

New properties on ToolExecutionContext:

  • browserContext — direct access to Playwright BrowserContext
  • createPage() — creates pages with anti-detection scripts applied

Pages inherit session state (cookies, localStorage, proxy config) and are tracked for automatic cleanup on errors.

async call(params, ctx?: ToolExecutionContext) {
  const page = await ctx.createPage();
  try {
    await page.goto(url);
    // ... operations without affecting main page
    return { output: 'Success' };
  } finally {
    await page.close();
  }
}

This enables:

  • Email activation links without losing form state
  • Cross-domain data lookups mid-workflow
  • Parallel page operations
  • Sub-agent delegation to isolated pages

For the complete architectural analysis, implementation patterns, and diagrams:

Multi-Context Browser Control for Agentic Systems →
← Back to Open Source