updating episodic memory prompts#11
Merged
aayush3011 merged 3 commits intoMay 7, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the toolkit’s episodic-memory extraction contract to support “scoped” episodic memories (via scope_type / scope_value), and modernizes the read-side filtering APIs to support multi-type retrieval via memory_types=[...]. It also changes get_user_summary() to read a single deterministic document (or return None) instead of querying and returning a list, with corresponding test/sample/doc updates.
Changes:
- Update episodic extraction prompt + pipeline handling to require
scope_type/scope_valueand allow episodic memories without the situation/action/outcome triple. - Add multi-type filtering support (
IN (...)) via a new query builder helper and propagate it throughget_memories,get_thread,search_cosmos, andget_local. - Switch
get_user_summary()toread_itemwith deterministic id/PK and update tests + samples accordingly.
Reviewed changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
tests/unit/test_query_builder.py |
Adds unit tests for new add_in_filter() behavior. |
tests/unit/test_pipeline_confidence.py |
Expands tests for scoped episodic extraction + content fallback behavior. |
tests/unit/test_memory_type_multi.py |
New tests ensuring memory_types flows into generated Cosmos SQL (IN clause). |
tests/unit/test_cosmos_memory_client.py |
Updates sync client tests for memory_types and single-doc get_user_summary(). |
tests/unit/aio/test_cosmos_memory_client.py |
Updates async client tests for single-doc get_user_summary(). |
tests/integration/test_processor_integration.py |
Updates integration assertions to use memory_types. |
tests/integration/test_processor_integration_async.py |
Updates async integration assertions to use memory_types. |
tests/integration/test_full_pipeline.py |
Updates integration tests to use memory_types and new get_user_summary() return shape. |
Samples/scenario_rag_with_memory.py |
Updates sample to handle singular user summary doc shape. |
Samples/scenario_memory_reconciliation.py |
Updates sample retrieval calls to memory_types. |
Samples/scenario_customer_support.py |
Updates sample retrieval calls and user summary access. |
Samples/processing_user_profile.py |
Updates user summary readback to handle Optional[dict]. |
Samples/processing_thread_summary.py |
Updates summary retrieval to memory_types=["summary"]. |
Samples/processing_fact_extraction.py |
Updates per-type retrieval to memory_types=[kind]. |
Samples/Demo.ipynb |
Updates notebook cells for get_local / get_memories / get_user_summary shape changes. |
Samples/Demo_function_app.ipynb |
Updates notebook text/cells to use memory_types in retrieval examples. |
Samples/Demo_function_app_async.ipynb |
Updates async notebook retrieval examples to memory_types. |
Samples/Demo_async.ipynb |
Updates async notebook retrieval examples and user summary access. |
Samples/advanced_memory_lifecycle.py |
Updates archive loop to use memory_types=["turn"]. |
README.md |
Updates retrieval example to use memory_types=["fact"]. |
function_app/triggers/change_feed.py |
Minor simplification of should_reconcile assignment. |
Docs/local_testing.md |
Updates example to use memory_types=["summary"]. |
Docs/design_patterns.md |
Updates documentation examples to use memory_types. |
Docs/azure_testing.md |
Updates documentation examples to use memory_types. |
agent_memory_toolkit/prompts/extract_memories.prompty |
Revises episodic prompt section for scoped episodic memories + updated schema. |
agent_memory_toolkit/pipeline.py |
Implements scoped episodic validation + deterministic content fallback chain. |
agent_memory_toolkit/cosmos_memory_client.py |
Introduces memory_types read filters, IN-clause usage, and single-doc get_user_summary(). |
agent_memory_toolkit/aio/cosmos_memory_client.py |
Async parity for memory_types filters and single-doc get_user_summary(). |
agent_memory_toolkit/_utils.py |
Updates _build_memory_query_builder() to apply multi-type IN filter. |
agent_memory_toolkit/_query_builder.py |
Adds add_in_filter() helper to generate parameterized IN (...) clauses. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "lesson": "transferable takeaway or null", | ||
| "domain": "topic area", | ||
| "scope_type": "trip|project|event|session|release|campaign|... (free-form, required, non-empty)", | ||
| "scope_value": "specific instance, e.g. Paris 2025 (required, non-empty)", |
| @@ -1239,10 +1242,6 @@ def search_cosmos( | |||
| 3. Optionally filters by the remaining keyword parameters. | |||
| 4. Returns up to *top_k* results ordered by similarity. | |||
|
|
|||
Comment on lines
183
to
187
| summaries = mem.get_user_summary(user_id=user_id) | ||
| if summaries: | ||
| print(f" Found {len(summaries)} summary document(s):") | ||
| for s in summaries: | ||
| print(f" • {s.get('content', '')[:120]}") | ||
| print(" Found user summary:") | ||
| print(f" • {summaries.get('content', '')[:120]}") | ||
| else: |
Comment on lines
201
to
206
| Filter at retrieval time: | ||
|
|
||
| ```python | ||
| results = memory.search_cosmos("user preferences", user_id="u1", min_confidence=0.7) | ||
| high_conf_facts = memory.get_memories(user_id="u1", memory_type="fact", min_confidence=0.7) | ||
| high_conf_facts = memory.get_memories(user_id="u1", memory_types=["fact"], min_confidence=0.7) | ||
| ``` |
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.
No description provided.