Skip to content

Refactor memory types, working memory (breaking changes) #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 24, 2025

Conversation

abrookins
Copy link
Contributor

Starting to tease out a set of more useful abstractions now that we're using this with an agent ourselves.

@Copilot Copilot AI review requested due to automatic review settings May 24, 2025 00:02
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the memory subsystem by replacing the old SessionMemory/LongTermMemory abstractions with unified WorkingMemory and MemoryRecord types, and updates all related modules, routes, and tests accordingly.

  • Introduce agent_memory_server/working_memory.py for get/set/delete of session-scoped working memory with TTL and optional summarization.
  • Replace LongTermMemory with MemoryRecord and use ULID everywhere instead of nanoid; update filters and search index to support new fields.
  • Update API endpoints, MCP tools, client library, and tests to adopt the new models and behaviors.

Reviewed Changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
agent_memory_server/working_memory.py New working memory module: JSON (de)serialization, TTL, summarization, promotion
agent_memory_server/models.py Remove SessionMemory/LongTermMemory; add WorkingMemory, MemoryRecord, expanded fields and response/request types
agent_memory_server/utils/redis.py Extended search index schema to tag id and track persisted_at and extracted_from
tests/test_messages.py Tests updated to use WorkingMemory/MemoryRecord and ULID
tests/test_memory_compaction.py Compaction and indexing tests now reference MemoryRecord, use ULID, and correct pipeline usage
Comments suppressed due to low confidence (2)

agent_memory_server/working_memory.py:69

  • In get_working_memory, datetime.fromtimestamp is called without timezone information, yielding a naive datetime. Consider using datetime.fromtimestamp(..., UTC) or datetime.fromtimestamp(...).replace(tzinfo=UTC) so returned WorkingMemory timestamps are timezone-aware.
last_accessed=datetime.fromtimestamp(working_memory_data.get("last_accessed", int(time.time())))

agent_memory_server/working_memory.py:127

  • [nitpick] Using default=str for JSON serialization can produce non-ISO datetime strings, which may not round-trip cleanly. Consider converting timestamps to integers or using datetime.isoformat() explicitly to ensure consistent format.
await redis_client.setex(key, working_memory.ttl_seconds, json.dumps(data, default=str),)

@abrookins abrookins merged commit 50fdd06 into main May 24, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant