New Tool Radar

AI Concepts

How to Shorten a Prompt by Removing Context the Model Does Not Need

Shorten a prompt by removing context the model does not need, starting with the longest block that the question never uses.

Schematic illustration of shorten a prompt by removing context the model does not need: step one find the unused blocks, step two remove the longest first, step three re-check the answer.

Long prompts cost tokens on every request, and a prompt that carries context the question never uses is paying for nothing. The fix is to find the blocks the question does not need and remove them, longest first, then check that the answer is unchanged. A shorter prompt that gives the same answer is strictly better: cheaper, faster, and less likely to distract the model.

Prerequisites

  • A long prompt with several context blocks.
  • The question the prompt answers.
  • A way to count the prompt’s tokens before and after.

Steps

Step 1: Find the unused blocks

Go through the prompt block by block and ask: does the question need this block to be answered? Mark each block needed or not. A block that no question in the task needs is unneeded context.

Step 2: Remove the longest first

Remove the longest unneeded block first, then the next, until the prompt holds only what the question needs. Removing the longest first gives the biggest saving for the least work.

Step 3: Re-check the answer

Run the shortened prompt on the same question and compare the answer with the original prompt’s answer. If the answer is unchanged, keep the shorter prompt; if it changed, the removed block was needed after all.

Worked example: Harbor Light library catalogue question

The fictional Harbor Light library asks one question about opening hours. Its prompt carries 1,850 tokens, including a 930-token catalogue history the question never uses.

Version Tokens Answer Verdict
Original prompt 1850 Opens 09:00 Saturdays Works, but long
History removed 920 Opens 09:00 Saturdays Same answer, half the tokens

Removing the 930-token history leaves a 920-token prompt, and the answer is unchanged, so the shorter prompt is kept.

Expected result. The shortened prompt gives the same answer as the original, with fewer tokens. UNTESTED: this guide was not run against a live model or API. The worked example below is fictional practice material, and its result is the expected result, not a measured one.

Limits

  • A block that looks unneeded for one question may be needed for another; check each question the prompt serves.
  • Removing context can change the answer in subtle ways; compare the answers, not just the length.
  • This guide does not cover prompt caching, which also reduces the cost of long prompts.

Sources

See all