Skip to content
Agent Field Notes
Course contentsExpand a topic to choose a lesson.

SYSTEMATIC LEARNING / FOUR-LEVEL COURSE

Memory scopes and trusted authorization context

Design memory scope, authenticity, permissions and recall order as data contracts, and vector similarity is only responsible for sorting.

Learning objectives: The relevance, life cycle and visibility range of memory are three independent dimensions. Threads or namespaces provide organization, and real authorization is still determined by trusted identities and current resource relationships.

Content checked: 2026-10-03 · Each level has independent explanations, tasks and inspections

Choose a starting point based on your familiarity with this topic. Current level: Foundation · Understand the concepts. After completing the task, continue to the next level. Reading and self-checks alone do not establish mastery.

On this level

Review the prerequisites

Suitable for: Junior/mid-level AI application candidates with Python and backend fundamentals.

Memory scopes and trusted authorization context
The relevance, life cycle and visibility range of memory are three independent dimensions. Threads or namespaces provide organization, and real authorization is still determined by trusted identities and current resource relationships.

How does the mechanism work?

Step-by-step explanation
  1. After the user exits the project, how to deal with the context in the started task?

    After static namespace separation, consider changes in the authorization lifecycle.

  2. Why might namespace prefix matching expand the read range?

    The storage API's matching mechanism may expand candidates and must be separated from authorization.

  3. How to prioritize when organizational rules conflict with personal preferences?

    Multiple authorized scopes can still have conflicting semantic priorities.

Foundation · Understand the concepts

Understand the principle · Authorize before ranking

Objectives of this level: Derive the visible memory set from authenticated tenant/user and current project membership; distinguish relevance, lifetime and authority.

Visual guide · Scope comes from trusted identity

Scope comes from trusted identity

Namespaces organize candidates; current authority decides access. Caches of mixed personal/project/organization bundles must include the trusted user boundary. Select the figure to open it at full size.

Fixed input and trusted context

Use two tenants t1 and t2, users Alice and Bob, and project IDs p1 and p2. At logical server time 100, t1/Alice belongs only to p1; t1/Bob belongs to p1 and p2; t2/Alice belongs to its own p1. Identical user/project names across tenants are intentionally different resources. Authentication supplies (tenant,user); the request supplies only (project_id,query). A model-generated tenant, user or role cannot authenticate a caller.

All following records are active and expire at 200 unless stated otherwise; the final number is an authored relevance score, not authorization:

  1. r1: t1, personal Alice, “prefer English”, score 1.
  2. r2: t1, personal Bob, “prefer Chinese”, score 99.
  3. r3: t1, project p1, “use PostgreSQL”, score 2.
  4. r4: t1, project p2, “private MongoDB design”, score 100.
  5. r5: t2, personal Alice, “t2 private preference”, score 999.
  6. r6: t1, organization t1, “human approval required”, score 3.
  7. r7: t1, project p1, “expired decision”, score 1000, expiry exactly 100.
  8. r8: t1, project p1, “withdrawn decision”, score 999, inactive.
  9. r9: t2, project p1, “t2 same project ID”, score 9998.
  10. r10: t1-admin, personal Alice, “prefix tenant secret”, score 10000.

Derive the result in three steps

First authenticate and check membership for the requested project. Next filter exact tenant, eligible personal/project/org scopes, active state and expires>100. Only then rank the remaining records. For t1/Alice requesting p1, the authorized set is r1/r3/r6 and descending-score order is r6/r3/r1. Higher scores cannot admit Bob’s preference, p2 data, t2 data, an expired or withdrawn record, or t1-admin prefix data. Alice’s request for p2 is denied before memory is returned.

For t1/Bob requesting p1, order is r2/r6/r3. For t2/Alice requesting its p1, order is r9/r5. These are positive controls: an implementation returning nothing everywhere would avoid leakage but fail the task.

Why scope is more than a key

A personal language preference can be reusable across sessions; a project database decision applies only to that authorized project; a current organization approval rule has separate authority. Ranking personal data above a rule does not authorize omitting approval. A thread ID is a locator, not a credential, and knowledge of a record ID cannot bypass its scope. Namespace prefix matching cannot replace exact authorization.

The standard-library experiment in the next layer implements this fixed policy, not real login, vector search or organizational administration. LangGraph persistence separates thread checkpoints and cross-thread stores; the application still supplies its authorization policy.

code example

Shared devices and known thread IDs

After switching from Alice to Bob, the same visible thread ID must be reauthorized. A previous cache entry or client locator cannot authorize Bob to read Alice’s personal memory. Clear private client state and use current server identity at the next read boundary.

Acceptance task for this level

Produce a decision record for all ten inputs under Alice/t1/p1: allow or deny with the responsible boundary. Give the three positive-control result orders and explain why the organization rule cannot be overridden by the highest-ranked preference.

Acceptance self-checks

Reading this browser’s record…

Hide the answer and check your understanding

Why is filtering cross-tenant results after the model has seen them insufficient?

Further explanations and practice

When encountering unfamiliar principles, first read the implementation, continuous questioning and migration cases, and then independently explain the premise and boundaries. Answers and notes are saved to the original account record.

All linked explanations and exercises (1 )

Sources and verification scope

The principles are based on public information; the numbers, cases and tasks are the teaching design of this website. Offline experiments verify the range noted on this page, and the learning effect still needs to be judged through independent tasks and feedback.