Trail content
8 minEnglish narration, Portuguese subtitlesPodcast (RSS)
Chapters
  1. 0:00Opening
  2. 0:55The diagnosis
  3. 2:01Why it happens
  4. 3:00What it costs
  5. 4:04A challenge
  6. 4:46The treatment
  7. 6:31When to ignore
  8. 7:30Wrap-up
Transcript

Opening

The company's HR bot started with ten lines. A friendly tone, a couple of rules, and that was it.

Today, its system prompt looks like this. Forty paragraphs, about four thousand tokens. And there are three things worth noticing.

First, the remote work rule appears twice. Once it says three days a week.

And further down, it says two. With different values, and nobody deleted the old one.

Second, the prompt asks for brevity, at the very end of a four thousand token text.

And third, half the content isn't instruction at all. It's knowledge. The vacation policy, the reimbursement policy. In this lesson, you'll learn to recognize this smell, why it grows, what it costs, and how to shrink it without breaking anything.

The diagnosis

That last point is the key to the diagnosis.

An instruction tells the model how to act, in any conversation. Be brief. Never discuss salaries.

Knowledge is the subject of some conversations. The vacation policy only matters when someone asks about vacation. But when knowledge lives in the system prompt, it rides along on every single call. Including the ones that don't need it.

So how do you recognize it? The system prompt is past a few thousand tokens, and it only grows.

Every fixed bug became a new paragraph. Never the removal of an old one.

Some rules contradict each other, and nobody knows which one wins.

Whole blocks of knowledge are pasted in. Policies, catalogs, frequently asked questions.

And nobody on the team can explain what each paragraph does. Changing one line changes answers about topics that have nothing to do with it.

Why it happens

Nobody writes a bloated prompt on purpose. It grows out of reasonable decisions, one at a time. And it grows in a cycle.

A case shows up that the bot handles badly.

The quickest fix, at six in the evening, is adding one more instruction. Do not do this.

The prompt grows, and every new instruction competes with the old ones.

The model follows the existing rules a little less reliably. New bugs appear. And the cycle starts over.

Adding is faster than understanding.

There are no evals. Without a test set, removing a paragraph is scary, because nobody knows what will break.

The prompt is the only place. With no search index and no tools, every piece of information ends up there.

And several people edit it. Each one adds their rule, without reading everyone else's.

What it costs

Now the cost of ignoring it. Let's start with money, using some illustrative numbers. A four thousand token prompt, times twenty thousand messages a day, is eighty million input tokens a day.

At a hypothetical one dollar per million, that's about two thousand four hundred dollars a month, just for the prompt. Before the user has typed a single word.

Then time. Bigger input means slower answers, especially before the first word shows up.

Then quality. Instructions compete for the model's attention. Research has shown that models make worse use of what sits in the middle of a long context. An important rule in paragraph twenty-three of forty tends to be followed less consistently. And rules that contradict each other produce answers nobody can predict.

And team speed. Nobody wants to touch it. Every change becomes a session of manual testing, and hoping.

A challenge

Here's one for you. With that prompt, an employee asks how many remote days they get. Sometimes the bot says three. Sometimes it says two. What's the most likely cause?

The prompt has two contradicting rules, and the model picks one each time. It's not temperature. Even at zero, the contradiction would still be there. And it's not that the model misunderstood. The question is simple. The problem is in what the model receives.

The fix is keeping each rule in exactly one place. Not asking the model to pay more attention.

The treatment

There are three refactorings, depending on what the bloat is made of.

If the prompt handles several topics or tasks, extract subprompt. Each one gets its own call, often behind a router.

If the bloat is style and format rules, replace rules with examples. A few good examples teach more than twenty rules in capital letters.

And if the bloat is content, like policies, catalogs and FAQs, move it out of the prompt. That content goes to an index, and comes in through retrieval only when it's relevant.

Apply all three to the HR bot, and the system prompt shrinks to four lines. Answer from the policy excerpts. If it's not there, say you don't know and point to the HR channel. Never discuss salaries. And answer in at most three sentences.

Notice that be brief became a limit you can check. At most three sentences.

The policies become documents in an index, each with an effective date. The three day rule simply disappears, because only the current version is indexed. And a reimbursement question brings in only the reimbursement excerpt.

But before any of it, build an eval with real questions, and measure the current prompt. That's what gives you the courage to delete paragraphs.

The common mistake here is cutting by gut feeling, on a Saturday, with no eval. A paragraph that looked useless might be the one holding a rare case, like the rule for interns. Cut one block at a time, run the eval, and keep going only if the numbers hold.

When to ignore

And when can you live with it? A prototype. To validate an idea in a week, a big messy prompt can be the fastest path. Just don't take it to production that way.

Low volume, stable content. An internal tool used ten times a day, with a base that barely changes, can live with a big prompt. Turn on caching, and move on.

And a prompt that's long because it holds eight well chosen examples isn't bloated. If accuracy is high and nobody's touched it in months, it's healthy. The smell is growth without criteria, not size.

One last trap. Someone turns on prompt caching, the cost of the eight thousand token prompt drops a lot, and they say the problem is solved. Caching lowers the price of repeated tokens. But the model still reads the whole prompt, on every call, with the same contradictions, and the same competition for attention.

Wrap-up

So here's the idea to take with you. A system prompt should hold how to behave, not everything the bot might ever need to know. Each rule in one place, knowledge in an index, and an eval so you can delete with confidence. A prompt someone can read in two minutes is a prompt your team can change.

In the next lesson, we'll move part of what the prompt asks for out of the text, and into a contract your code can check: structured output. See you there.

SmellBloaters

Prompt Bloat

Prompt Inchado

Prompt Bloat is an AI code smell, a sign of trouble in LLM systems, in the Bloaters group. The system prompt is past 3k tokens and every fixed bug became one more paragraph.

Element
01/37
Level
Beginner
Read
4 min
Updated
On this page 7
  1. 01Signs and symptoms
  2. 02Reasons
  3. 03Cost of ignoring
  4. 04Treatment
  5. 05Payoff
  6. 06When to ignore
  7. 07Is it this smell?
  8. ··Quick answers

Signs and symptoms

The HR bot started with ten lines. Today its system prompt looks like this (anonymized excerpt, trimmed):

You are the Company's HR assistant. Be friendly and objective.
IMPORTANT: never discuss other people's salaries.
About vacation: employees are entitled to 30 days... [4 paragraphs]
ATTENTION: if asked about remote work, the rule is 3 days per week.
About reimbursement: up to $40 without a receipt... [3 paragraphs]
New rule (Mar/26): remote work is now 2 days per week.
If the employee is an intern, ignore the vacation section and...
[31 more paragraphs]
DO NOT forget: be brief.

Notice three things. The remote work rule appears twice, with different values. The prompt asks for brevity at the end of a 4,000-token text. And half the content is knowledge (the policy), not instruction (how to behave).

That last distinction is the key to the diagnosis. An instruction tells the model how to act in any conversation. Knowledge is the subject of some conversations. When knowledge lives in the system prompt, it rides along on every call, including the ones that do not need it.

Signs of Prompt Bloat:

  • The system prompt is past a few thousand tokens and only grows.
  • Every fixed bug became a new paragraph, never the removal of an old one.
  • Some rules contradict each other, and nobody knows which one wins.
  • Whole blocks of knowledge are pasted in (policies, catalogs, FAQs).
  • Nobody on the team can explain what each paragraph does.
  • Changing one line changes answers about unrelated topics.
flowchart LR
  B(["1. Bug in production"]):::io --> P["2. One more paragraph"]:::tool
  P --> G[("3. Bigger prompt")]:::store
  G --> C(["4. More confused model"]):::llm
  C --> B
  1. A case shows up that the bot handles badly.
  2. The quickest fix is adding an instruction.
  3. The prompt grows, and every new instruction competes with the old ones.
  4. The model follows existing rules less reliably, and new bugs appear. The cycle starts over.
Check +20 XP on first tryWith the HR bot's prompt above, an employee asks how many remote days they get. The bot sometimes says 3, sometimes 2. What is the most likely cause?

Reasons

Nobody writes a bloated prompt on purpose. It grows out of reasonable decisions, one at a time:

  • Adding is faster than understanding. Facing a bug at 6 p.m., writing “DO NOT do X” fixes the case at hand.
  • There is no eval. Without a test set, removing a paragraph is scary, because nobody knows what will break.
  • The prompt is the only place. With no other home for knowledge (a search index, a tool), every piece of information ends up there.
  • Several people edit it. Each one adds their rule without reading everyone else’s.
  • Prompt caching makes it cheap. With caching, a big prompt costs a lot less, and the incentive to trim disappears. But caching makes tokens cheaper, not the model less confused.

Cost of ignoring

  • Money. The system prompt goes into every call. Run the math with illustrative numbers: a 4,000-token prompt times 20,000 messages a day is 80 million input tokens daily, before the user types a word. At a hypothetical US$1 per million, that is US$80 a day, or about US$2,400 a month, just for the prompt.
  • Time. Bigger input means slower answers, especially to the first token.
  • Quality. Instructions compete for attention. The “Lost in the Middle” paper (Liu et al., 2023) showed that models make worse use of information placed in the middle of long contexts. An important rule in paragraph 23 of 40 tends to be followed less consistently, and contradicting rules produce unpredictable answers.
  • Team speed. Nobody wants to touch it. Every change becomes a session of manual testing and hoping.

Treatment

Refactoring Choose it when
Extract Subprompt The prompt handles several topics or tasks. Each gets its own call, often behind Routing.
Replace Rules with Examples The bloat is style and format rules. A few good examples teach more than twenty rules in caps.
Move Retrieval Out of the Prompt The bloat is content: policies, catalogs, FAQs. That content moves to an index and enters through RAG only when relevant.

Before any of them, build an eval with real questions. It is what gives you the courage to delete paragraphs: see Add Eval Before Changing the Prompt. If the bloat is mostly all-caps rules, read Rule Stacking too.

What the HR bot becomes

Applying the three refactorings to the excerpt at the top, the system prompt shrinks to something like this:

You are the Company's HR assistant. Answer based on the policy excerpts
in <policy>. If the answer is not there, say you do not know and point
to the HR channel. Never discuss other people's salaries.
Answer in at most 3 sentences.

The vacation, reimbursement, and remote work policies become documents in an index, each with an effective date. The 3-day rule disappears, because only the current version is indexed. A reimbursement question brings in only the reimbursement excerpt. And “be brief” became a checkable limit (“at most 3 sentences”).

A common mistake at this point is cutting paragraphs by gut feeling, on a Saturday, with no eval. A paragraph that looked useless may be the one holding a rare case, like the intern rule. Cut one block at a time, run the eval, and continue only if the numbers hold.

Check +20 XP on first tryYou are about to trim a 5,000-token prompt. It mixes tone instructions, the store's entire return policy, and 15 all-caps rules. What is the first step?

Payoff

  • A short system prompt that a person can read in two minutes.
  • Each rule in exactly one place, with no contradictions.
  • Knowledge kept current in the index, without editing the prompt.
  • Lower cost and latency on every call.
  • Changes measured by an eval instead of tested by hand.

When to ignore

  • Prototype. To validate an idea in a week, a big messy prompt can be the fastest path. Just do not take it to production that way.
  • Low volume and stable content. An internal tool used ten times a day, with a base that fits in the context and barely changes, can live with a big prompt. Use prompt caching and move on. The RAG for Small Data smell shows the other side: sometimes pasting everything into the context is the right call.
  • Size that comes from well-chosen examples. A prompt that is long because it holds quality examples is not bloated. The problem is growth without criteria, not size.

Is it this smell?

Check +20 XP on first tryYour prompt is 6,000 tokens, almost all of it the store's price table and shipping rules. Someone in sales updates it every week. Is it Prompt Bloat?

Check +20 XP on first tryThe prompt is 1,500 tokens: a task description and eight well-chosen input and output examples. Accuracy is high and nobody has touched it in months. Is it Prompt Bloat?

Check +20 XP on first tryEvery time the bot gets something wrong, someone adds a line with ‘IMPORTANT’ or ‘NEVER’. The prompt is still short, but it already has 12 of those lines. What is the most precise diagnosis?

Check +20 XP on first tryYour team turned on prompt caching, and the cost of the 8,000-token system prompt dropped a lot. Someone says that settles the bloat problem. What does that conclusion miss?

Quick answers

What is Prompt Bloat?

Prompt Bloat is an AI code smell, a sign of trouble in LLM systems, in the Bloaters group. The system prompt is past 3k tokens and every fixed bug became one more paragraph.

How do you fix Prompt Bloat?

With Extract Subprompt, Replace Rules with Examples, and Move Retrieval Out of the Prompt. Each refactoring has safe step-by-step mechanics with an eval before and after.

Where does Prompt Bloat show up in practice?

In the real-world scenarios Automated PR reviewer, Internal knowledge base chat, and Educational tutor.

Go further

Relations

Part of the tracks 1
Search