Controlling Read and Write to Memory
You can use the memory_access_policy metadata parameter to control a conversation's read from and write to memory.
Allowed values for the
memory_access_policy metadata parameter are:recall_and_store: enable both store and recall (default)recall_only: this conversation can recall memory but can't store new memory-
store_only: this conversation can store memory but can't recall memory -
none: neither store nor recall
Example code:
# first conversation
conversation1 = client.conversations.create(
metadata={
"memory_subject_id": "user_123456",
"memory_access_policy": "store_only",
},
)
# a turn on first conversation, this conversation can store memory, but cannot recall memory
response = client.responses.create(
model="openai.gpt-4.1",
input="I like Fish. I don't like Shrimp.",
conversation=conversation1.id
)
print(response.output_text)
# delay for long-term memory processing
time.sleep(10)
# second conversation, this conversation can recall memory, but cannot store new memory
conversation2 = client.conversations.create(
metadata={
"memory_subject_id": "user_123456"
"memory_access_policy": "recall_only",
},
)
# a turn on second conversation
response = client.responses.create(
model="openai.gpt-4.1",
input="What do I like",
conversation=conversation2.id
)
print(response.output_text)