Pasting a single large file can consume 20% of an AI agent's context window
A developer measured the token cost of pasting common files into an AI agent's context window, using the tiktoken tokenizer with GPT-4o encoding. A 2,348-line Swift source file consumed 40,324 tokens — roughly one-fifth of a 200,000-token window — while the file path to the same file cost just 19 tokens. Terminal logs, despite being frequently pasted during debugging, tokenize inefficiently due to hashes, timestamps, and long numbers. Pasting just four large files can push earlier instructions out of the agent's effective memory, causing it to forget project constraints or repeat already-completed steps. The author concluded that sharing file paths and letting the agent retrieve only what it needs is far more context-efficient than direct pasting.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in