Adding conflict resolution#10
Merged
aayush3011 merged 7 commits intoMay 7, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces memory reconciliation: a new pipeline step that consolidates paraphrased duplicate facts and resolves semantic contradictions in a single LLM pass, with additional metadata to preserve an audit trail. It also adds a write-time exact-dedup short-circuit using a normalized/truncated content_hash, and updates processors, orchestrators, docs, and tests to use the new reconciliation flow.
Changes:
- Replace the previous fact-dedup flow with
ProcessingPipeline.reconcile_memories(...)and client-facingCosmosMemoryClient.reconcile(...). - Add
content_hashnormalization/truncation + exact-dedup skipping during extraction. - Extend supersession metadata with
supersede_reason+superseded_atand update prompts/docs/tests accordingly.
Reviewed changes
Copilot reviewed 36 out of 36 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/test_utils.py | Updates compute_content_hash expectations (32-char truncated hash, case-insensitive normalization). |
| tests/unit/test_reconcile.py | Adds comprehensive unit tests for reconciliation, hashing/normalization, and extraction short-circuit behaviors. |
| tests/unit/test_process_now.py | Updates process_now tests to call reconcile_memories instead of dedup. |
| tests/unit/test_pipeline_confidence.py | Removes legacy dedup-merge confidence tests; updates _mark_superseded calls to require reason. |
| tests/unit/test_models.py | Adds tests for new supersede_reason and superseded_at fields on MemoryRecord. |
| tests/unit/test_auto_trigger.py | Updates auto-trigger tests to use reconciliation step. |
| tests/unit/processors/test_protocol_satisfaction.py | Updates protocol satisfaction for sync processors to process_reconcile(n=...). |
| tests/unit/processors/test_inprocess.py | Updates in-process processor tests for reconciliation ordering/count reporting. |
| tests/unit/processors/test_durable.py | Updates durable processor tests for renamed reconciliation counters. |
| tests/unit/processors/test_base.py | Updates base ProcessThreadResult defaults to use reconciled_count. |
| tests/unit/function_app/test_orchestrators.py | Updates orchestrator tests to call the reconcile activity and expect new stats shape. |
| tests/unit/aio/test_process_now.py | Updates async process_now tests to use reconciliation. |
| tests/unit/aio/processors/test_protocol_satisfaction.py | Updates async processor protocol satisfaction to process_reconcile(n=...). |
| tests/unit/aio/processors/test_inprocess.py | Updates async in-process processor tests for reconciliation ordering/count. |
| tests/unit/aio/processors/test_durable.py | Updates async durable processor tests for renamed reconciliation counters. |
| tests/integration/test_processor_integration.py | Updates integration coverage for sync processors to use reconciliation. |
| tests/integration/test_processor_integration_async.py | Updates integration coverage for async processors to use reconciliation. |
| tests/integration/test_full_pipeline.py | Updates full-pipeline integration tests to call reconcile() and adds contradiction/hash metadata validations. |
| Samples/scenario_memory_reconciliation.py | Adds a new runnable scenario demonstrating reconciliation + audit trail behavior. |
| Samples/Demo.ipynb | Updates demo narrative to reference reconcile() instead of deduplicate_facts(). |
| README.md | Documents reconciliation semantics, cost controls, and new metadata fields/env vars. |
| function_app/orchestrators/extract_memories.py | Renames Durable Functions activity to em_ReconcileMemories and passes DEDUP_POOL_SIZE. |
| Docs/concepts.md | Adds a new “Memory Reconciliation” concept section (duplicates + contradictions + exact-dedup hash). |
| agent_memory_toolkit/thresholds.py | Adds DEDUP_POOL_SIZE config and get_dedup_pool_size() helper (clamped to 500). |
| agent_memory_toolkit/prompts/dedup.prompty | Reworks the prompt into a pool-wide reconcile schema: duplicates, contradictions, kept IDs. |
| agent_memory_toolkit/processors/inprocess.py | Updates processor to run reconciliation and report reconciled_count. |
| agent_memory_toolkit/processors/durable.py | Updates durable processor API to process_reconcile(...) (still a no-op). |
| agent_memory_toolkit/processors/base.py | Renames protocol method to process_reconcile(n=...) and result field to reconciled_count. |
| agent_memory_toolkit/pipeline.py | Implements reconcile_memories, adds numeric guards, supersession metadata, exact-dedup skipping, and hash-based IDs. |
| agent_memory_toolkit/models.py | Adds supersede_reason (Literal) and superseded_at fields to MemoryRecord serialization. |
| agent_memory_toolkit/cosmos_memory_client.py | Replaces client-facing dedup with reconcile(user_id, n=...) and updates auto-trigger to pass pool size. |
| agent_memory_toolkit/aio/processors/inprocess.py | Async in-process processor updated to call reconciliation and report reconciled_count. |
| agent_memory_toolkit/aio/processors/durable.py | Async durable processor API updated to process_reconcile(n=...) (no-op). |
| agent_memory_toolkit/aio/processors/base.py | Async processor protocol updated to process_reconcile(n=...). |
| agent_memory_toolkit/aio/cosmos_memory_client.py | Async client updated to expose reconcile(...) and pass pool size into auto-trigger. |
| agent_memory_toolkit/_utils.py | Adds _normalize_for_hash and truncates compute_content_hash to 32 hex chars after normalization. |
💡 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.
No description provided.