Repository navigation
fix(chat): serve legacy memories when a legacy-cohort account has no rollout state (#10736) - #10752
Merged
Merged
Conversation
…rollout state (#10736) Omi chat's memory tools returned "No memories available for this request." for accounts that were never enrolled in the canonical-memory rollout, so chat answered as though the user had no memories while the memories screen showed them normally. Prod logs show 23 such denials on 2026-07-27 alone. Root cause is the divergence already fixed for the Developer API (#10094, #10485) and MCP (#10095): pin_memory_system resolves every account outside the canonical whitelist to MemorySystem.LEGACY, where users/{uid}/memory_control/state is *expected* to be absent — but read_default_read_rollout reports that absent doc as DENY_MEMORY / missing_rollout_state. The chat sites reach that branch only after the cohort pin already said LEGACY, then refused to read the collection the selector had just declared authoritative. Fix: route all four chat sites through one shared decision owner, chat_legacy_read_authorized, mirroring mcp_legacy_read_authorized. It allows an explicit USE_LEGACY_SAFE decision and the never-enrolled missing_rollout_state case, records the mode change through the shared record_fallback helper, and keeps every other deny reason (malformed state, read failure, missing grant, shadow-only) fail-closed. Verify (backend/.venv, python3.11, repo runner): - new tests/unit/test_chat_memory_missing_rollout_fallback.py: 12 passed — invokes get_memories_tool / search_memories_tool / get_memories_text with the adapter denying on missing_rollout_state and asserts the legacy memory is served, plus the mirror cases asserting a missing-grant denial still returns the safe string and never touches the legacy read. - 81 memory/retrieval test files via test.sh: exit 0. - black clean on all changed files. Not exercised live: a production chat turn for a real un-enrolled account (no such credentials here). The fix point is the shared server-side decision helper the tests drive directly. Failure-Class: none Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
undivisible
pushed a commit
to Archit-lal/omi
that referenced
this pull request
Jul 29, 2026
…rollout state (BasedHardware#10736) (BasedHardware#10752) Omi chat's memory tools returned "No memories available for this request." for accounts that were never enrolled in the canonical-memory rollout, so chat answered as though the user had no memories while the memories screen showed them normally. Prod logs show 23 such denials on 2026-07-27 alone. Root cause is the divergence already fixed for the Developer API (BasedHardware#10094, BasedHardware#10485) and MCP (BasedHardware#10095): pin_memory_system resolves every account outside the canonical whitelist to MemorySystem.LEGACY, where users/{uid}/memory_control/state is *expected* to be absent — but read_default_read_rollout reports that absent doc as DENY_MEMORY / missing_rollout_state. The chat sites reach that branch only after the cohort pin already said LEGACY, then refused to read the collection the selector had just declared authoritative. Fix: route all four chat sites through one shared decision owner, chat_legacy_read_authorized, mirroring mcp_legacy_read_authorized. It allows an explicit USE_LEGACY_SAFE decision and the never-enrolled missing_rollout_state case, records the mode change through the shared record_fallback helper, and keeps every other deny reason (malformed state, read failure, missing grant, shadow-only) fail-closed. Verify (backend/.venv, python3.11, repo runner): - new tests/unit/test_chat_memory_missing_rollout_fallback.py: 12 passed — invokes get_memories_tool / search_memories_tool / get_memories_text with the adapter denying on missing_rollout_state and asserts the legacy memory is served, plus the mirror cases asserting a missing-grant denial still returns the safe string and never touches the legacy read. - 81 memory/retrieval test files via test.sh: exit 0. - black clean on all changed files. Not exercised live: a production chat turn for a real un-enrolled account (no such credentials here). The fix point is the shared server-side decision helper the tests drive directly. Failure-Class: none Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Omi chat's memory tools (
get_memories_tool,search_memories_tool, and the REST tool services behind/v1/tools/*) no longer return "No memories available for this request." for accounts that were never enrolled in the canonical-memory rollout: they now serve the authoritative legacymemoriessurface.All four sites route the decision through one shared helper,
chat_legacy_read_authorized, instead of four copies of the!= USE_LEGACY_SAFEcomparison. Every other deny reason (malformed state, read failure, missing grant, shadow-only) stays fail-closed. The mode change is recorded through the sharedrecord_fallbackhelper — no new one-off counter.Chat-surface counterpart of #10094 / #10485 (Developer API) and #10095 (MCP), same root cause. This is the cross-surface unification #10485 explicitly deferred. Fixes #10736.
Root cause
pin_memory_systemresolves every account outside the canonical whitelist toMemorySystem.LEGACY, whereusers/{uid}/memory_control/stateis expected to be absent — butread_default_read_rolloutreports the absent doc asDENY_MEMORY/missing_rollout_state. The chat sites reach that branch only after the cohort pin already said LEGACY, then refused to read the collection the selector had just declared authoritative. It is silent from the user's side: chat answers as though the user has no memories, so it reads as the assistant forgetting rather than as an error. Prod logs show 23 of these denials on 2026-07-27 alone.Failure class
Failure-Class: none
Same call as #10094 / #10095: no registered class covers a reader failing closed on state whose absence the authoritative cohort selector defines as normal.
Durable guard
chat_legacy_read_authorized, whose docstring names the contract.missing_rollout_state(doc absent = never enrolled) qualifies;malformed_rollout_state,uid_mismatch, androllout_read_failedstay fail-closed because there the doc exists or its state is unknown.Validation
tests/unit/test_chat_memory_missing_rollout_fallback.py— 12 passed. It invokesget_memories_tool,search_memories_tool, andget_memories_textwith the adapter denying onmissing_rollout_stateand asserts the legacy memory reaches the result, plus the mirror cases asserting amissing_chat_default_memory_grantdenial still returns the safe string and never calls the legacy read. These cannot pass on pre-fix code.BACKEND_UNIT_TEST_FILE_LIST=... bash test.sh) → exit 0, includingtest_chat_memory_adapter.py,test_tools_router.py,test_mcp_memory_adapter.py,test_lock_bypass_fixes.py.black --line-length 120 --skip-string-normalizationclean on all changed files.Product invariants affected
backend/utils/memory/chat_memory_adapter.py): no tier vocabulary change — the helper only decides legacy-vs-deny routing for chat reads; tier semantics and the guard test are untouched.Out of scope, named
should_use_legacy_fallbackonChatMemorySearchResultstays for API compatibility; the call sites now use the shared helper.🤖 automated by hourly watchdog — tested and merged