Isolate memory by channel/chat to prevent cross-chat leakage#23
Open
lawyered0 wants to merge 2 commits into
Open
Isolate memory by channel/chat to prevent cross-chat leakage#23lawyered0 wants to merge 2 commits into
lawyered0 wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR closes a critical data-isolation issue by scoping agent memory per
channel + chatID.Critical issue addressed
Memory context was previously shared across chats, which allowed data from one conversation to leak into another conversation’s prompt context.
What changed
internal/agent/loop.go:channelandchatIDfor all channels, includingcli.write_memorytool is pointed at the active scoped memory store before tool execution.internal/agent/tools/write_memory.go:SetStore) with synchronization.internal/agent/loop_memory_scope_test.go:internal/agent/loop_processdirect_test.gointernal/agent/loop_remember_test.gointernal/agent/loop_write_memory_test.goValidation
go test ./internal/agent -run "MemoryIsScoped|RemembersToday|ExecutesWriteMemoryToolCall" -count=1go test ./internal/agent/tools -run WriteMemory -count=1go test -race ./internal/agent -run "MemoryIsScoped|RemembersToday|ExecutesWriteMemoryToolCall|ProcessDirectExecutesToolCall" -count=1go test ./...