Control the Agent, or It Controls the Cost

I “almost” 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’t opened in three months. Simple enough, right?

Except it wasn’t. 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 read through my entire inbox.

This experiment turned into a valuable lesson while working with AI agents before handing them real-world tasks.

The task: Scan all emails under a specific label and unsubscribe from inactive mailing lists.

Same goal. Three approaches. Wildly different token costs. Here’s the breakdown of how I turned a 1,000,000+ token task into a ~50,000 token win.


Method 1: The Brute Force

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 “unsubscribe.”

Estimated token cost: 1 million+ tokens.

This is what happens when you say, “go handle my emails” without thinking. The agent isn’t reading like a human; it’s processing everything.


Method 2: The Filtered Flow

Gmail has powerful search operators. Instead of brute-forcing, you can guide the agent directly. For example, I gave the agent specific parameters:

is:unread before:2025/11/22 category:promotions

Now, instead of 10,000 emails, the agent deals with a few hundred. It opens only the relevant ones and uses Gmail’s built‑in unsubscribe feature.

Estimated token cost: 200,000–400,000 tokens.

Just pausing to design the right entry point made this 5x more efficient. Using the tool’s native features is the first step to efficiency.


Method 3: The Architect’s Approach. Separate Analysis From Action

Export Gmail via Google Takeout (MBOX file) and hand that to Claude Code or another AI coding assistant.

The agent wrote a Python script to parses all 10,000 emails locally, 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.

Estimated token cost: 50,000–100,000 tokens.

That’s nearly 100× cheaper than the brute force method.


The Real Lesson Isn’t About Gmail

It’s about how you engage with AI agents on any complex workflow.

AI agents are literal. They will take the most expensive path if you don’t build the map.

Most people jump straight into Method 1. It feels natural: “I’ll describe the task, and the AI will handle it.” But AI agents follow instructions literally, even when that means working inefficiently.

Before starting any agentic task, ask yourself:

  1. What is the agent actually doing at each step? Every DOM read, every API call, every query costs tokens. Visibility into the process helps you design smarter flows.
  2. Can I split the task? i.e., analysis first, action second? Combining “think” and “do” in the same session almost always burns through tokens. Separate them. Similar to using the “Plan” option some tools provide.
  3. Is there a better entry point? Search parameters, exports, APIs, or CLI tools often trim work by an order of magnitude before the agent even starts.

AI agents are incredibly capable, but they’re not automatically efficient. Efficiency depends on your workflow design.

Ask for a plan, request clarifications, and treat token usage like a metric worth optimizing.

Think. Plan. Then act. Your token budget will thank you.

Have you ever had an agent run away with your API budget? What’s your ‘Architect’ move for saving tokens? Let’s swap strategies in the comments.


In my next post, I’ll cover how picking the right model for the task can make (or break) your token efficiency. That experiment was… eye-opening!

#AI #Agents #Architecture #Cost #Claude

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.