Show HN: Reverse-engineering web apps into agent tools
Transforming Web Applications into Agentic Tools
The current state of AI agents interacting with the web is, frankly, suboptimal. While we have seen a surge in "browser agents," the prevailing methodology relies on simulating a human user—clicking buttons, scrolling through pages, and scraping the DOM. This approach is effective fundamentally flawed.
The Core Problem: The "DOM Trap"
Most agents use tools like Playwright or Puppeteer to "see" a website. However, relying on the Document Object Model (DOM) introduces several critical failure points:
- Fragility: A single CSS class change can break a selector, rendering the agent blind.
- Latency: Loading full HTML pages and executing JavaScript is agonizingly slow.
- Token Bloat: Feeding raw HTML into a Large Language Model (LLM) consumes massive amounts of context window, increasing costs and decreasing reasoning quality.
"The DOM is essentially a lie; it is a presentation layer. The real truth of a web application lives in the network tab."
A Better Way: Reverse-Engineering the API
Instead of pretending to be a human with a mouse, we can treat web applications as what they actually are: front-ends for internal APIs. By reverse-engineering these apps, we can convert a visual interface into a set of structured tools (JSON schemas) that an LLM can call directly.
The Workflow Process
The transition from a website to a tool follows a specific pipeline:
- Observation: The user performs the desired action while a proxy captures all outgoing HTTP requests.
- Extraction: The system identifies the specific API endpoints, headers, and payloads required to complete the task.
- Generalization: An LLM analyzes the captured data to replace specific values (e.g.,
user_id: "12345") with generic parameters (e.g.,user_id: "string"). - Deployment: The resulting schema is plugged into the agent's toolset.
Comparison: Browser-Based vs. API-Based Agents
| Feature | Browser-Based (DOM) | API-Based (Reverse Engineered) |
|---|---|---|
| Execution Speed | Slow (Page Loads) | Fast (Direct HTTP) |
| Reliability | Low (Brittle Selectors) | High (Stable Endpoints) |
| Token Usage | High (HTML dumps) | Low (JSON payloads) |
| Complexity | High (UI Navigation) | Low (Parameter Mapping) |
Technical Implementation
To turn a request into a tool, we map the network traffic to a standard tool definition. For example, a request to fetch a user's profile might be transformed into the following:
{
"name": "get_user_profile",
"description": "Retrieves detailed profile information for a specific user via internal API",
"parameters": {
"type": "object",
"properties": {
"user_id": {
"type": "string",
"description": "The unique identifier of the user"
}
},
"required": ["user_id"]
}
}
The Math of Efficiency
If we define the cost of an operation as a function of the number of tokens and the price per token , the browser-based approach is significantly more expensive:
Since , the API approach reduces operational overhead by orders of magnitude.
Getting Started
If you want to begin converting your favorite web apps into tools, follow these steps:
- Set up a capturing proxy (e.g., Mitmproxy).
- Record a "Golden Path" session of the desired action.
- Feed the request/response pairs into an LLM for schema generation.
- Test the tool via a direct `