Repository navigation
Description
Company or project name
No response
Component
Python SDK
Use case
App builders ask for long-term memory per end user that survives conversations and can be erased on request. sdk/python/examples/agent_memory.py already shows per-user memory for one user (user_id on each call); no example shows two users kept apart, a fact revised, and one user's data erased and checked gone.
Describe the solution you'd like
Goal. sdk/python/examples/support_agent_memory.py, next to agent_memory.py and built on its layout.
Files to start from
sdk/python/examples/agent_memory.py: the layout, the per-calluser_idand the cleanup.docs/reference/operations/erasure.md:erasure.request(scope_type,scope_value,requester) anderasure.status.docs/guides/tokens-and-grants.md: theorg_adminrole.
Acceptance criteria
- Writes facts for two
user_ids; amemory.searchnarrowed to each user returns only that user's facts. - Updates one fact (
memory.update_by_id) and shows the new value. - Erases one throwaway user with
erasure.request(scope_type: "user_id") and pollserasure.statusuntil the saga iscompletedwithresidue_count0; then that user's search returns nothing and the other user's facts are still there. Say beside the call that auser_idscope covers every namespace in the org, so the script must use a user id that exists only in its own run. user_iderasure needs an org admin. On a server with auth on,loom mint-token --rolestakesviewer,writeroradminonly, so the README says how to get a token that may erase (for exampleloom mint-token --platform-admin --subject sa:<name> --org <org> --ttl-days 1on a local server).- Exits 0 only when every check passes.
tests/unit/test_sdk_example_support_agent_memory.py, modelled ontests/unit/test_sdk_example_agent_memory.py: it loads the script by path and runs it against anhttpx.MockTransportserver that answers each op. It checks that the script's cleanup deletes the memories it wrote when a step in the middle fails (for examplememory.update_by_idanswering 422), and that the script exits non-zero when a check fails (the erased user's search still returns a fact) and 0 when every check passes.- Listed in
sdk/python/examples/README.mdwith a real run's output, and under "Examples" in docs/reference/python-sdk.md.
How to test
- Against a local Loom:
python sdk/python/examples/support_agent_memory.py. make format-check lint, the example's unit test, and the docs checks:
.venv/bin/python -m pytest tests/unit/test_sdk_example_support_agent_memory.py -q
.venv/bin/python -m pytest tests/unit/test_doc_links.py tests/unit/test_public_copy.py -q
.venv/bin/python -m scripts.codegen.docs_reference --checkDescribe alternatives you've considered
agent_memory.py covers one user and deletes its memories by key; it does not show isolation between users or erasure.
Where the need comes from
The need is mine, an AI tool helped shape the proposal
Additional context
Start after #696 merges, or rebase onto it: it edits docs/reference/python-sdk.md.
Size: M (a day or two). Read CONTRIBUTING.md first (signed-off commits), and comment here to say you are working on it.
Activity
rahulsjha commentedon Nov 16, 2026
Hi @zlareb1, I'd like to pick this up. Plan: add
sdk/python/examples/support_agent_memory.pyon theagent_memory.pylayout that writes facts for twouser_ids and checks amemory.searchnarrowed to each user returns only that user's facts, revises one withmemory.update_by_id, then erases a run-unique user witherasure.request(scope_type: "user_id", with a note that this scope covers every namespace in the org), pollserasure.statusuntilcompletedwithresidue_count0, and confirms that user's search is empty while the other user's facts remain; it exits 0 only when every check passes.tests/unit/test_sdk_example_support_agent_memory.pyruns it on anhttpx.MockTransportand asserts cleanup whenmemory.update_by_idanswers 422, a non-zero exit when the erased user still has a fact, and 0 on success. The examples README gets a real run and theloom mint-token --platform-adminsteps for a token that may erase, plus the entry in docs/reference/python-sdk.md, rebased onto #696 and with signed-off commits. Could you assign it to me?