Adding support for Temporal Grounding and searchable summaries#34
Merged
aayush3011 merged 3 commits intoJul 23, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR expands the Cosmos-backed memory system to support semantically searchable summaries and improves fact extraction guidance around event-time vs processing-time temporal grounding.
Changes:
- Add
search_summariesto sync + asyncMemoryStoreand expose it via both Cosmos memory clients. - Make the summaries container carry vector + full-text indexing policies so summaries can be queried via semantic search.
- Update
extract_memories.promptyto v3 with stronger temporal grounding and attribution rules; update tests accordingly.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/test_cosmos_memory_client.py | Updates expectations for summaries container policies; adds sync tests for summaries inclusion and ordering. |
| tests/unit/store/test_memory_store.py | Adds unit coverage for MemoryStore.search_summaries query shape and validation. |
| tests/unit/services/test_prompty_loader.py | Bumps expected extract_memories.prompty version to v3. |
| tests/unit/aio/test_cosmos_memory_client.py | Adds async tests for including summaries and ordering with turns. |
| azure/cosmos/agent_memory/store/memory_store.py | Implements sync MemoryStore.search_summaries using shared search helpers. |
| azure/cosmos/agent_memory/prompts/extract_memories.prompty | Updates extraction prompt to v3 with event-time grounding and richer formatting rules/examples. |
| azure/cosmos/agent_memory/cosmos_memory_client.py | Adds summaries indexing policies on container creation; adds include_summaries blending and search_summaries API. |
| azure/cosmos/agent_memory/aio/store/memory_store.py | Implements async search_summaries. |
| azure/cosmos/agent_memory/aio/cosmos_memory_client.py | Adds summaries indexing policies on container creation; adds async include_summaries blending and search_summaries API. |
| azure/cosmos/agent_memory/_utils.py | Simplifies ISO parsing in normalize_created_at_iso. |
Comments suppressed due to low confidence (1)
azure/cosmos/agent_memory/cosmos_memory_client.py:742
- This warning message says "returning memories only", but the function no longer returns early on turn-search failure and may still return summaries (and always returns whatever memory hits were found). Update the log message to match the behavior.
except Exception as exc: # noqa: BLE001
logger.warning("search_cosmos: include_turns turn search failed (%s); returning memories only", exc)
turns = []
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Two improvements:
search_cosmosadditions are opt-in; the prompt change is behind a version bump (v3) and takes effect on re-memorize.
Changes
Searchable summaries
Previously the summaries container had no vector index, so generated
thread_summary/user_summarydocs were not reachable by search.(keeping the existing
(user_id, thread_id, version)composite for pointlookups).
search_summaries(query, user_id, thread_id=None)(sync + async, store +client) vector-searches across all of a user's summary docs at once - the
single
user_summaryand every per-threadthread_summary- so a holistic,session-scoped, or topic-scoped summary question all resolve with one query.
search_cosmos(..., include_summaries=True, summary_top_k=...)blends matchingsummaries into results (best-effort). With
include_turnsalso on, the resultorder is facts → summaries → raw turns, so summaries/turns never jump the
relevance-ranked facts or evict them under context truncation.
Extraction prompt (v2 → v3)
one (the user if named, and always third parties) instead of collapsing
everyone into "the user" - essential for multi-speaker transcripts so two
speakers don't blur into one.
processing-time guard, so relative expressions ("3 weeks ago") resolve only
against the turn's timestamp, never against the current clock; plus
relative→absolute (never absolute→vague) and preserve exact durations/counts.
Datadog" ≠ "uses Datadog").
document/spec/dataset, not "the user shared a doc".
cover every distinct topic - without the volume quotas that would inflate count.
Minor
created_atnormalization drops a redundantZ→offset replace(
datetime.fromisoformatparsesZnatively on the supported Python range).Tests
Store + client coverage for
search_summariesscoping,include_summariesblending + facts→summaries→turns ordering, the summaries container vector policy,
and the prompt version bump. Full unit suite green; ruff clean.
Benchmark Results
Beam 1M
LongMemEval
LoCoMo