AI Subroutines: Deterministic Browser Automation with Zero Token Cost

✍️ OpenClawRadar📅 Published: April 19, 2026🔗 Source
AI Subroutines: Deterministic Browser Automation with Zero Token Cost
Ad

What AI Subroutines Do

AI Subroutines record browser tasks once and save them as callable tools that replay at zero token cost, zero LLM inference delay, and with 100% determinism. The generated script executes inside the webpage itself, not through a proxy, headless worker, or out-of-process solution.

Key Architectural Decision

The script executes inside the webpage's execution context, which means all authentication, CSRF tokens, TLS sessions, and signed headers get added to requests automatically. No certificate installation, TLS fingerprint modification, or separate auth stack maintenance is required.

Recording Mechanism

During recording, the extension intercepts network requests using two layers:

  • MAIN-world fetch/XHR patch installed before any page script runs
  • Chrome's webRequest API as a correlated fallback for CORS and service-worker paths

Request bodies including FormData, Blob, and raw bytes are captured, not just JSON.

Network Capture Processing

The system scores and trims approximately 300 requests down to about 5 based on multiple signals:

  • First-party vs. third-party origin (+20 / −15)
  • Known telemetry hosts (Sentry, Segment, Hotjar, RUM): −80
  • Temporal correlation to DOM events (+28 within 800ms, +16 within 2.5s)
  • Method and payload shape (mutating POST/PUT/PATCH/DELETE: +35; GET: +5; with request body: +8)
  • Response quality (2xx: +12; 4xx+: −25; non-empty body: +4)
  • Volatile operation identifiers (−18) for GraphQL queryId, doc_id, operationHash

Volatile GraphQL operation IDs trigger a DOM-only fallback before they break silently on the next run.

Ad

Generated Code Structure

The generated code combines network calls with DOM actions (click, type, find) in the same function via an rtrvr.* helper namespace. The top five ranked requests plus DOM interactions get rendered into a 12,000-character context for the generator.

Usage Pattern

Point an AI agent at a spreadsheet of 500 rows, and with just one LLM call, parameters are assigned and 500 Subroutines are kicked off.

Key Use Cases

  • Record sending an Instagram DM, then have a reusable routine to send DMs at zero token cost
  • Create a routine to get latest products in a site catalog, call it to get thousands of products via direct GraphQL queries
  • Set up a routine to file EHR forms based on parameters, with AI inferring parameters from current page context
  • Reuse routines daily to sync outbound messages on LinkedIn/Slack/Gmail to a CRM using an MCP server

Why This Matters

The fundamental problem with browser agents for repetitive tasks is that going through the inference loop is unnecessary. Recording once and having the LLM generate a script that leverages all possible interaction methods (direct API calls, DOM interactions, third-party tools/APIs/MCP servers) provides deterministic, cost-effective automation.

📖 Read the full source: HN LLM Tools

Ad

👀 See Also

TeamHero v2.6.1: Open-Source Platform for Managing Claude AI Agents
Tools

TeamHero v2.6.1: Open-Source Platform for Managing Claude AI Agents

TeamHero v2.6.1 is a local-first, open-source platform that creates a managed team of Claude agents with features like autopilot mode, subtask nesting, flow views, and persistent memory. The tool runs on Node.js with a vanilla HTML/CSS/JS dashboard and requires no database.

OpenClawRadar
Routerly: Self-Hosted LLM Gateway with Runtime Routing Policies and Budget Control
Tools

Routerly: Self-Hosted LLM Gateway with Runtime Routing Policies and Budget Control

Routerly is a free, open-source, self-hosted LLM gateway that provides runtime model selection based on routing policies like cheapest, fastest, or most capable, along with project-level budget limits with per-token tracking. It's OpenAI-compatible for drop-in use with tools like Cursor, LangChain, and Open WebUI.

OpenClawRadar
Clawpage: A Tool That Converts OpenClaw Conversations to Static Websites
Tools

Clawpage: A Tool That Converts OpenClaw Conversations to Static Websites

A developer created Clawpage, a skill that transforms OpenClaw session history into static web pages to preserve valuable conversations, including the back-and-forth, research, and debugging process. The tool is available on GitHub.

OpenClawRadar
Design Studio Plugin for Claude Code Adds Virtual Design Team with 9 Roles and 16 Commands
Tools

Design Studio Plugin for Claude Code Adds Virtual Design Team with 9 Roles and 16 Commands

A new Claude Code plugin called Design Studio simulates a full design team with 9 specialist roles, 16 slash commands, and 5 agents. It auto-detects tech stacks and includes over 8,000 lines of design knowledge across reference files.

OpenClawRadar