What you will be able to do
- Explain why every token in context competes for the model's finite attention, and how low-value tokens dilute focus
- Inventory an agent configuration into standing and accumulating elements and find which one dominates the budget
- Spot redundant standing context across instructions, metadata and examples, and keep one copy
- Match an overconsuming element to its one fix: fewer or staged tools, deduplicated instructions, fewer examples, or cleared history and retrieved content
- Recognise when pruning cannot restore focus and the work needs to be split across agents
Key concept
Attention budget — The model has only so much attention for everything in its context window. Each token draws on that budget, so a token that carries little value for the current task takes focus away from the tokens that do.
1.Every token competes for the same attention
A model does not read its context the way a database reads a table, looking up only the rows it needs. On every call it attends over everything it has been given: the system prompt, every tool definition, every example, the conversation so far, and every retrieved chunk. That attention is finite. When ten thousand tokens of an unused tool catalogue sit beside two hundred tokens of the user's actual question, the question gets a smaller share of the model's focus than it deserves.
This is the attention budget, and it is different from the context window limit. An agent can be far below its token limit and still answer badly, because the relevant material is outnumbered by material that is merely present. Budget pressure also builds on every turn, since an agent loop sends the accumulated context back to the model each time. Databricks describes Genie Code this way: each turn re-sends the whole chat's context, so the twentieth message costs more than the first.
Genie Agents show one platform's response to the same pressure. As a space approaches its token limit, Genie filters context to prioritise what it judges most relevant, and the troubleshooting guide warns that answer quality can drop if something important gets filtered out. The lesson generalises even though the mechanism does not. When low-value context is crowding the window, something valuable loses out, whether a filter drops it or the model's attention simply passes over it.
Checkpoint 1 of 5· Check yourself
An agent uses about 12,000 tokens of a 128,000-token context window. Most of that is a catalogue of tool definitions it rarely calls, alongside a user question of about 200 tokens. Its answers keep drifting off the question. Which change is most likely to bring back its focus?
Every token draws on the same limited attention, so low-value tokens like unused tool schemas take focus away from the question even when the agent is far below its window limit. A bigger window doesn't help, and another instruction only adds tokens. Removing the low-value element is what frees attention.
“Review your instructions and try to focus the agent by removing irrelevant tables or instructions.”Source: docs.databricks.com
2.Inventory the configuration and find the dominant element
Diagnosis starts with an inventory. Split everything that reaches the model into two groups, because they grow differently and need different fixes:
- Standing context is loaded before any work starts and is the same on every call: system prompt instructions, tool definitions, few-shot examples, and table or column metadata.
- Accumulating context grows as the agent works: conversation history, raw tool outputs, and retrieved chunks.
- The task itself is the user's request and whatever the current step needs. Everything else is judged by how much it helps this.
Per-call token counts from MLflow Tracing tell you which group to look at. MLflow records token usage on each LLM span, so you can read input tokens call by call through a trace. Two patterns are worth recognising. If the first call is already heavy, before the agent has done anything, the cost is standing context. In a tool-calling agent the usual culprit is tool definitions, because every schema is loaded whether or not the task needs it (Upfront tool-schema cost explains why). If input tokens climb with each turn, accumulating context is to blame, and stale tool outputs left in history are the first thing to check (Which raw tool outputs can be cleared).
# Print the token usage for each LLM call
print("\n== Detailed usage for each LLM call: ==")
for span in trace.data.spans:
if usage := span.get_attribute("mlflow.chat.tokenUsage"):
print(f"{span.name}:")
print(f" Input tokens: {usage['input_tokens']}")
print(f" Output tokens: {usage['output_tokens']}")
print(f" Total tokens: {usage['total_tokens']}")Span counts show which call is heavy, not which element inside it. To break the cost down by element, you read the configuration itself. The rule for choosing what to cut is to remove or shrink the largest low-value element first, and both words matter. A twelve-thousand-token retrieved contract that contains the answer is large but valuable. Eight thousand tokens of schemas for tools the task never calls are large and nearly worthless. Cut the second.
Standing context. Most of the cost was there before any work happened, and history added only about 1,500 tokens over nine turns. Look at tool definitions, instructions, examples and metadata before touching the history.
Checkpoint 2 of 5· Check yourself
A contract-review agent answers poorly. One LLM call holds a 9,000-token retrieved contract that contains the clause the user is asking about, 8,000 tokens of schemas for 30 tools (the task uses 2 of them), a 1,500-token system prompt and a 200-token question. Which change should come first?
The rule is to cut the largest low-value element first. The contract is large, but it holds the answer, so it is earning its tokens. The unused tool schemas are almost as large and add nearly nothing. Another instruction would only add tokens, and history is not where this cost sits.
“Review your instructions and try to focus the agent by removing irrelevant tables or instructions.”Source: docs.databricks.com
Sources3
3.Redundant standing context: keep one copy
Redundancy is the cheapest cut because it removes tokens without removing information. Standing context accumulates duplication over time. A rule gets written into the system prompt, then repeated in a tool description, then shown again in three examples that all demonstrate the same thing. Each copy costs tokens on every call and teaches the model nothing the first copy did not.
Duplication shows up in three standard places:
- Metadata that restates names. A column called
account_namewith the description "the name of your account" adds tokens and nothing else. Keep descriptions that add meaning, such as units, valid values or business definitions, and drop the ones that repeat the name. - Examples that overlap. Twelve examples of four patterns carry roughly the information of four. Keep one example per distinct pattern, and keep variety rather than count.
- Instructions repeated across layers. If the system prompt and a tool description both state the same rule, keep it where the model needs it at decision time and delete the other copy.
Columns the agent never uses belong to the same family of waste. They are not duplicates, but they take budget without informing the answer. Databricks recommends creating views or hiding columns in a Genie space so the model never sees them.
Checkpoint 3 of 5· Check yourself
You are trimming a Genie space's column metadata to free attention budget without losing information. Which column description should you keep?
Descriptions that only repeat the column name cost tokens on every call and teach the model nothing. The order_total description adds the currency and what the total includes and excludes, which the name alone does not say. So it is earning its tokens.
“avoid duplicating information already conveyed by column names”Source: docs.databricks.com
Sources2
4.Match each overconsuming element to its change
Once you know which element dominates, the fix is close to fixed. Each overconsuming element has one change that targets it, and a change aimed at the wrong element leaves the budget problem in place. A better compaction prompt does nothing for a bloated tool list, and removing tools does nothing for a history full of stale query results.
| Overconsuming element | Typical sign in the configuration | Change most likely to restore focus |
|---|---|---|
| Tool definitions | Heavy first call; dozens of tools, most unused by the task; wrong tool picked | Fewer tools, or staged tool loading |
| Instructions and metadata | The same rule in several places; descriptions that repeat column names | Deduplicate and keep one copy; simplify wording |
| Few-shot examples | Many examples covering the same few patterns | Fewer examples, one per distinct pattern |
| Conversation history and tool outputs | Input tokens climb each turn; old results the task no longer needs | Clear stale history; start a fresh session |
| Retrieved content | Many chunks per query, most irrelevant to it | Retrieve less, or clear chunks once used |
Tools deserve the closest look because their failure is visible. An agent with too many tools to choose from does not only spend tokens. It picks the wrong one, as the BASF Coatings team found when its agents grew. Accumulated history is the other common offender, and the Genie guidance is direct: when responses turn slow or fail, start a new chat rather than adding more instructions to the old one.
Checkpoint 4 of 5· Match them up
Each symptom below points to a different element that is taking too much of an agent's attention budget. Match each symptom to the change that targets that element.
Tap a term, then the definition that fits it.
Each element that takes too much attention has its own fix. Removing tools does nothing for stale history, and a fresh session does nothing for a bloated tool list. A fix aimed at the wrong element leaves the main cost where it was.
“Start a new chat if Genie starts to generate slow or failing responses.”Source: docs.databricks.com
5.When pruning cannot restore focus
Sometimes nothing can be cut without breaking something. A single agent that serves finance, operations and marketing really does need all three tool sets, all three instruction blocks and all three example sets, so every element is high-value for some request and low-value for most others. Pruning stops working at that point, because the problem is no longer waste. It is too many concerns sharing one context.
The change then is structural: give each concern its own agent and its own context, so each one carries only the tools, instructions and examples its domain needs. Recognising that boundaries were drawn too wide is covered in Under-split agent boundaries. What this lesson adds is the trigger. Split when the dominant element is legitimately needed by part of the workload, and prune when it is not.
Checkpoint 5 of 5· Check yourself
One agent handles finance, operations and marketing requests. Its instructions have already been deduplicated, and each domain's tool set, instruction block and example set is used by that domain's requests and ignored by the others. It still loses focus. What is the best next step?
Every element here is needed by some part of the workload, so trimming would remove a capability, and adding an instruction only adds tokens. The problem is too many concerns sharing one context. Giving each domain its own agent and its own context brings back focus.
“If your application spans radically different sub-domains (finance, devops, marketing, etc.), a single agent can become unwieldy or overloaded with functionality requirements.”Source: docs.databricks.com
Sources5
Sources
(5)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“Each turn re-sends the whole chat's context to the model”
↩︎ Every token competes for the same attention“The goal is to keep each chat's context relevant to the task at hand.”
↩︎ Key concept - 2.
“Genie uses context filtering to prioritize the tokens it considers most relevant to a question.”
↩︎ Every token competes for the same attention“quality may be reduced if important context is filtered out”
↩︎ Every token competes for the same attention“avoid duplicating information already conveyed by column names”
↩︎ Redundant standing context: keep one copy“Unnecessary columns in your tables can significantly contribute to token usage.”
↩︎ Redundant standing context: keep one copy“Start a new chat if Genie starts to generate slow or failing responses.”
↩︎ Match each overconsuming element to its change“Review your instructions and try to focus the agent by removing irrelevant tables or instructions.”
↩︎ Exam trap 1“avoid duplicating information already conveyed by column names”
↩︎ Exam trap 2“Start a new chat if Genie starts to generate slow or failing responses.”
↩︎ Exam trap 3“Review your instructions and try to focus the agent by removing irrelevant tables or instructions.”
↩︎ Checkpoint“Review your instructions and try to focus the agent by removing irrelevant tables or instructions.”
↩︎ Checkpoint“Include a diverse range of example SQL queries to cover various types of questions, but remove overlapping or redundant examples.”
↩︎ Prediction - 3.
“The total token usage throughout the trace is available in the token_usage field of the trace info object.”
↩︎ Inventory the configuration and find the dominant element - 4.https://www.databricks.com/blog/multi-agent-supervisor-architecture-orchestrating-enterprise-ai-scaleSecondary source
“an agent can have too many tools at its disposal and make poor decisions about which tool to call next”
↩︎ Match each overconsuming element to its change - 5.
“You still need carefully designed prompts and constraints to keep the agent focused and relevant.”
↩︎ When pruning cannot restore focus“If your application spans radically different sub-domains (finance, devops, marketing, etc.), a single agent can become unwieldy or overloaded with functionality requirements.”
↩︎ When pruning cannot restore focus“If your application spans radically different sub-domains (finance, devops, marketing, etc.), a single agent can become unwieldy or overloaded with functionality requirements.”
↩︎ Exam trap 4