Skip to content

Commit 30ea09e

Browse files
committed
Fix ClientMemoryRecord import - use agent_memory_client.models
ClientMemoryRecord, WorkingMemory, MemoryMessage, and UserId are not exported from agent_memory_client.__init__.py, they must be imported from agent_memory_client.models instead. Fixed in: - agent.py - tools.py - section-3-memory/02_long_term_memory.ipynb This should fix the ImportError in CI.
1 parent 0f19481 commit 30ea09e

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

python-recipes/context-engineering/notebooks/section-3-memory/02_long_term_memory.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@
104104
"import os\n",
105105
"import asyncio\n",
106106
"from datetime import datetime\n",
107-
"from agent_memory_client import MemoryAPIClient as MemoryClient, MemoryClientConfig, ClientMemoryRecord\n",
107+
"from agent_memory_client import MemoryAPIClient as MemoryClient, MemoryClientConfig\n",
108+
"from agent_memory_client.models import ClientMemoryRecord\n",
108109
"\n",
109110
"# Initialize memory client\n",
110111
"student_id = \"student_123\"\n",

python-recipes/context-engineering/reference-agent/redis_context_course/agent.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ async def _save_working_memory(self, state: AgentState) -> AgentState:
226226
# Save to working memory
227227
# The Agent Memory Server will automatically extract important memories
228228
# to long-term storage based on its configured extraction strategy
229-
from agent_memory_client import WorkingMemory, MemoryMessage
229+
from agent_memory_client.models import WorkingMemory, MemoryMessage
230230

231231
# Convert messages to MemoryMessage format
232232
memory_messages = [MemoryMessage(**msg) for msg in messages]
@@ -363,7 +363,7 @@ async def _store_memory_tool(
363363
memory_type: Type of memory - "semantic" for facts/preferences, "episodic" for events
364364
topics: Related topics for filtering (e.g., ["preferences", "courses"])
365365
"""
366-
from agent_memory_client import ClientMemoryRecord
366+
from agent_memory_client.models import ClientMemoryRecord
367367

368368
memory = ClientMemoryRecord(
369369
text=text,
@@ -388,7 +388,7 @@ async def _search_memories_tool(
388388
query: Search query (e.g., "student preferences")
389389
limit: Maximum number of results to return
390390
"""
391-
from agent_memory_client import UserId
391+
from agent_memory_client.models import UserId
392392

393393
results = await self.memory_client.search_long_term_memory(
394394
text=query,

python-recipes/context-engineering/reference-agent/redis_context_course/tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ async def store_memory(text: str, memory_type: str = "semantic", topics: List[st
213213
- text="Student completed CS101 with grade A", memory_type="episodic", topics=["courses", "grades"]
214214
"""
215215
try:
216-
from agent_memory_client import ClientMemoryRecord
216+
from agent_memory_client.models import ClientMemoryRecord
217217

218218
# Note: user_id should be passed from the calling context
219219
# For now, we'll let the client use its default namespace

0 commit comments

Comments
 (0)