Skip to content

Adding conflict resolution#10

Merged
aayush3011 merged 7 commits into
AzureCosmosDB:mainfrom
aayush3011:users/akataria/conflictResolution
May 7, 2026
Merged

Adding conflict resolution#10
aayush3011 merged 7 commits into
AzureCosmosDB:mainfrom
aayush3011:users/akataria/conflictResolution

Conversation

@aayush3011

Copy link
Copy Markdown
Contributor

No description provided.

@aayush3011 aayush3011 marked this pull request as ready for review May 7, 2026 04:08
@aayush3011 aayush3011 requested a review from Copilot May 7, 2026 04:08

Copilot AI left a comment

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.

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-facing CosmosMemoryClient.reconcile(...).
  • Add content_hash normalization/truncation + exact-dedup skipping during extraction.
  • Extend supersession metadata with supersede_reason + superseded_at and 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.

Comment thread agent_memory_toolkit/pipeline.py Outdated
Comment thread agent_memory_toolkit/pipeline.py
Comment thread tests/unit/test_reconcile.py
Comment thread README.md Outdated
Comment thread agent_memory_toolkit/cosmos_memory_client.py Outdated
Comment thread README.md Outdated

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 36 out of 36 changed files in this pull request and generated 5 comments.

Comment thread agent_memory_toolkit/pipeline.py
Comment thread agent_memory_toolkit/pipeline.py
Comment thread agent_memory_toolkit/pipeline.py Outdated
Comment thread tests/unit/test_reconcile.py
Comment thread tests/unit/test_reconcile.py

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 36 out of 36 changed files in this pull request and generated 2 comments.

Comment thread agent_memory_toolkit/pipeline.py
Comment thread agent_memory_toolkit/pipeline.py Outdated

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 36 out of 36 changed files in this pull request and generated 3 comments.

Comment thread agent_memory_toolkit/pipeline.py
Comment thread agent_memory_toolkit/processors/inprocess.py Outdated
Comment thread agent_memory_toolkit/aio/processors/inprocess.py
@aayush3011 aayush3011 merged commit 4b8c6be into AzureCosmosDB:main May 7, 2026
6 checks passed
@aayush3011 aayush3011 deleted the users/akataria/conflictResolution branch May 21, 2026 17:26
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.

2 participants