惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Privacy International News Feed
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Jina AI
Jina AI
T
Tailwind CSS Blog
WordPress大学
WordPress大学
Scott Helme
Scott Helme
C
Cybersecurity and Infrastructure Security Agency CISA
博客园 - Franky
C
CERT Recently Published Vulnerability Notes
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
雷峰网
雷峰网
Schneier on Security
Schneier on Security
博客园 - 聂微东
T
Tor Project blog
Hugging Face - Blog
Hugging Face - Blog
博客园 - 司徒正美
AI
AI
T
Troy Hunt's Blog
Security Latest
Security Latest
T
The Blog of Author Tim Ferriss
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
C
Check Point Blog
T
Threat Research - Cisco Blogs
W
WeLiveSecurity
V
Vulnerabilities – Threatpost
Recorded Future
Recorded Future
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Cisco Talos Blog
Cisco Talos Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Cloudbric
Cloudbric
J
Java Code Geeks
罗磊的独立博客
C
Cyber Attacks, Cyber Crime and Cyber Security
aimingoo的专栏
aimingoo的专栏
L
LangChain Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
P
Privacy & Cybersecurity Law Blog
Google DeepMind News
Google DeepMind News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
L
Lohrmann on Cybersecurity
I
InfoQ
MongoDB | Blog
MongoDB | Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The GitHub Blog
The GitHub Blog
The Hacker News
The Hacker News
H
Help Net Security
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Proofpoint News Feed
N
News and Events Feed by Topic

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
I Had a Working Agent at $3.41 a Run. Here's Where the Money Was Actually Going.
Amit · 2026-06-06 · via DEV Community

Amit

TL;DR

  • Same task, same infrastructure, different harness: cost went from $3.41 to $0.03. Zero model changes.
  • Prompt caching on the inner browser loop (~120 lines of wrapper code): −29% cost. The 8K of repeated system prompt + tools was being billed at full price 59× per run.
  • Convergence rules in the prompt (three sentences): −54% cost on the desktop path, −75% wall time. The default behavior across Opus 4.8 and 4.6 is to keep searching. "After N items, STOP" is the most underrated sentence in production agent prompting.
  • Eliminating the LLM from the browser loop entirely (Playwright instead of browser-use): −99% cost on the browser path. The first two are optimizations within the loop. This one removes the loop.

The previous post argued for the hierarchy: when an agent needs to interact with a UI, pick the cheapest tier that can do the job. Native API first, then connectors, then browser automation, then computer use. The core finding was that implementation choice — not model choice — drives most of the cost.

This post is what happens once you've picked your tier. You're at tier 3 (browser) or tier 4 (computer use) because nothing above it covers your workflow. Now the question is: what does the cheap version of that tier actually look like, versus the demo version that ships out of the box?

I had a working agent — part of the fleet I run for my own daily operations. It found nearby lunch options, validated walking distances, and saved a markdown file. Twenty-three minutes per run. $3.41 per run on Bedrock. Not a bad number for a proof of concept. A bad number if you're running this at any scale: a thousand lookups a month per tenant is $40,800 a year. Same outcome.

The question I sat down with wasn't "is there a cheaper model?" I was using a frontier model deliberately. The question was: where is that $3.41 actually going, and what changes without touching a single line of model API code?

The optimization went further than I expected. The first two changes got cost down to $1.17. A third got it to $0.03. This post is the breakdown.

The runs

Run What changed Wall Cost
Browser path, vanilla AgentCore Browser + browser-use + Strands, no harness tuning 20:11 $3.41
Browser + caching 120-line ChatBedrockConverse subclass injecting Bedrock cachePoint markers 17:48 $2.43 (−29%)
Desktop path, base prompt Swap browser-use for Anthropic computer use on a Linux container 20:30 (timeout) $2.13 (file never saved)
Desktop + convergence prompt Three sentences telling the agent when to stop 5:11 $1.17 (−54% vs base)
Browser, Playwright structured Replace browser-use with a purpose-built Playwright script. Zero LLM calls in the browser loop. 1:09 $0.03 (−99% vs vanilla)

The first four runs used Opus 4.8 as the inner model. The Playwright run used Sonnet 4.6 — the point isn't the model, it's that the model is barely involved. One Haiku call at the end to format results.

Where vanilla browser-use spends $3.41

The browser-use library runs a screenshot-decide-click loop inside one tool call from the outer agent. On the Yelp task, that inner loop made 59 model invocations before returning. CloudWatch's InputTokenCount for the Sonnet 4.5 inner sub-agent: 874,862 tokens in one run.

Per-call input shape:

┌──────────────────────────────────────────────────────────┐
│  Per-call input ≈ 14,800 tokens                          │
│                                                          │
│  ┌────────────────────────────────────────────┐          │
│  │ System prompt (browser-use thinking rules) │ ~5,000   │
│  ├────────────────────────────────────────────┤          │
│  │ Tool definitions (click/type/scroll/...)   │ ~3,000   │
│  ├────────────────────────────────────────────┤  IDENTICAL
│  │                                            │   every  │
│  │  ↑ 8,000 tokens repeat verbatim every turn │   turn   │
│  │                                            │          │
│  ├────────────────────────────────────────────┤          │
│  │ Conversation history (recent screenshots) │ ~5,000   │
│  ├────────────────────────────────────────────┤  varies  │
│  │ Current screenshot                         │ ~1,800   │
│  └────────────────────────────────────────────┘          │
│                                                          │
│  × 59 calls = 874K tokens billed at full price           │
└──────────────────────────────────────────────────────────┘

That ~8K of system+tools is paid at full input price 59 times. More than half the run cost is reprocessing the same instructions. Caching them is the obvious move.

Cache that, save 29%

Bedrock supports prompt caching via cachePoint markers — drop a marker in the request body, and from call 2 onward, content before the marker is served from cache at 10% of the input price. First call writes the cache at 1.25× normal price. Break-even: 2 calls. We were at 60.

browser-use 0.3.x exposes no cache_control configuration. The library sends raw messages to whatever LLM wrapper you give it. So I subclassed the wrapper instead of forking the library:

class CachedChatBedrockConverse(ChatBedrockConverse):
    def _generate(self, messages, ...):
        bedrock_messages, system = _messages_to_bedrock(messages)
        system.append({"cachePoint": {"type": "default"}})  # mark system cacheable
        params = self._converse_params(...)
        if "toolConfig" in params:
            params["toolConfig"]["tools"].append({"cachePoint": {"type": "default"}})
        return self.client.converse(messages=bedrock_messages, system=system, **params)

That's it. About 120 lines once you handle the streaming path and a couple of edge cases. browser-use never knows.

The numbers from the next run:

Vanilla Cached Δ
Sonnet input billed at full price 874,862 535,327 −339K
Sonnet cache reads (10% price) 0 306,176 +306K served from cache
Sonnet cache writes (125% price) 0 5,888 +5.9K written
Sonnet cost $3.32 $2.34 −$0.97
Wall clock 20:11 17:48 −2:23

Faster and cheaper. The cache write penalty (5.9K × 1.25× = trivial) is dwarfed by 306K cache reads at 10% price. The cached prompt also processes faster on Bedrock's side, which is where the wall-clock improvement came from.

This is the kind of optimization that compounds. At a thousand lookups per month per tenant, the difference between cached and uncached is $11,600 per tenant per year. Paid once in 120 lines of Python.

I wrote about prompt caching last March. The general principle is well-known. What's interesting is how rarely it's applied inside agent harnesses — browser-use, Strands' built-in browser tooling, and most reference implementations send identical prompts on every turn and let the bill add up.

The deeper fix: remove the LLM from the loop

Caching saved 29% by making the 59 model calls cheaper. But the question underneath is: why are there 59 model calls?

browser-use runs a screenshot-decide-click loop. Every action — navigate to a URL, click a button, read a result — goes through a model invocation. The LLM is not just reasoning about the task; it's deciding every mechanical step. Most of those 59 calls aren't doing strategic work. They're doing work that code could do deterministically.

For tasks with a stable DOM structure — which describes most of the web — you can replace the entire browser-use loop with a Playwright script: navigate by URL, wait for a selector, extract structured data from DOM elements. Zero LLM calls in the browser loop. One LLM call at the end to rank and format.

The same lunch-finding task, reimplemented this way:

  1. Navigate to google.com/maps/search/Mexican+restaurants+near+525+Market+St+San+Francisco
  2. Wait for result cards to render ([role="article"])
  3. Extract name, rating, review count from DOM selectors — no model, no screenshots
  4. For each candidate, navigate to a walking directions URL (data=!4m2!4m1!3e2 = walking mode), extract duration with a regex scan
  5. Pass the structured JSON to one Haiku call: "pick the best 3, format as markdown"

Result: $0.03. Same output. Same AgentCore Browser infrastructure. The difference is what's driving it.

browser-use (LLM loop) Playwright (code loop)
LLM calls in browser ~60 0
Cost $3.41 $0.03
Wall time 20:11 1:09

The 99% cost reduction isn't from caching or prompting. It's from not calling the model 59 times in the first place.

The tradeoff: Playwright scripts are task-specific. browser-use is general — give it any instruction and it figures out the clicks. If the site changes its DOM, the Playwright script breaks; browser-use adapts. For tasks you run at high volume on predictable sites, Playwright is the right answer. For tasks that require navigating novel UIs or handling sites with anti-bot measures, browser-use (or a vision loop) is still necessary.

Prompt engineering moved the dial more than caching

The desktop path tells a different story. Same Opus 4.8 on the same Bedrock endpoint, but now the model does both the strategic reasoning and the per-pixel clicking — no inner sub-agent. First run, with a base prompt that asked for "3 strong lunch options that meet ALL of these criteria," the agent kept finding candidates indefinitely. Found 4. Found 5. Found 6. Hit the 20-minute harness timeout without ever writing the file. $2.13 spent. Zero output.

Then I added three sentences to the prompt:

"As soon as you have 3 candidates that meet the criteria, STOP SEARCHING. Do not look for better candidates. Three is the target, not the floor. If you cannot find 3 that meet ALL criteria, lower the bar (include 3.9-star options) and note this in the output."

Same model. Same container. Same task. Five minutes and eleven seconds. $1.17. File saved. The agent quoted my rule back in the output: "bar lowered to 3.9 per convergence rules."

That's a 54% cost reduction from words. More than caching gave me. The default behavior across Opus 4.8 and Opus 4.6 is to keep gathering. "After N items, STOP" is the most underrated sentence in production agent prompting. Most builders write the search criteria carefully and forget the stopping criteria entirely.

The pattern works for anything the agent might over-explore: research depth, candidate pools, file searches, retry attempts. A budget the agent knows about converges faster than no budget.

The pattern

Four findings, ranked by impact:

  1. Eliminate the LLM from the browser loop (Playwright): −99% cost. Only viable when the DOM is stable and the task is predictable. Not always possible, but when it is, nothing else comes close.
  2. Convergence rules in the prompt: −54% cost, −75% wall time. Three sentences. Costs nothing. Applies to any agent that searches or gathers — not just browser agents.
  3. Prompt caching on the inner loop: −29% cost, −12% wall time. 120 lines of subclass code. One-time investment. Applies whenever the same context repeats across many model calls.
  4. Tier choice (browser vs desktop): Not a harness optimization, but worth noting — picking the wrong tier and then optimizing it is still losing.

The rankings matter. Most teams apply caching first because it's well-documented and mechanical. Convergence rules are higher leverage and cost nothing. And neither is as impactful as asking whether the model needs to be in the loop at all.

The thing I'm still unsure about

None of the optimizations above (caching, convergence rules, sensible retries) ship as defaults in the major reference implementations.

The fixes themselves are small. What's missing is a shared convention — a set of "production agent defaults" that frameworks could adopt so builders don't have to rediscover them the expensive way every time.

I don't know who is best positioned to define and ship that convention. The first credible party to do so will capture significant mindshare.

So what

If you're shipping on a frontier model, stop optimizing the model first. Optimize the harness.

Work through these in order of impact:

  1. Ask whether the model needs to be in the loop at all. For browser tasks with stable DOM structure, a Playwright script + one formatting call is $0.03. A generic LLM browser agent is $3.41. The gap is structural.
  2. Add convergence rules. Three sentences. The default behavior for current frontier models is to keep gathering. Budget the agent explicitly and it stops.
  3. Cache repeated context. 120 lines of wrapper code delivers 29% on inner loops. Low effort, reliable return.

The harness is where the margin lives — and the harness includes the question of whether you need a model-per-action loop or just a model-at-the-end. Most teams don't ask that question until the bill arrives.

The next post looks at what happens when even a well-tuned single tier isn't enough — and you have to orchestrate across tiers (the hybrid recovery behavior that only appeared in that setup).


Part 2 of the Agent Tooling series.
← Part 1: Cost-justified hierarchy · Part 3: Router or agent? →