feat(memory): add AddEventsToMemory for incremental ingestion#1161
Open
mdabydeen wants to merge 1 commit into
Open
feat(memory): add AddEventsToMemory for incremental ingestion#1161mdabydeen wants to merge 1 commit into
mdabydeen wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Adds Service.AddEventsToMemory to let callers persist a subset of events (e.g. the latest turn) instead of re-ingesting a whole session via AddSessionToMemory, matching adk-python's BaseMemoryService.add_events_to_memory. InMemoryService dedups incoming events by ID against what's already stored for the (app, user, session) scope, mirroring in_memory_memory_service.py. The Vertex AI Memory Bank service returns an explicit unsupported error for now; porting the real ingestion call is a separate, larger effort. Fixes google#1160 Author: Mike Dabydeen <mdabydeen@gmail.com>
mdabydeen
force-pushed
the
feat/memory-add-events-to-memory
branch
from
July 16, 2026 00:22
aba21ad to
d87912b
Compare
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.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
2. Problem / Solution:
Problem: adk-python's
BaseMemoryService.add_events_to_memory(*, app_name, user_id, events, session_id=None, custom_metadata=None)lets callers persist a subset of events (e.g. just the latest turn) as an incremental delta, instead of re-ingesting the whole session viaadd_session_to_memory.memory.Servicein adk-go has no equivalent —AddSessionToMemoryis the only ingestion path, and it wholesale-replaces the stored events for a session ID on every call (no per-event dedup at all).Solution:
AddEventsToMemory(ctx, *AddEventsToMemoryRequest) errortomemory.Service, with fields mirroring Python's kwargs (AppName,UserID,Events, optionalSessionID, optionalCustomMetadata).memory/inmemory.go: extracted the event→valueconversion (skip events with no text content) into a sharedeventToValuehelper reused by bothAddSessionToMemoryand the new method, and dedup incoming events byevent.IDagainst whatever's already stored for that(app, user, session)scope — mirroringin_memory_memory_service.py's dedup behavior, so repeated calls with overlapping events are idempotent.memory/vertexai/vertexai.goreturns an explicit "not supported" error for now. adk-python's Vertex AI Memory Bank backend does implement this against the real ingestion API, but porting that is a distinctly larger, separate effort from this interface addition — happy to follow up separately if useful.Testing Plan
Unit Tests:
Added
Test_inMemoryService_AddEventsToMemorycovering: events become searchable, repeated calls with overlapping events are deduped by ID, isolation across sessions/users, and that contentless events are ignored (matching existingAddSessionToMemorysemantics). Added a standalone unit test asserting the Vertex AI backend's explicit unsupported error.go build,go vet, andgo mod tidy -diffare all clean.Manual End-to-End (E2E) Tests:
N/A — internal service API addition, covered by unit tests above.
Checklist