Skip to content

Commit 4beaa63

Browse files
Aayush KatariaAayush Kataria
authored andcommitted
Resolving comments
1 parent 2b9ee5b commit 4beaa63

7 files changed

Lines changed: 625 additions & 63 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ high_conf_facts = memory.get_memories(user_id="u1", memory_type="fact", min_conf
209209

210210
`reconcile_memories(user_id, n=50)` collapses paraphrased duplicates and resolves semantic contradictions in a single LLM pass over the N most-recent active facts. Both outcomes soft-delete the loser with a `supersede_reason` of `"duplicate"` or `"contradiction"`. See [Docs/concepts.md](Docs/concepts.md#memory-reconciliation) for details.
211211

212-
> **Cost note.** Each reconciliation makes one LLM call covering up to `n` facts (default 50, hard cap 500). With auto-trigger, this fires every `FACT_EXTRACTION_EVERY_N × DEDUP_EVERY_N` turns per user. The previous cosine-cluster pre-filter was removed deliberately — it could not catch semantic contradictions like "vegetarian" vs "ribeye steak" — so the LLM is now invoked whenever there are ≥ 2 active facts. Tune `DEDUP_EVERY_N` upward (or override `n` per call) if you need to bound LLM cost more tightly.
212+
> **Cost note.** Each reconciliation makes one LLM call covering up to `n` facts (default 50, hard cap 500). With auto-trigger, this fires every `FACT_EXTRACTION_EVERY_N × DEDUP_EVERY_N` turns per user, with `n` taken from `DEDUP_POOL_SIZE`. The previous cosine-cluster pre-filter was removed deliberately — it could not catch semantic contradictions like "vegetarian" vs "ribeye steak" — so the LLM is now invoked whenever there are ≥ 2 active facts. Tune `DEDUP_EVERY_N` upward (frequency) or `DEDUP_POOL_SIZE` downward (pool size; or override `n` per call when invoking `reconcile()` directly) to bound LLM cost more tightly.
213213
214214
| New `MemoryRecord` field | Meaning |
215215
|---|---|
@@ -226,6 +226,7 @@ By default, the **InProcess processor** runs each pipeline step independently as
226226
|---|---|---|---|
227227
| `FACT_EXTRACTION_EVERY_N` | `1` (every turn) | `process_extract_memories` | scheduled via `asyncio.create_task` |
228228
| `DEDUP_EVERY_N` | `5` | `process_reconcile` (fires every Nth extract → effectively every `FACT_EXTRACTION_EVERY_N × DEDUP_EVERY_N` turns) | scheduled via `asyncio.create_task` |
229+
| `DEDUP_POOL_SIZE` | `50` | pool size (`n`) passed to `process_reconcile` from the auto-trigger; hard-capped at `500` | n/a (per-call) |
229230
| `THREAD_SUMMARY_EVERY_N` | `10` | `process_thread_summary` | scheduled via `asyncio.create_task` |
230231
| `USER_SUMMARY_EVERY_N` | `20` | `process_user_summary` | scheduled via `asyncio.create_task` |
231232

agent_memory_toolkit/aio/cosmos_memory_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1553,6 +1553,7 @@ async def _run_auto_trigger_steps(
15531553
thread_counter_id,
15541554
user_counter_id,
15551555
)
1556+
from ..thresholds import get_dedup_pool_size
15561557

15571558
user_batch_counts: dict[str, int] = {}
15581559

@@ -1607,7 +1608,7 @@ async def _run_auto_trigger_steps(
16071608

16081609
if fire_dedup:
16091610
try:
1610-
await processor.process_reconcile(user_id=user_id)
1611+
await processor.process_reconcile(user_id=user_id, n=get_dedup_pool_size())
16111612
except Exception as exc:
16121613
logger.warning(
16131614
"Auto-trigger process_reconcile failed for %s: %s",

agent_memory_toolkit/cosmos_memory_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,7 @@ def _maybe_auto_trigger(self, turn_counts: dict[tuple[str, str], int]) -> None:
695695
PROCESSOR_OWNER_DURABLE,
696696
PROCESSOR_OWNER_INPROCESS,
697697
get_dedup_every_n,
698+
get_dedup_pool_size,
698699
get_fact_extraction_every_n,
699700
get_processor_owner,
700701
get_thread_summary_every_n,
@@ -802,7 +803,7 @@ def _maybe_auto_trigger(self, turn_counts: dict[tuple[str, str], int]) -> None:
802803

803804
if fire_dedup:
804805
try:
805-
processor.process_reconcile(user_id=user_id)
806+
processor.process_reconcile(user_id=user_id, n=get_dedup_pool_size())
806807
except Exception as exc:
807808
logger.warning(
808809
"Auto-trigger process_reconcile failed for %s: %s",

0 commit comments

Comments
 (0)