Skip to content

feat(memory): add AddEventsToMemory for incremental ingestion#1161

Open
mdabydeen wants to merge 1 commit into
google:mainfrom
mdabydeen:feat/memory-add-events-to-memory
Open

feat(memory): add AddEventsToMemory for incremental ingestion#1161
mdabydeen wants to merge 1 commit into
google:mainfrom
mdabydeen:feat/memory-add-events-to-memory

Conversation

@mdabydeen

@mdabydeen mdabydeen commented Jul 16, 2026

Copy link
Copy Markdown

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 via add_session_to_memory. memory.Service in adk-go has no equivalent — AddSessionToMemory is 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:

  • Add AddEventsToMemory(ctx, *AddEventsToMemoryRequest) error to memory.Service, with fields mirroring Python's kwargs (AppName, UserID, Events, optional SessionID, optional CustomMetadata).
  • Implement in memory/inmemory.go: extracted the event→value conversion (skip events with no text content) into a shared eventToValue helper reused by both AddSessionToMemory and the new method, and dedup incoming events by event.ID against whatever's already stored for that (app, user, session) scope — mirroring in_memory_memory_service.py's dedup behavior, so repeated calls with overlapping events are idempotent.
  • memory/vertexai/vertexai.go returns 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:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Added Test_inMemoryService_AddEventsToMemory covering: events become searchable, repeated calls with overlapping events are deduped by ID, isolation across sessions/users, and that contentless events are ignored (matching existing AddSessionToMemory semantics). Added a standalone unit test asserting the Vertex AI backend's explicit unsupported error.

$ go test -race -mod=readonly -count=1 -shuffle=on ./...
ok  	google.golang.org/adk/v2/memory	...
ok  	google.golang.org/adk/v2/memory/vertexai	...
... (all other packages ok)

go build, go vet, and go mod tidy -diff are all clean.

Manual End-to-End (E2E) Tests:

N/A — internal service API addition, covered by unit tests above.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end. (N/A, see above)
  • Any dependent changes have been merged and published in downstream modules. (N/A)

@google-cla

google-cla Bot commented Jul 16, 2026

Copy link
Copy Markdown

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
mdabydeen force-pushed the feat/memory-add-events-to-memory branch from aba21ad to d87912b Compare July 16, 2026 00:22
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.

memory.Service is missing AddEventsToMemory (incremental ingestion, parity with adk-python)

1 participant