How to Write an AI Agent: Lessons Learnt<br>PlatformOverviewThe platform at a glanceBrowsers as a ServiceManaged headless browsers at scaleAPIsBrowser tasks over simple HTTPMCP ServerBrowser automation over MCPSelf-HostedRun on your own infrastructure
SolutionsFor Web ScrapingExtract data without getting blockedFor AutomationAutomate any browser workflowFor TestingHeadless tests and Lighthouse auditsFor AI AgentsGive agents a real browserFor Screenshots & PDFsPixel-perfect captures and documentsFor EnterpriseSLAs, compliance, security & support
ResourcesCustomersWho builds on BrowserlessBlogScraping, automation & AI guidesTrust CenterSecurity, privacy & complianceAboutThe team behind Browserless
PricingDocsLog In
Contact UsSign Up
LoginSign Up<br>Contact Us<br>PlatformOverviewBrowsers as a ServiceAPIsMCP ServerSelf-Hosted
SolutionsFor Web ScrapingFor AutomationFor TestingFor AI AgentsFor Screenshots & PDFsFor Enterprise
ResourcesCustomersBlogTrust CenterAbout
PricingDocsLog In<br>Lessons Learnt From Writing an AI Agent<br>Andy Martínez<br>Senior Software Engineer · June 17, 2026
TL;DR
Don't host the agent, use it as a service
Tokens matter, don't rely only on vision
Stick to mature technologies
A stubborn LLM is the one!
At Browserless, we've spent the last few months building our own agentic browsing experience. We've all started being more LLM-friendly, letting LLMs discover our routes and consume our REST APIs easily. So it seemed like a no-brainer to write our own MCP server that LLMs could consume.
Then we realized we could build an autonomous agent with what we already had.
The road's been hard, there's no denying that. Every other day, HackerNews gets a meltdown over the new CLI tool that, this time for "real", will make browsing fully autonomous, or the new Python wrapper that makes round trips to an Anthropic agent that will revolutionize autonomous browsing.
We get it, the situation is very nebulous, and everyone has their own solution. But some things that we learnt during the process of building our agent seem to almost be cardinal rules that (if not already in place) will be crucially valued a year from now, when the LLM space is much different (just like it was last year).
1. Hostability is key
If you are going to take something from this blog post, please let it be this. Hostability is key. AI, and agentic browsing in particular, seems to be forgetting how the last two decades of DevEx have evolved into a Thing-as-a-service philosophy.
Let me put it this way: unless you have an extremely specific reason, nobody builds their bare metal servers from scratch, and Amazon, Google, DO, Microsoft, and many other cloud providers are a fundamental part of the whole internet infrastructure.
Unless you have an extremely good reason not to, you do CI paying GitHub, BitBucket, or a cloud provider to host Gitea for you. Team chat and sync? You pay for Slack or Teams. Internal documentation and ticket tracking? Same story.
This is not bad on its own. It actually allows teams to be more productive and deliver products with much higher quality. And it's something that AI, and autonomous agents in particular, will eventually be offered as a "plug and play" feature. You can already see Anthropic/OpenAI/Google providing managed agents on their own infrastructure, which you consume and pay as a service. Agentic browsing will also be plug and play . In the same way CodeRabbit or Devin is "plugged" to your CI config, agentic browsing through MCP will be offered as a plug-and-play feature.
At Browserless, we kind of made a bet on this approach.
Currently, these agentic browser tools (your Browser-harness, your Vercel agent-browser CLI) are a program you host and execute. You need at least four pieces to run it:
The browser harness repo
A runtime environment
A file system to read and write skills
An LLM
Of course, when you download these repos to your local machine, you can use browsers in the cloud, but these tools forget that remote browser ≠ remote infrastructure . That's why Browserless MCP is plug-and-play, and can connect to any MCP-capable LLM, without having to host anything on your end .
2. You will be chasing the token
Another unavoidable question: is this a bubble?
When subsidies end and investors want their money back, will it implode? Will token usage be sustainable? Regardless of the answer, we are progressively suffering a bit every time from paying all those sweet tokens, every time a model gets better and requires more computing power. Which brings me to my second point: every token costs.
It's almost like a tautology, saying that tokens have a value to be paid. But the agentic browsing environment doesn't seem to be concerned with this. Every other week, a new agentic browsing repo comes in claiming to be the most accurate, or the most reliable, or the most stealthy. And strictly speaking, all of these are good. The problem is that all this is done sacrificing token...