Skip to content

feat(memory): Add explicit GetMemoryKey method to token and window buffer memory types#1471

Open
mahanadh wants to merge 1 commit into
tmc:mainfrom
mahanadh:tech/add-explicit-wrapper-method
Open

feat(memory): Add explicit GetMemoryKey method to token and window buffer memory types#1471
mahanadh wants to merge 1 commit into
tmc:mainfrom
mahanadh:tech/add-explicit-wrapper-method

Conversation

@mahanadh
Copy link
Copy Markdown

@mahanadh mahanadh commented Feb 4, 2026

Description

This PR adds explicit GetMemoryKey method implementations to ConversationTokenBuffer and ConversationWindowBuffer types in the memory package.

Motivation

Both ConversationTokenBuffer and ConversationWindowBuffer embed ConversationBuffer and implement the schema.Memory interface. While Go's struct embedding forwards method calls to the embedded type, all other Memory interface methods (MemoryVariables, LoadMemoryVariables, SaveContext, Clear) are explicitly implemented with proper documentation comments - except GetMemoryKey.

This inconsistency can lead to:

  • Confusion when browsing the API documentation
  • Missing methods in IDE autocompletion for these specific types
  • Incomplete documentation when viewing the type definition

Changes

  • Added GetMemoryKey method to ConversationTokenBuffer in memory/token_buffer.go
  • Added GetMemoryKey method to ConversationWindowBuffer in memory/window_buffer.go
  • Added unit tests for both methods in their respective test files

Testing

Added unit tests that verify:

  • Default memory key ("history") is returned correctly
  • Custom memory keys set via WithMemoryKey option are returned correctly

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code improvement (non-breaking change that improves code quality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

…ffer and ConversationWindowBuffer

Add explicit GetMemoryKey wrapper methods for API consistency with other
Memory interface methods. While Go's struct embedding would forward these
calls, having explicit methods improves documentation, IDE support, and
maintains consistency with other explicitly wrapped methods like Clear,
MemoryVariables, LoadMemoryVariables, and SaveContext.

Also adds unit tests to verify the GetMemoryKey behavior with both default
and custom memory keys.
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