openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

Connector-synced memories are never retrieved: deficient vectors, provider signature mismatch, raw Gmail bodies, global-only auto-recall

Open yh928 opened this issue 4 months ago • 2 comments

Summary

Memories synced from a connector are unretrievable. A Gmail thread that was ingested successfully never comes back from recall, on a live instance.

Problem

Four independent failures stack up, each enough on its own to make a synced memory invisible:

  1. Deficient vectors are invisible and never repaired. A chunk whose batch embed failed is stored text-only, and a partial cloud failure writes degenerate short vectors. Recall drops any chunk whose dimension differs from the live query, so both are permanently unreachable — and nothing re-derives them.
  2. The Gmail response reshape lost its caller in the TinyCortex engine migration, so the sync stores raw provider JSON rather than one record per message.
  3. The tree's active signature names a different provider than the namespace store's embedder, so the two disagree about what a stored vector even is.
  4. Auto-recall is global-only. RecallOpts::default() resolves to the global namespace, so the per-turn context never searches connector namespaces at all.

Steps to reproduce:

  1. Connect Gmail and let the sync ingest a thread.
  2. Ask the agent about something only that thread contains.
  3. The agent answers as if the memory does not exist. A direct namespace query shows the row present but not retrievable.

Solution (optional)

Treat deficient vector_chunks rows as their own durable work-list and sweep them (startup, sync completion, login, embedder switch), writing a vector back only when its width matches the active embedder. Restore the reshape via an executor wrapper, carry the embedding provider into the tree config, and fan auto-recall out to the connector namespaces.

Acceptance criteria

  • [ ] Repro gone — a synced Gmail thread is retrievable through auto-recall on a live instance.
  • [ ] Sweep is restart-safe — the pending set is re-derived every pass, with no queue to lose.
  • [ ] No short-vector writes — a degraded provider cannot stamp a vector that stays pending forever.
  • [ ] Regression safety — coverage for the sweep, the reshape, the signature, and the namespace fan-out.
  • [ ] Diff coverage ≥ 80% — the fix PR meets the changed-lines coverage gate.

Related

Fix: #5258, which depends on tinyhumansai/tinycortex#132 landing first.

yh928 avatar Jul 31 '26 08:07 yh928

Re-verified 2026-09-04 on main f5c5ba892 (tinymemory module 1.14.1, tinycortex cb1c163) against a live desktop store. Still valid, not closable: three of the four failures reproduce and the fix PR is dead. Proposing a re-scope so the remaining work has owners.

Per failure

# Failure Status Evidence on main
1 Deficient vectors invisible and never repaired live store/namespace_store/documents.rs still writes every chunk of a document with embedding = NULL when the batch embed fails; the reader (namespace_store/query.rs:630-637) silently skips rows with no usable vector; nothing revisits vector_chunks (the reembed_backfill job covers only the tree sidecars; the Sources page's "Repair older memories" is the #6012 tree backfill). Live store: 30,358 null-vector rows (skill-gmail 30,178 of 39,328; global 124 of 148). → tinyhumansai/tinymemory#140
2 Gmail sync stores raw provider JSON fixed tinycortex#132 (merged 2026-08-10) is inside the pinned cb1c163; documents are one per message, plain text.
3 Tree and namespace store disagree about the signature live, new form #132 unified the format; the provider label still comes from two places. Tree signs provider=cloud (engine/config.rs:60, effective_embedder_slug), namespace store signs the configured slug verbatim (store/factories.rs:264), so [memory] embedding_provider = "managed" yields provider=managed. → tinyhumansai/tinymemory#139
4 Auto-recall is global-only live agent/harness/memory_context.rs:53,89 and memory/agent/memory_loader.rs:67 pass RecallOpts::default(); retriever.rs:165 → mem.recall → tinymemory memory_trait.rs:43 normalize_namespace(None) → GLOBAL_NAMESPACE; the ranked query is WHERE namespace = ?1. Connector namespaces are never searched per turn. context_scout (tree FastRetrieveQuery) exists but only when the agent invokes the tool.

What failure 3 does today

Timeline from the host log and memory.db on the reference store:

2026-09-01 17:10:20  [embeddings::rpc] update_settings applied provider="managed" model="embedding-v1" dimensions=1024 sig_changed=true requeued=0
2026-09-01 17:11:55  last vector_chunks row signed  provider=cloud;model=embedding-v1;dims=1024
2026-09-01 17:12:24  app restart (module re-reads config at load)
2026-09-01 17:13:46  first row signed               provider=managed;model=embedding-v1;dims=1024

Trigger: a switch in the Embeddings tab from Ollama to Managed. The pre-switch rows were cloud-labelled cloud vectors (embedding-v1, 1024 dims) in the first place because the host's default embedder hard-codes the managed provider regardless of the configured one (#5730). Same endpoint, same model, same dimensions, new label, and the reader skips any row whose signature is not the active one:

vector_chunks signature rows reachable by vector recall today
provider=managed (after the switch) 8,365 yes
provider=cloud (before) 12,672 no
NULL (embed failed, never repaired) 30,358 no

The global namespace, the only one per-turn recall reads, has zero rows at the active signature. Both spellings also come from openhuman's own config migrations (unify_ai_provider_settings → "cloud", migrate_legacy_embedding_provider → "managed"), so this is not limited to people who used the toggle.

Acceptance criteria as written

  • [ ] Repro gone through auto-recall — fails (failure 4).
  • [ ] Sweep is restart-safe — no sweep exists (failure 1).
  • [ ] No short-vector writes — width is checked on read only; failed batches still write text-only rows.
  • [ ] Regression coverage — only the reshape has tests (tinycortex#132).
  • [ ] Diff coverage — no live fix PR.

Fix PR

#5258 is un-rebasable: 14 of its 23 files were deleted by ba088ec20 (legacy memory subsystem removed 2026-08-10), last commit 2026-08-05. Its four parts now split by owner.

Proposed re-scope

work where
Re-embed sweep for vector_chunks + width check on write tinyhumansai/tinymemory#140
One provider label for one embedder + re-sign migration for aliased rows tinyhumansai/tinymemory#139
Per-turn auto-recall fan-out to connector namespaces (or tree retrieval in the per-turn path) this issue, fresh PR
Row-level "waiting for vectors" signal on the Sources page #6025

Suggest keeping this open for the fan-out only and treating the two tinymemory issues as blockers for "repro gone".

YellowSnnowmann avatar Sep 04 '26 11:09 YellowSnnowmann

Triage: valid — Current review confirms this is a concrete, in-scope engineering issue or request: “Connector-synced memories are never retrieved: deficient vectors, provider signature mismatch, raw Gmail bodies, global-only auto-recall”. No complete resolution is evident in current main.

senamakel avatar Oct 09 '26 17:10 senamakel