You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(consolidation): eliminate duplicate observations via interleave dedup recall (#1907)
Round-robin interleave fusion for consolidation dedup recall (guarantees the semantic-#1 'twin' a slot so the LLM updates instead of duplicating), unified 'reranking' strategy param (cross_encoder/rrf/interleave), case-sensitive exact-dup guard, obs-dedup tool + benchmark wired into the perf dashboard (English dataset). Near-dup observation rate 4% -> 0% on the English hermes transcript (1/10 and 1/4), coverage 89% -> 94%, no false merges.
Copy file name to clipboardExpand all lines: hindsight-api-slim/hindsight_api/engine/consolidation/prompts.py
+5-4Lines changed: 5 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -65,7 +65,7 @@
65
65
# Output format — JSON braces escaped as {{ }} so .format() leaves them literal
66
66
_OUTPUT_SECTION="""## OUTPUT FORMAT
67
67
68
-
Return a JSON object with three arrays: `creates`, `updates`, `deletes`.
68
+
Return a JSON object with three arrays: `creates`, `updates`, `deletes`. Every entry must include a `reason`.
69
69
70
70
### Example 1 — Merging recurring claims into an existing observation
71
71
@@ -79,7 +79,7 @@
79
79
Expected output (one UPDATE, no creates — both new facts are additional evidence for the same canonical decision):
80
80
81
81
{{"creates": [],
82
-
"updates": [{{"text": "Donald named Athena's sovereignty as a foundational principle of the Janus architecture.", "observation_id": "11111111-1111-1111-1111-111111111111", "source_fact_ids": ["a1b2c3d4-e5f6-7890-abcd-ef1234567890", "b2c3d4e5-f6a7-8901-bcde-f12345678901"]}}],
82
+
"updates": [{{"text": "Donald named Athena's sovereignty as a foundational principle of the Janus architecture.", "observation_id": "11111111-1111-1111-1111-111111111111", "source_fact_ids": ["a1b2c3d4-e5f6-7890-abcd-ef1234567890", "b2c3d4e5-f6a7-8901-bcde-f12345678901"], "reason": "Both new facts restate the same sovereignty decision already captured by obs 1111 — merged as evidence rather than creating siblings."}}],
83
83
"deletes": []}}
84
84
85
85
### Example 2 — State change updates one observation; unrelated fact creates a new one
@@ -93,8 +93,8 @@
93
93
94
94
Expected output (UPDATE for the state change; CREATE for the unrelated work-hours facet):
95
95
96
-
{{"creates": [{{"text": "Alice works long hours, often past midnight.", "source_fact_ids": ["d4e5f6a7-b8c9-0123-defa-234567890123"]}}],
97
-
"updates": [{{"text": "Alice owned a 2019 Honda Civic; sold it on March 15, 2025.", "observation_id": "22222222-2222-2222-2222-222222222222", "source_fact_ids": ["c3d4e5f6-a7b8-9012-cdef-123456789012"]}}],
96
+
{{"creates": [{{"text": "Alice works long hours, often past midnight.", "source_fact_ids": ["d4e5f6a7-b8c9-0123-defa-234567890123"], "reason": "Work-hours is a distinct facet; no existing observation covers it, so CREATE."}}],
97
+
"updates": [{{"text": "Alice owned a 2019 Honda Civic; sold it on March 15, 2025.", "observation_id": "22222222-2222-2222-2222-222222222222", "source_fact_ids": ["c3d4e5f6-a7b8-9012-cdef-123456789012"], "reason": "State change to the existing Honda Civic observation 2222 — UPDATE, not a new sibling."}}],
98
98
"deletes": []}}
99
99
100
100
### Observation text rules
@@ -110,6 +110,7 @@
110
110
- One create or update may reference multiple facts when they jointly support the observation.
111
111
- **AT MOST ONE UPDATE PER `observation_id`**: if several new facts all update the same existing observation, emit a single `updates` entry that lists all contributing `source_fact_ids` and a single consolidated `text`. Never emit two `updates` entries with the same `observation_id` in one response — they would silently overwrite each other.
112
112
- `deletes`: only when an observation is directly superseded or contradicted by new facts.
113
+
- `reason`: REQUIRED on every create/update/delete — one sentence explaining the choice. For a CREATE, state which existing observation(s) you considered and why none matched (a near-identical existing observation means you should UPDATE, not CREATE). This is audited to catch duplicate creates.
113
114
- Do NOT include `tags` — handled automatically.
114
115
- Return `{{"creates": [], "updates": [], "deletes": []}}` if nothing durable is found."""
0 commit comments