Repository navigation
Conversation
There was a problem hiding this comment.
1 issue found across 3 files
Confidence score: 5/5
- In
backend/utils/retrieval/tools/calendar_tools.py, theif names else querybranch is effectively dead becausenamesis guaranteed truthy viaor [{}], so the main risk is maintainability confusion rather than runtime behavior; this PR is safe to merge, and you can de-risk future edits by removing the unreachable fallback condition.
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
|
Hi @ZachL111 — thank you for finding and writing up this retrieval/output semantic correctness issue. We consolidated this group into a smaller aggregate PR with shared semantic models/helpers and focused tests: #8366. Your original discovery, reproduction details, and candidate fix are credited in the new PR body and commit metadata. I’m closing this individual PR as superseded by #8366, not because the issue is invalid. Thanks again for surfacing it. |
|
Hey @ZachL111 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! 💜 |
## Summary Supersedes #8290, #8291, #8306, #8310, #8311, #8313, #8319, #8320. Original issue discovery, reproductions, and candidate fixes by @ZachL111. This aggregates the retrieval/output semantic correctness fixes into one focused backend PR: - adds shared conversation metadata keys/model and uses them for vector metadata production + reranking - fixes metadata entity extraction so entities no longer copy topics - refactors RAG chunking through a pure `build_conversation_context(...) -> str | None` path so short conversations are included consistently - separates calendar deletion successes from failures before building user-visible output - normalizes merge/photo timestamps through a UTC-aware helper and keeps malformed/missing photo dates with a structured warning - makes proactive-notification cache setters keyword-only for `app_id` to prevent passing an `App` object as the cache key - validates daily-summary LLM JSON with a Pydantic payload, falls back only on JSON/model-validation failures, and stops logging raw LLM output - safely handles Google contacts with absent names while preserving email extraction ## Included Zach PRs Included/redesigned in this aggregate: #8290, #8291, #8306, #8310, #8311, #8313, #8319, #8320. Deferred from this aggregate: none. ## Tests - `cd backend && ./scripts/sync-python-deps.sh` - `cd backend && source .venv/bin/activate && pytest tests/unit/test_retrieval_semantics.py tests/unit/test_daily_summary_regenerate.py tests/unit/test_daily_summary_race_condition.py tests/unit/test_conversations_to_string.py` - `cd backend && source .venv/bin/activate && python -m py_compile models/conversation_metadata.py models/calendar_mutation.py models/daily_summary_payload.py utils/conversations/datetime_utils.py utils/conversations/merge_conversations.py utils/retrieval/rag.py utils/llm/chat.py utils/llm/external_integrations.py utils/retrieval/tools/calendar_tools.py database/mem_db.py database/redis_db.py database/vector_db.py tests/unit/test_retrieval_semantics.py` - `cd backend && bash testing/e2e/run.sh` — 73 passed, 6 skipped Also ran `python backend/scripts/scan_async_blockers.py` from repo root; it exits 0 and reports existing async-blocker findings unrelated to this PR. Running it from `backend/` currently fails with `Error: backend/routers not found`, so root invocation was used. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/8366?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. -->
Supersedes BasedHardware#8290, BasedHardware#8291, BasedHardware#8306, BasedHardware#8310, BasedHardware#8311, BasedHardware#8313, BasedHardware#8319, BasedHardware#8320. Co-authored-by: ZachL111 <[email protected]>
Summary
search_google_contactsin the calendar tools resolves an attendee name to an email by querying the Google People API, first against My Contacts and then against Other Contacts. In the Other Contacts branch, a contact that has an email but an emptynameslist makes the handler raiseIndexErrorwhile reading the display name for a log line. The broadexcept Exceptionaround that block swallows the error, so the email that was already extracted is thrown away and the function returnsNone. The result is a contact that should resolve gets silently dropped, and the calendar tool reports the attendee as unfound even though their email was in hand. This change reads the names list defensively so the email is still returned. This is a proactive hardening change; there is no filed GitHub issue for it.Root cause
In
backend/utils/retrieval/tools/calendar_tools.py,search_google_contactshandles the Other Contacts result like this:The
[{}]default passed toperson.get('names', [{}])is only used when thenameskey is missing from the dict. The People API can return a contact that has an email but'names': [], an empty list that is present. In that caseperson.get('names', [{}])returns the empty list, and[][0]raisesIndexError. Thereturn emailon the next line never runs. ThatIndexErrorpropagates up to theexcept Exceptionwrapping the Other Contacts lookup, which logs it and falls through to the finalreturn None, so the email is dropped even though it was already read intoemail.Fix
Read the names list once and only index it when it is non-empty, falling back to the query string for the log label otherwise:
person.get('names') or [{}]treats both a missing key and an empty list the same way, so the index is always safe. A contact that has a real name is unchanged: it logs that name and returns the email exactly as before. The only difference in behavior is that a contact with an email and no name now returns the email instead of being discarded.Testing
Added
backend/tests/unit/test_calendar_contacts_empty_names.py, registered inbackend/test.sh. The module under test pulls in heavy database, utils, and langchain dependencies through its package, so the test loadscalendar_toolsdirectly from its file path under a stub meta-path finder that replaces thedatabaseandutilstrees (and other heavy roots) with empty stubs, while keeping the target leaf module real. It drivessearch_google_contactswith a mocked auth client whose My Contacts search returns nothing and whoseotherContacts:searchreturns the chosen payload, and patchesasyncio.sleepso the warm-up delay does not slow the test. One case sends a contact with an email and'names': []and asserts the email is returned rather than dropped; a second case sends a contact that has a name and asserts the email still comes back, so the happy path stays intact. Verified red to green: the test fails on current main and passes with this change.PR status check
No open PR changes this logic. The index access and its fix live entirely inside this handler's body, and no pending PR touches
search_google_contactsor the Other Contacts name read. The defensive read added here does not appear anywhere in this file's history, so it is not a previously reverted fix being resubmitted. No filed GitHub issue matches.