QuestionQ77

Implement generative AI and agentic solutions

You have a Microsoft Foundry project that contains an agent.

You need to enable long-term memory so that the agent can recall user preferences across separate conversations. Stored memories must be isolated per authenticated user, and the client application must not have to manually generate user IDs.

How should you complete the Python code? Each value may be used once, more than once, or not at all.

Drag & Drop
"session"
"{{$conversationId}}"
"{{$userId}}"
[mem_store_name]
[memory_tool]
MemorySearchTool("support_mem_store")
from azure.ai.projects.models import MemorySearchTool, PromptAgentDefinition
mem_store_name = "agent_mem_store"
memory_tool = MemorySearchTool(
    memory_store_name=mem_store_name,
    scope=,
)
agent_def = PromptAgentDefinition(
    model= "gpt-5.2",
    instructions= "You are a customer support assistant.",
    tools=
)
Explanation

The scope parameter of MemorySearchTool defines the isolation boundary for stored memories. To persist and recall user preferences across separate conversations, the scope must be tied to the user identity rather than the session or conversation. The dynamic token "{{$userId}}" automatically resolves to the authenticated user's ID from the calling context, so memories are isolated per user without requiring the client application to generate or supply user IDs manually. In contrast, "session" or "{{$conversationId}}" scope memories to a single conversation, which would not allow recall across separate conversations. The tools parameter of PromptAgentDefinition must reference the already-configured memory_tool instance (passed as [memory_tool]) so the agent uses the MemorySearchTool object with the correct memory_store_name and scope already set, rather than instantiating a new, differently configured tool.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!