Context Windows and Conversation Memory
Context is a request budget
A context window limits the sequence a model can process under a particular deployment configuration. Inputs include instructions, message history, tool descriptions, tool results, and retrieved evidence. Depending on the system, output or other reserved tokens also consume the effective budget. Verify the chosen endpoint's accounting.
For an illustrative 8,000-token total budget, reserve 1,000 for output and 500 as a safety margin. If instructions use 700, conversation uses 2,000, and tool schemas use 800, only 8000-1000-500-700-2000-800 = 3000 remain for retrieved evidence.
More context does not guarantee better use
Relevant evidence can be buried among distracting passages. Contradictory policy versions create ambiguity. Long inputs cost more to process and can make diagnosis harder. Measure answer quality as input grows instead of treating the largest possible request as optimal.
flowchart LR A[Full conversation] --> B[Keep recent turns] A --> C[Summarize older turns] D[Authorized persistent facts] --> E[Context builder] B --> E C --> E F[Retrieved evidence] --> E E --> G[Budget and priority checks] G --> H[Model request]
Memory is an application feature
A model does not automatically remember previous API calls. Applications typically resend selected history or maintain state through a supported service. Distinguish conversation state from training weights and from a retrieval index.
Three common strategies are a sliding window of recent messages, summaries of older interactions, and retrieval of relevant past facts. Summaries can omit or distort details. Persist only appropriate, consented information and retain provenance. A user preference should not overwrite an access-control policy.
A practical context-priority rule
Preserve essential instructions and the current request. Include minimal authorized facts required for the answer. Trim redundant history before discarding decisive evidence. If an important contract cannot fit, split the task or ask a narrower question.
Treat numbers in this lesson as a hypothetical budget. Real model context limits, tokenizer behavior, and output allowances differ.
Checkpoint with answers
Can deleting earlier turns change the answer? Yes. It changes the information and instructions available to the model.
Does summarizing history preserve every detail? No. Validate critical identifiers and decisions against durable records.
Exercise: A tool returns a 20,000-token log for a 4,000-token request budget. What should happen? Answer: filter or summarize relevant sections with provenance, narrow the query, or use a staged workflow; do not silently chop an arbitrary suffix and assume the evidence survived.