Context Engineering

Context Window Budget

Every model has a finite context window measured in tokens, and treating that space as a budget is essential for effective agent design. You must allocate tokens across system instructions, conversation history, retrieved context, tool definitions, and the model's own reasoning and output, since exceeding the window causes silent truncation or errors while wasting tokens on irrelevant information degrades performance even within the limit. Research on the "lost in the middle" problem shows that models disproportionately attend to information at the beginning and end of the context, making strategic placement of critical information as important as total quantity.