androidengineers.Book a session

Context and memory architecture

Context, retrieval, and memory

articleSelf-paced

Context is the information presented to a model for the current decision. Memory is information retained for later decisions. Storing more conversation does not necessarily improve an agent: old facts can become stale, irrelevant text can crowd out evidence, and data can leak across users if scope is unclear.

Give every item a scope

For a support agent, separate application instructions, current ticket facts, retrieved policy passages, and prior observations. Attach provenance to factual material. A retrieved passage is evidence, not an instruction that can redefine tool permissions.

A memory record might contain:

{"tenant_id":"demo-a","user_id":"user-7","key":"preferred_language","value":"English","updated_at":"2026-09-20"}

The application must enforce ownership and retention. A tenant identifier in model-generated text is not an authorization check. Validate stored values and provide a deletion path. Avoid retaining sensitive information simply because it appeared in a conversation.

Manage a context budget

Reserve space for the current task and response. Retrieve a few relevant passages, bound tool output length, and summarize older observations carefully. Summaries can lose qualifiers, so keep source references for important decisions.

Exercise

Write a context policy for two synthetic users. Specify which fields are transient, which can persist, their expiration rules, and how corrections work.

Check: a user switch cannot expose another user’s context. Updated documents supersede stale facts. Deleting memory removes it from future retrieval, rather than only hiding it in the interface.

YOUR LEARNING JOURNEY

0 of 118 available lessons completed

Progress saved in this browser. No account needed.
Context, retrieval, and memory | Agentic AI | Android Engineers