Why an AI Agent Can Burn Tens of Thousands of Tokens on a Simple Greeting

    An agent turns a chat turn into equipped reasoning: even a two-word user message can load identity, tools, workspace files, memory, and history into the prompt. This article explains why input tokens dominate the bill, how workspace preload, tool schemas, rolling history, and bloated system prompts drive cost, and how to baseline with a greeting then slim context by route.

    An agent treats a conversation as equipped reasoning. The user may type two words, while the server packs identity, available capabilities, workspace material, memory, and multi-turn traces into context. Input can easily reach ten to twenty thousand tokens while output is only a few dozen. That imbalance is typical in production: the expensive part is not the answer, but the material the model has already read before it speaks.

    Separate the two lines on the bill

    LLM billing usually charges input and output tokens separately, and input often dominates long sessions. A request’s input is typically the sum of:

    • System prompt and role constraints: safety boundaries, output format, business rules.
    • Tool and skill descriptions: names, parameter schemas, and when to use each capability.
    • Retrieved or preloaded material: directories, docs, code snippets, logs, stack traces.
    • Session state: history, tool results, intermediate reasoning summaries.
    • This turn’s user message: the line a person actually typed.

    Output tokens cover only the text the model generates, plus tool-call arguments in some implementations. A short reply to “hello” does not prove the call was cheap. Debug with request-assembly logs, not only the bubbles in the chat UI.

    Task complexity scales cost, but it is not the only cause

    Heavier tasks cost more—that is undisputed. Summarizing a short article is cheaper than reading many sources, cross-checking, and writing a long draft, which needs more retrieval, more tool round-trips, and a longer retained context.

    A common misread is the opposite pattern: the task description is tiny, yet input is already high. Cost then comes from default carried context, not from the task. Using “hello” as a probe is useful: if an empty chat is already expensive, inspect loading policy first, not answer length.

    The workspace is ingested as a bundle

    Many coding agents default to a directory as the work root. When the user says “look at this project,” the implementation may recursively scan source, docs, designs, requirements, run logs, and error stacks, then write snippets or full files into the prompt. Before the model answers, input is already tens of thousands of tokens. The user still feels they wrote one sentence.

    More subtle is implicit prefetch: even if this turn does not ask for code analysis, the agent may attach a tree, key configs, and a recent diff so it can “edit anytime.” Large trees plus generated and dependency directories that were not ignored can raise tokens by an order of magnitude.

    Controls include: default to a directory summary and file list; open single files on demand with line limits; ignore build artifacts, dependency dirs, and huge logs; for oversized files, structured summaries first, then targeted reads by anchors. That is context engineering and does not depend on a vendor-specific API.

    The fixed tax of tool schemas

    Each request usually tells the model which tools it can call. Many tools turn schema (names, parameters, enums, examples) into a stable overhead. With dozens of tools, even “what day is it?” may still send the full catalog.

    Skill packs behave similarly: the more you install, the more the agent tends to browse manuals each turn to decide what applies. Browsing is tokens too. If tool and skill docs are long tutorials instead of short contracts, the tax rises.

    Practical principles:

    1. Mount by scenario, not globally. Chat routes keep almost no tools; coding routes then enable file and terminal capabilities.
    2. Keep schemas short and strict; put long docs behind on-demand retrieval instead of embedding them every turn.
    3. Merge semantically duplicate tools so ten tools do not all do the same I/O.
    4. Delay disclosure for low-value tools: one-line catalog first, full parameter schema only after the model chooses.

    Greeting-class requests then stop paying for unused capabilities.

    Snowballing long sessions

    The longer a session, the more later turns may carry all prior user messages, assistant replies, and tool results. If a tool returns a whole file, page, or log, that payload is billed again and again. Multi-step reasoning, self-critique, and plan–act–verify also write intermediate drafts back into context.

    Common mitigations: sliding windows, staged summaries, and externalizing tool results. Summaries should keep decisions, constraints, and unfinished work, and drop superseded drafts. Large observations go to object storage or a log service; context keeps a pointer and a short conclusion. Fetch fragments by id when needed. History length then tracks task information, not raw bytes.

    System prompts and persona bloat

    To stabilize behavior, teams keep adding rules, examples, bans, and brand tone to the system prompt. Every line is paid every turn. Full-length examples cost more than the rules themselves. Converge the system prompt into a short, stable contract; put volatile policy in retrievable fragments; audit regularly and delete unused, contradictory, or rare-scenario paragraphs.

    Debug order: use “hello” as a baseline

    When input is abnormally high, narrow one variable at a time.

    1. Record a baseline. New empty session, no project directory, minimal system prompt, send a greeting, note input tokens. That is platform and protocol floor noise.
    2. Add only the system prompt and measure again. The delta is persona and rule cost.
    3. Add only tools and skills, no workspace. The delta is schema tax. If this already exceeds ten thousand tokens, slim the tool set first.
    4. Attach the workspace without opening large files. If the tree itself is huge, scan scope or ignore rules are wrong.
    5. Compare with an old session. If empty is fine and old is not, the issue is memory and tool-result replay.
    6. Only then inspect the task: retrieval rounds, retries, and parallel sub-agents each copying a full context.

    Change one variable per step and keep segmented stats: system, tools, files, history, user. Without that, at least print character counts or token estimates per segment at the gateway or agent layer, or you have no handle for optimization.

    Spend tokens where they matter

    Cost control is not turning everything off; it is a thin default path and explicit heavy paths.

    • Layered routing: greetings, Q&A, code edits, and commands use different configs, tool sets, and file permissions.
    • Context budget: set an input cap per request; summarize before continuing instead of silent truncation that makes behavior odd.
    • Externalize results: command output, page bodies, and large files go to logs or object storage; the model sees summaries and locators.
    • Cache reuse: keep prefixes stable for unchanged system prompts and tool schemas on services that support prompt caching; frequent prefix rewrites invalidate the cache.
    • Observability: count tokens by session, tool, and directory; alert on thresholds. Spikes often cluster on a few skills or a class of log replay.

    Illustrative assembly, for matching the bill—not a vendor API:

    1. messages = [
    2. system_contract, # short, stable
    3. tool_catalog_minified, # trimmed by route
    4. workspace_index, # listing, not full text
    5. history_compacted, # summary + last few turns
    6. user_turn # this turn
    7. ]

    If tool_catalog_minified or workspace_index is still huge on a greeting, default policy is not yet split by task.

    Do not confuse this with “the model talks too much”

    Output waste exists: rambling explanations, duplicated code, restating steps. It does not explain tens of thousands of input tokens for a greeting. Compress input structure first, then constrain output (length limits, no pasting files already in context). Both sides of the bill fall together.

    Avoid the opposite extreme: dropping safety constraints, truncating until critical errors vanish, or letting the model edit code with too little information. The goal is that every token serves this turn’s decision, not an absolute minimum.

    Takeaway

    Agent tokens are spent mainly on request assembly, not on the two words “hello.” Workspace prefetch, full tool schemas, skill manuals, snowballing history, and ever-longer system prompts are billed before the model speaks. Baseline with an empty-session greeting, add layers one at a time, then trim tools by route, read files on demand, externalize large results, and compact history. Once cost is visible, complex tasks can still spend what they need—without the default stack quietly burning tens of thousands of tokens.