Skip to content

Keep observation watermarks advancing beyond the retrieval cap - #462

Closed
rudycelekli wants to merge 1 commit into
google-deepmind:mainfrom
rudycelekli:fix/observation-watermark-full-memory-20261104
Closed

rudycelekli wants to merge 1 commit into
google-deepmind:mainfrom
rudycelekli:fix/observation-watermark-full-memory-20261104

Conversation

@rudycelekli

Copy link
Copy Markdown
Contributor

ObservationsSinceLastPreAct uses the number of retrieved memories as a persistent append-order watermark, but retrieves at most one million entries. Once that limit is reached, the watermark stops growing and later observations are silently omitted from agent context.

Use the existing Memory.get_all_memories_as_text() API to obtain the full committed bank. Preserve the observation filter, ordering, watermark state format and resume behavior; update the documented retrieval assumption accordingly. This retains the existing append-only memory assumption and does not add a streaming retrieval API or repair observations omitted by earlier actions.

Validation: an actual public EntityAgent.act() → observe() → act() regression with one million repeated non-observation filler entries fails before the fix and passes afterward, including once-only delivery. Two further public-agent controls cover multiple observations in order, watermark checkpoint resume and associative memory backed by a local deterministic embedder. All 12 tests pass across the new three-test suite and existing nine-test Publisher/Subscriber suite. Focused pylint/type checks pass; formatting passes for the changed production lines and complete new test file. No provider calls or external model downloads.

AI assistance was used to prepare this fix and its regression tests.

# retrieve_recent returns memories in chronological (append) order;
all_recent = memory.retrieve_recent(limit=1_000_000)
# The full-bank API preserves chronological (append) order.
all_recent = memory.get_all_memories_as_text()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This now materializes the entire memory history on every pre_act, even if only one observation was appended. ListMemory.get_all_memories_as_text() copies all N strings into a tuple; the associative backend builds a full DataFrame/text list, so a long simulation becomes O(N) work/allocation per action (O(N²) over N actions). The old one-million-item cap at least bounded that cost, and this becomes unbounded exactly where the PR fixes the watermark. Could we expose an append count/cursor and fetch only count - last_seen_index recent entries, with a regression for histories beyond the previous cap?

@jzleibo

jzleibo commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator

This only makes a difference past 1,000,000 memories, which does not arise in real Concordia simulations, and the test allocates a 1M-entry list. Closing for now, happy to reopen if you have a real use case.

@jzleibo jzleibo closed this Nov 8, 2026
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.

3 participants