Daniel Petro, developer behind the shared chat app HeyAgents, recently detailed a practical optimization strategy for his weekly SEO monitoring automation. Originally, Petro used OpenAIโs Codex to perform manual browser searches on Google and Bing every Monday at 1 p.m. to track organic rankings for heyagents.app and heyagents.io. The process relied on prompt-based instructions, forcing the AI agent to interpret the browser environment from scratch each time, a method Petro described as token-intensive and inefficient for repetitive tasks.
From Prompt to Playbook
To address the inefficiency, Petro tested Oya Browser, an AI-powered tool that recently launched on Product Hunt. He aimed to determine how much of the repetitive browser interaction could be converted into deterministic code. In a baseline test, Petro used Oyaโs 'Ask' panel to search Bing for the term 'HeyAgents app'. The one-off run completed in 51 seconds but consumed 112,800 tokens. While Petro hasn't yet measured the exact token usage of his scheduled Codex job, the high cost of the single query highlighted the need for a more structured approach.
Automating the Repetitive Steps
Petro attempted to save the 'Ask' run as a playbook but encountered errors, noting the system returned 'Nothing to save: run ask() on this browser first.' He then switched to Oyaโs Record tab, capturing the search actions as a playbook. After troubleshooting a stuck page check, he simplified the automation into a single step: navigating to a Bing results URL with a dynamic query input. This deterministic step, generated by Oya as a Playwright module, runs without model calls. The code snippet provided shows a simple page.goto command with a 15-second timeout, using a variable substitution function to inject the search term.
Hybrid Workflow for Future Scales
The new workflow separates deterministic navigation from AI-driven analysis. Petro tested the Oya-generated Playwright script on demand, manually verifying that the search for 'HeyAgents' placed his site second, while 'HeyAgents app' placed it first. For the final production setup, Petro plans to integrate this deterministic navigation into his existing Monday Codex job. The script will return the top organic matches as data, allowing Codex to compare results against previous weeks and decide whether to send an update. This hybrid model ensures the repetitive browser work is handled by code, reserving AI tokens for the high-value analysis and reporting tasks.
Key Takeaways
- Repetitive browser automation consumes significant tokens when handled by LLMs alone; converting these steps to code reduces costs.
- Oya Browser can generate Playwright scripts from recorded actions, though the 'Ask' to 'Playbook' conversion may require manual editing.
- A hybrid approachโusing deterministic code for navigation and AI for analysisโis an effective pattern for scaling agent-based automations.
The Bottom Line
If you're running agents on a schedule, stop paying for AI to figure out how to click the same button every week. Offload the deterministic navigation to code and save your tokens for the actual thinking.