{"id":"context-memory-provenance","name":"Context, retrieval and durable memory","shortName":"Context, retrieval and durable memory","role":"Separate context window, retrieved passages, workflow state, durable user data and model parameters.","description":"The word memory can refer to several objects with different lifetimes. A model context contains the tokens supplied to a particular invocation. Retrieved passages are selected external data with source identities. A workflow journal stores execution events. Durable user or application records can survive sessions, while model parameters change only through an actual training or adaptation process. KV cache is another representation of computation for a particular sequence and model, not a database of verified facts. Confusing these objects leads to claims such as a retrieved note teaching the weights or an old conversation proving that an action committed. Context construction should therefore expose which items are present, omitted or summarized, where they came from, and who is permitted to read them.","mechanism":["The application identifies task instructions, history, retrieved evidence and tool observations separately.","Each included item retains provenance, applicability and access scope before it enters the current context.","The declared tokenizer and context budget determine how much input and reserved output can fit.","Durable records and model weights remain separate from the transient invocation and its KV cache."],"learningObjective":"Classify each retained object by lifetime and reproduce a context budget without confusing tokens, facts, journals and parameters.","engineeringExample":"A synthetic context capacity is 2,048 tokens under one declared tokenizer. System/task text uses 256, conversation history 512, retrieved evidence 640, tool descriptions 128 and reserved output 512: the total is exactly 2,048. Adding a 256-token duplicate passage would exceed the budget unless another item is removed or the reservation changes. Removing that duplicate can restore capacity, but it does not prove that all needed evidence remains. These counts are hypothetical tokenizer counts, not words or a provider’s billing claim.","misconception":"Persisting a conversation or retrieving a fact does not by itself update model weights.","check":{"question":"Which action changes this invocation’s context without necessarily changing its model parameters?","options":["Including a retrieved passage","Changing a training gradient update","Replacing the stored model weights"],"answer":0,"explanation":"Context assembly supplies different inference input; parameter changes require a separate model update."},"checks":[],"prerequisites":["tool-loop","kv-cache"],"related":["tool-loop","evaluation"],"specs":[{"label":"Mechanism boundary","value":"What survives between two model calls?","context":"The example declares one accounting convention and tokenizer. Real services can impose additional or different input/output limits; words are not substituted for tokens."},{"label":"Evidence type","value":"Authored worked example","context":"Worked explanation with a bounded numeric or state example. This lesson does not claim an executing implementation of an external model or platform."}],"interfaces":[{"name":"Declared input and state","direction":"in","signal":"The application identifies task instructions, history, retrieved evidence and tool observations separately."},{"name":"Checked outcome","direction":"out","signal":"Classify each retained object by lifetime and reproduce a context budget without confusing tokens, facts, journals and parameters."}],"tradeoff":"More retained context can preserve useful evidence but increases capacity use and can retain stale, irrelevant or unauthorized data.","whyAI":"Reliable tool loops need explicit context assembly rather than an undifferentiated notion of memory.","sourceIds":["automation-langgraph-persistence","automation-rag"],"sources":[{"title":"LangGraph persistence","url":"https://docs.langchain.com/oss/python/langgraph/persistence"},{"title":"Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks","url":"https://arxiv.org/abs/2005.11401"}],"science":[{"title":"Context, retrieval and durable memory · explicit relationship","equation":"The sum of included input-token counts and reserved output tokens must fit the stated context capacity.","explanation":"A synthetic context capacity is 2,048 tokens under one declared tokenizer. System/task text uses 256, conversation history 512, retrieved evidence 640, tool descriptions 128 and reserved output 512: the total is exactly 2,048. Adding a 256-token duplicate passage would exceed the budget unless another item is removed or the reservation changes. Removing that duplicate can restore capacity, but it does not prove that all needed evidence remains. These counts are hypothetical tokenizer counts, not words or a provider’s billing claim.","assumptions":"The example declares one accounting convention and tokenizer. Real services can impose additional or different input/output limits; words are not substituted for tokens."}],"evidenceNotes":"This is a worked explanation, not an executing external platform, model or robot. The quantities and fixtures are authored. Source scope is recorded in the automation learning review manifest; no source benchmark or private system behavior is claimed. The example declares one accounting convention and tokenizer. Real services can impose additional or different input/output limits; words are not substituted for tokens.","level":"software","branch":"Authority, context and execution boundaries","subbranch":"Context, retrieval and durable memory","scale":"Logical state, task evidence and declared units; no physical assembly scale","kind":"system","workstream":"W11","visualFamily":"software-flow","labId":"library","labScope":"The worked example explains this mechanism. General numerical labs are a reference; they do not execute this lesson’s full mechanism.","history":[],"workedTrace":{"capacity":2048,"components":[256,512,640,128,512],"duplicate":256}}