A re-retain without `observation_scopes` takes the bank's default scope off the facts it keeps
Seen on a self-hosted Hindsight 1.2.1 (API image by digest, PostgreSQL 16) and checked against main at 31d5556
(19 Nov 2026). Paths are under hindsight_api/; line numbers are those of the 1.2.1 image.
What happens
A bank has default_observation_scopes: "shared" in its config.
- A document is retained under a fixed
document_id. Its facts carryobservation_scopes = "shared", whether the request named the scope or left it out:_apply_default_observation_scopesgives the bank's default to freshly extracted facts (engine/retain/fact_extraction.py3822 to 3833). - The same
document_idis retained again, and the request does not nameobservation_scopes. - Chunks whose text changed are extracted again. Their facts get the default, "shared".
- Chunks whose text did not change keep their facts, and those facts are relabelled with the request's own
value, which is
None:engine/retain/orchestrator.pyhandsretain_params.get("observation_scopes")tofact_storage.update_memory_units_metadata_and_tagsat 1406, 4555, 4739 and 4789, and the store writes it over the survivors (engine/retain/fact_storage.py553 to 562).
After a partial change the document has two kinds of facts: re-extracted ones in the bank's scope, and kept ones without a scope. After a re-retain of the identical text (the "DELTA RETAIN (no changes)" path, orchestrator 4739 and 4789) every fact of the document is relabelled.
Because the scope of the kept facts changed, the same function deletes the observations built on them and marks
the facts as not consolidated (fact_storage.py 563 to 573). They are then consolidated again, without the
bank's scope, so their observations are built apart from the rest of the bank.
Why it looks like a fault and not a choice
- The relabel exists, in the words of its docstring, so that the optimised delta retain "matches a full replace"
(
fact_storage.py490 to 494). A full replace gives every fact the bank's default. - The comment above the call at
orchestrator.py1398 to 1402 names the aim: without the relabel a partial re-retain left "a document whose units disagreed on their labels by whether their chunk happened to change". For the scope, the relabel now causes exactly that. - The request field's own description says: "When omitted, the bank's default_observation_scopes applies"
(
api/http.py1315).
Who meets it
- Every MCP client.
mcp_tools.pydoes not contain the nameobservation_scopes. Itsretainandsync_retaintools (1024, 1085, 1148, 1210) take content, context, timestamp, tags, metadata, document_id, strategy and update_mode. An MCP client that stores an existing document again, in a bank with a default scope, cannot avoid the loss. - Any API client that leaves the field out on a re-retain.
A document of one chunk whose text changes is extracted afresh and keeps the scope, so small notes do not show it.
Numbers from this server
- Reproduced on a copy of the production database, through the HTTP retain without
observation_scopes: a made-up note of two chunks, sent twice with one line changed. After the first send: 33 facts, all "shared". After the second: the 17 facts of the unchanged chunk had no scope, and the count of facts outside the bank's scope went from 0 to 17. Withobservation_scopes: "shared"named in both requests the kept facts stayed "shared" (two more runs). - The MCP tools were not used in that test. They cannot name the field, so they send the same request.
- The identical-text path, on production (the bank's default was already "shared"): a same-text re-retain of 213 documents, made to add a timestamp and sent without the field, wrote "no scope" over "shared". 264 observations were deleted and 307 facts were queued for consolidation again. No LLM call was made by the retains themselves.
- Exposure in one bank: 47 of 437 documents have more than one chunk; they hold 1,177 of 3,007 facts.
- Cost of one loss: the kept facts are consolidated twice, once after the loss and once after the repair.
To reproduce
- Create a bank and set
default_observation_scopesto"shared"in its config. - Retain a text long enough for two chunks under a fixed
document_id, withoutobservation_scopes. select observation_scopes, count(*) from memory_units where bank_id = '<bank>' and document_id = '<id>' and fact_type <> 'observation' group by 1gives one row,"shared".- Change one line in the second chunk and retain the text again under the same
document_id, again withoutobservation_scopes(or through the MCPretaintool). - The query of step 3 now gives two rows:
"shared"for the facts of the changed chunk, NULL for the facts of the unchanged one.
Retaining the identical text in step 4 is the shorter way: every fact of the document is kept, so every fact loses the scope, and no LLM call is made (seen on production, see above).
What would fix it
- Resolve the scope for kept facts as for fresh ones: where the orchestrator hands
retain_params.get("observation_scopes")to the relabel, fall back to the bank'sdefault_observation_scopeswhen the request names none. Or leave the scope of kept facts untouched when the request names none. - Give the MCP
retainandsync_retaintools anobservation_scopesargument.
What is done here meanwhile
- Writers that use the HTTP API name
observation_scopesin every retain. - An hourly count of facts whose scope differs from their bank's default, with an alert.
- The repair is the document PATCH that sets the scope again; nothing is extracted again.
Related
- #6452: the same relabel in
update_memory_units_metadata_and_tags, seen for tags. - On
mainat 31d5556 the four call sites still passretain_params.get("observation_scopes")(engine/retain/orchestrator.py1414, 4563, 4747, 4797), andmcp_tools.pydoes not contain the name.