{"id":992,"date":"2026-03-03T15:47:00","date_gmt":"2026-03-03T21:47:00","guid":{"rendered":"https:\/\/www.jkspeaks.com\/wordpress\/?p=992"},"modified":"2026-07-04T17:00:45","modified_gmt":"2026-07-04T22:00:45","slug":"control-the-agent-or-it-controls-the-cost","status":"publish","type":"post","link":"https:\/\/www.jkspeaks.com\/wordpress\/consulting\/control-the-agent-or-it-controls-the-cost\/","title":{"rendered":"Control the Agent, or It Controls the Cost"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">I &#8220;almost&#8221; burned 1 million tokens on a single Gmail cleanup. Why? Because I treated my AI agent like a human, not an architect.<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">I recently asked Claude to tidy up my Gmail. The exact task, unsubscribe me from newsletters I hadn\u2019t opened in three months. Simple enough, right?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Except it wasn\u2019t. I quickly realized something was not right and decided to go with my instinct. I labeled a few emails for experimentation (similar to creating a sandbox), and let the agent play to assess the tokens it would burn if the agent actually <em>read<\/em> through my entire inbox.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This experiment turned into a valuable lesson while working with AI agents before handing them real-world tasks.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>The task:<\/strong> Scan all emails under a specific label and unsubscribe from inactive mailing lists.<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">Same goal. Three approaches. Wildly different token costs. Here\u2019s the breakdown of how I turned a 1,000,000+ token task into a ~50,000 token win.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Method 1: The Brute Force<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Letting the agent browse Gmail page by page, reading the DOM (Document Object Model or, in simple terms, every single element) on every screen, opening each email, and clicking \u201cunsubscribe.\u201d<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Estimated token cost: <strong>1 million+ tokens.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is what happens when you say, \u201cgo handle my emails\u201d without thinking. The agent isn\u2019t reading like a human; it\u2019s processing <em>everything.<\/em><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Method 2: The Filtered Flow<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Gmail has powerful search operators. Instead of brute-forcing, you can guide the agent directly. For example, I gave the agent specific parameters:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>is:unread before:2025\/11\/22 category:promotions<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now, instead of 10,000 emails, the agent deals with a few hundred. It opens only the relevant ones and uses Gmail\u2019s built\u2011in unsubscribe feature.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Estimated token cost: <strong>200,000\u2013400,000 tokens.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Just pausing to design the right entry point made this 5x more efficient. Using the tool\u2019s native features is the first step to efficiency.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Method 3: The Architect\u2019s Approach. Separate Analysis From Action<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Export Gmail via Google Takeout (MBOX file) and hand that to Claude Code or another AI coding assistant.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The agent wrote a Python script to parses all 10,000 emails <strong>locally<\/strong>, consuming zero browser interaction, zero tokens. It generated a clean list of unsubscribe URLs. The agent only touched the browser to click the final links.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Estimated token cost: <strong>50,000\u2013100,000 tokens.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s nearly <strong>100\u00d7 cheaper<\/strong> than the brute force method.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">The Real Lesson Isn\u2019t About Gmail<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">It\u2019s about <strong>how<\/strong> you engage with AI agents on any complex workflow.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">AI agents are literal. They will take the most expensive path if you don&#8217;t build the map.<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">Most people jump straight into Method 1. It feels natural: &#8220;I\u2019ll describe the task, and the AI will handle it.&#8221; But AI agents follow instructions literally, even when that means working inefficiently.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Before starting any agentic task, ask yourself:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>What is the agent actually doing at each step?<\/strong> Every DOM read, every API call, every query costs tokens. Visibility into the process helps you design smarter flows.<\/li>\n\n\n\n<li><strong>Can I split the task? i.e., analysis first, action second?<\/strong> Combining \u201cthink\u201d and \u201cdo\u201d in the same session almost always burns through tokens. Separate them. Similar to using the &#8220;Plan&#8221; option some tools provide.<\/li>\n\n\n\n<li><strong>Is there a better entry point?<\/strong> Search parameters, exports, APIs, or CLI tools often trim work by an order of magnitude <em>before<\/em> the agent even starts.<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">AI agents are incredibly capable, but they\u2019re not automatically efficient. Efficiency depends on <em>your<\/em> workflow design.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Ask for a plan, request clarifications, and treat token usage like a metric worth optimizing.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Think. Plan. Then act.<\/strong> Your token budget will thank you.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Have you ever had an agent run away with your API budget? What\u2019s your &#8216;Architect&#8217; move for saving tokens? Let\u2019s swap strategies in the comments.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In my next post, I\u2019ll cover how picking the right <strong>model<\/strong> for the task can make (or break) your token efficiency. That experiment was\u2026 eye-opening!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">#AI #Agents #Architecture #Cost #Claude<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I &#8220;almost&#8221; burned 1 million tokens on a single Gmail cleanup. Why? Because I treated my AI agent like a human, not an architect. I recently asked Claude to tidy up my Gmail. The exact task, unsubscribe me from newsletters I hadn\u2019t opened in three months. Simple enough, right? Except it wasn\u2019t. I quickly realized&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":"","_links_to":"","_links_to_target":""},"categories":[4],"tags":[182,123,187,179,183,78],"class_list":["post-992","post","type-post","status-publish","format-standard","hentry","category-consulting","tag-agentic","tag-ai","tag-architecture","tag-claude","tag-cost","tag-strategy"],"acf":{"phase":"3","cluster":"Technical","topics":["AI Engineering","Claude","Ops"]},"_links":{"self":[{"href":"https:\/\/www.jkspeaks.com\/wordpress\/wp-json\/wp\/v2\/posts\/992","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jkspeaks.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jkspeaks.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jkspeaks.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jkspeaks.com\/wordpress\/wp-json\/wp\/v2\/comments?post=992"}],"version-history":[{"count":2,"href":"https:\/\/www.jkspeaks.com\/wordpress\/wp-json\/wp\/v2\/posts\/992\/revisions"}],"predecessor-version":[{"id":1108,"href":"https:\/\/www.jkspeaks.com\/wordpress\/wp-json\/wp\/v2\/posts\/992\/revisions\/1108"}],"wp:attachment":[{"href":"https:\/\/www.jkspeaks.com\/wordpress\/wp-json\/wp\/v2\/media?parent=992"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jkspeaks.com\/wordpress\/wp-json\/wp\/v2\/categories?post=992"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jkspeaks.com\/wordpress\/wp-json\/wp\/v2\/tags?post=992"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}