Repository navigation
fix: preserve complete claims in memory tool responses - #15462
Merged
Merged
Conversation
…plete-evidence # Conflicts: # backend/tests/unit/test_sync_bridge_lifecycle.py
Wizard815
pushed a commit
to Wizard815/omi-local
that referenced
this pull request
Nov 25, 2026
…#15462) Memory tool responses could be cut in the middle of a claim at the character limit, discarding a trailing exception. Use one shared formatter for chat and REST memory reads/searches: keep complete JSON-quoted claims with their existing subject attribution, cap the complete result at 60,000 characters, and report whole-record omissions and list continuation offsets. This uses existing memory records and retrieval policy; it adds no background distillation, profile store, model calls, or database reads. Source citations include only emitted claims; lock filtering remains in place. An exhausted temporal scan is reported without a misleading continuation offset. - INV-MEM-4: preserve canonical promotion authority; no promotion or writes. - INV-MEM-1: preserve the existing memory tiers and default Archive exclusion. - `PYTHON=.venv/bin/python BACKEND_UNIT_TEST_FILE_LIST=<nine-file list> BACKEND_PYTEST_FILE_ISOLATION=1 bash test.sh`: 161 passed across evidence rendering, REST adapters, universal-read fallback, lock filtering, scope, temporal views, timezone, result bounds, and tool callers. File isolation avoids an existing cross-file import/stub leak; a bare combined pytest run was interrupted in a Google API retry after 40 passes. - `bash backend/testing/e2e/run.sh -k 'memory_search or retrieval'`: 3 passed against the real FastAPI app with hermetic service fakes. - Served the real app using Uvicorn on loopback with the same hermetic service fakes; curl GET `/v1/tools/memories?limit=1` and POST `/v1/tools/memories/search` returned full quoted claims, their trailing exception, recorded subject attribution, and source citations. External network was blocked. No deployment or production behavior is claimed. - `cd backend && bash scripts/typecheck.sh`: zero errors. - `make preflight`: all 28 selected checks passed. - Cost replay is documented in `backend/docs/memory/complete-tool-evidence.md`. `backend/tests/unit/test_memory_evidence.py` covers long claims and JSON control characters, attribution labels, all four entrypoints, complete-record bounds, a deferred row's continuation offset, and an oversized first record without a pagination loop. Failure-Class: none Paired actual baseline/new formatter calls on an owner-authorized private snapshot (1,426 eligible processed memories; 18 frozen top-five searches; 40 paired cases across all four entrypoints) measured **+65.2 proxy tokens/search**, **+436–485 tokens/50-memory list**, and **+2,440–2,489 tokens/300-memory list**. At 100 retrievals/day for 30 days, each read once by short-context Luna at $0.20/M uncached input: **+$0.039/user/month for searches**, **+$0.262–$0.291 for 50-memory lists**, or **+$1.464–$1.493 for 300-memory lists**. Three model reads triple those estimates. These are local `cl100k_base` payload estimates, not invoice measurements or an observed usage mix. No new model, embedding, storage, or background work is added. Cache behavior, downstream output changes, retries, pagination, and long-context tier crossings require full-turn accounting. See `backend/docs/memory/complete-tool-evidence.md` for method and limits. Raw personal data and queries stay outside Git. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/15462?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
Wizard815
pushed a commit
to Wizard815/omi-local
that referenced
this pull request
Nov 25, 2026
Brings the fork from the 2026-09-14 merge base (6075928) to upstream 8a1de0d (2026-10-21). 122 conflicts. Upstream's code is the baseline; the fork's self-hosting changes are re-applied on top, ported into upstream's new structure where it moved code. Fork commits that were cherry-picks of upstream PRs (BasedHardware#15202, BasedHardware#15289, BasedHardware#15304, BasedHardware#15317, BasedHardware#15462, BasedHardware#15649) take upstream's newer version. Resolution decisions - Chat: upstream moved the send-message turn into utils/chat_turn.py. That call now forwards model_shortcut, so the sticky /adult toggle still works. graph.execute_chat_stream keeps the shortcut-routing wrapper around upstream's body. upstream already has the async quota release. - Local LLM: upstream routes every managed get_llm() through the Omi LLM gateway (OMI_LLM_GATEWAY_FEATURE_MODE no longer opts out). In local mode (is_local_mode()) clients.py now keeps generation on the direct client at OPENAI_BASE_URL. model_config keeps the fork's Redis/env model resolution, the per-turn shortcut override and local_base_chat_model. - Conversation notes: upstream serves them only through the shaped notes agent and fails closed unless OMI_SHAPED_AGENT_MODE is on, so omi-host/entrypoint.sh now exports OMI_SHAPED_AGENT_MODE=on (default). - Auth: upstream added POST /v1/auth/local-dev/custom-token, gated only on FIREBASE_AUTH_EMULATOR_HOST. omi-host always sets that (the emulator is its real auth store), so the route would mint a token for any uid. OMI_DISABLE_LOCAL_DEV_TOKEN_ROUTE (set by the entrypoint) switches it off. The fork's /v1/auth/local-login and remote-login sessions are kept. - Time zone: upstream added the same PUT /v1/users/time-zone. Keep upstream's handler and database.notifications.set_user_time_zone, and drop the fork's duplicate setter (it shadowed upstream's) and SaveTimeZoneRequest. The app calls upstream's syncUserTimeZoneServer. - Folders: upstream has no hierarchy, so the fork's folder tree is kept. folder_tabs.dart was deleted upstream (folder browsing moved into global search), so the subfolder bar, breadcrumb and tree entry were ported into global_search.dart and folder_options_sheet.dart. - Static map: rebuilt on upstream's themed renderer. The no-key OpenStreetMap fallback dispatches to _render_osm_png. - TTS: upstream's provider switch, plus the fork's local Piper path (TTS_LOCAL_BASE_URL). - Subscription/billing: the PROVIDER_MODE=offline early return sits ahead of upstream's new funded-compute and budget gates. - belief_model.py: deleted upstream (BasedHardware#22209) with nothing left importing it, so it stays deleted, as do its fork-only tests. - Vector DB: the fork's LOCAL_VECTOR_DB=chroma path is kept on top of upstream's upsert_vector2 metrics and legal-hold gates. - App: - The "/" popup, the sticky shortcut chip and modelShortcut are ported onto upstream's composer. - The day-review banner stays on Home. - The day-review list moves into the Daily Recaps app bar (its Home header button went away upstream). - LED dim on mute is re-applied after upstream's dispatch-based pause/resume. - Session snapshots: AuthService snapshots recognize a valid remote-login session. Upstream's snapshots read it as signed out, which silently disabled data export, on-demand recaps and onboarding sync. - SaaS removals stay removed: referral page and its Settings destination, Creator Payouts destination, Crashlytics, the FCM token, and the Google sign-in button. - route_policy_manifest.yaml: upstream's entries plus the fork's 25 routes. - Generated files: - regenerated from the merged sources: app-client OpenAPI spec and its Dart/Swift/TS types, flutter gen-l10n; - regenerated from requirements.txt by update-python-lock.sh: all pylocks, which also restores the e2e packages main's pylock had lost. Verification (details in the PR): - flutter analyze: 0 errors; app/scripts/analyze_ratchet.sh passes. - Backend suites for every touched area pass, among them test_local_model_routing (including the new gateway-bypass tests), test_chat_model_shortcuts through upstream's run_chat_turn, test_nested_folders, test_local_scheduler, test_local_dev_auth plus the new self-host opt-out test, test_static_map, and the LLM/retrieval/vector suites. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0148HLrpWR8Mimn43rkNvGKg
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.
What changed and why
Memory tool responses could be cut in the middle of a claim at the character limit, discarding a trailing exception. Use one shared formatter for chat and REST memory reads/searches: keep complete JSON-quoted claims with their existing subject attribution, cap the complete result at 60,000 characters, and report whole-record omissions and list continuation offsets.
This uses existing memory records and retrieval policy; it adds no background distillation, profile store, model calls, or database reads. Source citations include only emitted claims; lock filtering remains in place. An exhausted temporal scan is reported without a misleading continuation offset.
Product invariants affected
How it was verified
PYTHON=.venv/bin/python BACKEND_UNIT_TEST_FILE_LIST=<nine-file list> BACKEND_PYTEST_FILE_ISOLATION=1 bash test.sh: 161 passed across evidence rendering, REST adapters, universal-read fallback, lock filtering, scope, temporal views, timezone, result bounds, and tool callers. File isolation avoids an existing cross-file import/stub leak; a bare combined pytest run was interrupted in a Google API retry after 40 passes.bash backend/testing/e2e/run.sh -k 'memory_search or retrieval': 3 passed against the real FastAPI app with hermetic service fakes./v1/tools/memories?limit=1and POST/v1/tools/memories/searchreturned full quoted claims, their trailing exception, recorded subject attribution, and source citations. External network was blocked. No deployment or production behavior is claimed.cd backend && bash scripts/typecheck.sh: zero errors.make preflight: all 28 selected checks passed.backend/docs/memory/complete-tool-evidence.md.Tests
backend/tests/unit/test_memory_evidence.pycovers long claims and JSON control characters, attribution labels, all four entrypoints, complete-record bounds, a deferred row's continuation offset, and an oversized first record without a pagination loop.Failure class (fixes)
Failure-Class: none
Cost impact
Paired actual baseline/new formatter calls on an owner-authorized private snapshot (1,426 eligible processed memories; 18 frozen top-five searches; 40 paired cases across all four entrypoints) measured +65.2 proxy tokens/search, +436–485 tokens/50-memory list, and +2,440–2,489 tokens/300-memory list. At 100 retrievals/day for 30 days, each read once by short-context Luna at $0.20/M uncached input: +$0.039/user/month for searches, +$0.262–$0.291 for 50-memory lists, or +$1.464–$1.493 for 300-memory lists. Three model reads triple those estimates.
These are local
cl100k_basepayload estimates, not invoice measurements or an observed usage mix. No new model, embedding, storage, or background work is added. Cache behavior, downstream output changes, retries, pagination, and long-context tier crossings require full-turn accounting. Seebackend/docs/memory/complete-tool-evidence.mdfor method and limits. Raw personal data and queries stay outside Git.