Context is the information a large language model (LLM) receives for a particular interaction. Memory can also mean records the application stores for later use, such as a conversation transcript or a progress file. Long-running work depends on keeping those records useful and supplying the relevant parts when the model needs them. Prompt caching addresses a separate concern: reusing the processing of repeated input. See Anthropic's explanations of context engineering and prompt caching.
After a pause, an assistant needs to establish what was requested, what happened and what remains unresolved. A handover helps preserve those distinctions, especially when the conversation or working files have changed.
Context, parameters, records and caching
| Mechanism | What it contributes |
|---|---|
| Model parameters | Learned numerical values supporting the model's general capabilities. |
| Active context | Information supplied for the current model interaction, including relevant instructions, messages and observations. |
| Durable records | Information stored outside the immediate context, such as repository files, transcripts and progress notes. |
| Prompt caching | Reuse of previously processed prompt prefixes when the provider's caching conditions are satisfied. |
An example supplied in a prompt can change a model's response without changing its trained parameters. The original GPT-3 research demonstrated adaptation to tasks through textual instructions and examples without updating those parameters during evaluation. Supplying a repository detail in a conversation therefore does not establish that the model has permanently learned it. See Language Models are Few-Shot Learners.
A saved progress note has a different limitation: it can remain on disk while absent from the model's active context. The application needs a way to retrieve and load the information for it to inform the next response.
Selecting relevant context
The context window is the model's finite capacity for the information supplied to an interaction, measured in tokens, the units into which model input is encoded. Context engineering includes selecting instructions, tool information and retrieved material, then managing them as the conversation grows. Anthropic describes loading information when needed and retaining references to larger external records in Effective context engineering for AI agents.
Consider a hypothetical task in a source-code repository, the project's files and their version history: update a name-formatting function to handle empty input according to the requester's specification, update its tests and add a release note. The function, the code that calls it and relevant test assertions may help establish the required change. An unrelated deployment transcript may offer little help with that decision.
Relevance can change during investigation. An assertion, a test's check that a condition holds, may resolve a narrow ambiguity; inspecting the calling code may reveal a wider dependency. Historical material also needs its original scope. A note about an earlier release does not establish the requirements for the current change.
Capacity alone does not explain how effectively a model uses its input. In Lost in the Middle, Liu and colleagues found that performance often changed when relevant information moved within the supplied context. The finding concerns the models and retrieval tasks they evaluated. See Lost in the Middle.
What prompt caching and session persistence preserve
Prompt caching reuses processing for a matching prompt prefix, the opening portion of a request. This can reduce repeated processing time and cost under the provider's caching rules. The application still needs to supply the task and manage its state; a cache entry does not establish the repository's current contents. See Prompt caching.
Session persistence preserves the recorded conversation. Anthropic's Agent SDK (software development kit) documentation describes sessions containing prompts, responses, tool calls and results, with ways to return to a previous session. It distinguishes that history from filesystem state: resuming a conversation does not automatically restore the files as they existed earlier. See Work with sessions.
For example, a saved transcript might describe an edit that another contributor later changed. It remains a record of the earlier activity. Inspecting the current repository establishes which code exists now.
Compaction and handovers after an interruption
Compaction summarises accumulated conversation material to make room for continued work. A summary can preserve the direction of a task while omitting details. In Anthropic's long-running coding experiments, compaction alone did not resolve incomplete work, undocumented progress or premature completion claims. See Effective harnesses for long-running agents.
Suppose the hypothetical name-formatting change pauses after an edit, with the test outcome unconfirmed and the release note unfinished. A handover could identify the requested behaviour, affected files, completed edits and any available test output. A branch or commit reference can help locate that work. The handover would also need to distinguish a test that completed from one merely planned or started.
Continuation involves reconciling that record with the environment. If someone has since changed the function, earlier conclusions may need reassessment. Recording the model version and the harness version, identifying the software that coordinates model interactions and tools, also helps a later reader establish which system produced the execution record. Version information supports comparison without explaining every difference in behaviour.
Keeping tool output and delegated work usable
Tool responses consume part of the information the application manages. Relevant excerpts and references to complete records can keep an exchange focused while preserving access to further evidence.
A subagent is a separate worker assigned part of a task. Claude Code supports subagents with their own contexts, returning summaries to the coordinating agent. Separate contexts consume their own input and output tokens, and their results need to be integrated. Delegation therefore carries processing and coordination costs alongside the benefit of moving detailed work out of the main context. See Extend Claude Code.
For the hypothetical change, delegated test inspection could help if the findings identify which tests were examined and which questions remain unresolved. The coordinating assistant would still need enough information to relate those findings to the function change and release note.