Repository navigation
fix(desktop-backend): don't fail a chat turn on a guessed web-search requirement - #9692
Merged
Merged
Conversation
…requirement
is_fresh_public_lookup() classifies a turn as "requires public web" whenever the
last user message contains any of "right now"/"currently"/"today"/"this week"
AND any of a generic subject list ("schedule", "match", "game", "news",
"market", …), matched as raw substrings over the whole message. That guess then
becomes a terminal error: a route that cannot run Anthropic's server-side
web_search (every claude-haiku route, or any route when the kill switch is set)
returns 503 web_search_unavailable instead of answering.
The two combine into a deterministic break. CalendarReaderService's synthesis
prompt is machine-written, runs on the haiku synthesis model, and contains both
"Today's date: <iso>" and "work schedule" — so every Calendar import 503s on
both attempts and silently extracts nothing. GmailReaderService,
AppleNotesReaderService and the haiku agent-pill calls share the shape. On
sonnet, an innocuous "review the marketing copy I wrote today" ("market" inside
"marketing") gets the forced-search instruction prepended, which explicitly bans
the user's private context from the answer.
Root cause: a heuristic was given the authority of an explicit user instruction.
- A guessed requirement (freshness/anaphoric) now degrades on a route without
web search: answer from model knowledge, no injected tool, no forced-search
instruction, and record a `chat_retrieval` capability_mismatch fallback.
Only an explicit "search the web" still fails closed.
- The generic qualifier+subject heuristic matches on word boundaries and is
capped to short conversational turns, so machine-generated prompts and
ordinary words can't trip it.
Regression tests: the calendar synthesis prompt and "marketing copy … today"
stay on auto; a guessed freshness turn on haiku (and with web search disabled)
translates with no tools and no policy instruction instead of erroring.
Verified: cargo test 360 passed; cargo clippy -- -D warnings (the CI command)
clean; rustfmt applied. 3 of the 4 new tests fail on the pre-fix source (the 4th covers a new accessor).
This was referenced Jul 15, 2026
Git-on-my-level
added a commit
that referenced
this pull request
Jul 15, 2026
## Summary - Add a diff-scoped 1,500-line ratchet for Python, Swift, and Rust product sources. - Seed the committed snapshot with the 47 currently oversized files and provide a downward-only updater for splits. - Fold `RealtimeHubController.swift`'s overlapping size guard into the shared ratchet; its extracted-type ownership guard remains. ## Root cause and durable guard Oversized product files repeatedly concentrate collisions and costly navigation (#9838; notably #9836 and #9384/#9638/#9692). The new shared boundary freezes further growth, rejects smaller files that cross the threshold, and makes any exceptional raise exact-count, source-diff-bound, and one-line-justified. ## Verification - `python3 .github/scripts/test_check_product_file_line_count_ratchet.py` - `python3 desktop/macos/scripts/check-hub-controller-ratchet.py --self-test` - `make preflight` (rerun after applying the internal-only `no-changelog-needed` label) <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/9851?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. -->
undivisible
pushed a commit
to undivisible/omi
that referenced
this pull request
Sep 29, 2026
…#9851) ## Summary - Add a diff-scoped 1,500-line ratchet for Python, Swift, and Rust product sources. - Seed the committed snapshot with the 47 currently oversized files and provide a downward-only updater for splits. - Fold `RealtimeHubController.swift`'s overlapping size guard into the shared ratchet; its extracted-type ownership guard remains. ## Root cause and durable guard Oversized product files repeatedly concentrate collisions and costly navigation (BasedHardware#9838; notably BasedHardware#9836 and BasedHardware#9384/BasedHardware#9638/BasedHardware#9692). The new shared boundary freezes further growth, rejects smaller files that cross the threshold, and makes any exceptional raise exact-count, source-diff-bound, and one-line-justified. ## Verification - `python3 .github/scripts/test_check_product_file_line_count_ratchet.py` - `python3 desktop/macos/scripts/check-hub-controller-ratchet.py --self-test` - `make preflight` (rerun after applying the internal-only `no-changelog-needed` label) <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/9851?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. -->
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.
The bug
is_fresh_public_lookup()(retrieval_policy.rs) marks a turn as requires public web whenever the last user message contains any of"right now" / "currently" / "today" / "this week"and any of a generic subject list ("schedule","match","game","news","release","market", …) — rawstr::containssubstring matching over the entire message, at any length.That guess is then treated as a hard requirement: in
chat_completions.rs, a route that cannot run Anthropic's server-sideweb_search(everyclaude-haikuroute, or any route when theOMI_DESKTOP_WEB_SEARCH_DISABLEDkill switch is set) returns 503web_search_unavailableinstead of answering, andtranslate_request_innerhard-errors on the same condition.The two combine into a deterministic break:
CalendarReaderService's synthesis prompt is machine-written, runs on the haiku synthesis model (ModelQoS.Claude.synthesis), and contains bothToday's date: <iso>andwork schedule. Every import 503s on both attempts and silently drops all memories/tasks/profile.GmailReaderService,AppleNotesReaderServiceand the haiku agent-pill calls have the same shape.marketinsidemarketing) → the forced-search instruction is prepended, and that instruction explicitly tells the model not to use the user's private context.Introduced by ef8104a (07-13), which added the generic qualifier+subject heuristic on top of the pre-existing haiku 503 guard.
Root cause: a heuristic was given the authority of an explicit user instruction.
The fix
Freshness/AnaphoricLookupon a route without web search now degrades: answer from model knowledge, no injected tool, no forced-search instruction, and record achat_retrieval/capability_mismatch/degradedfallback (per the AGENTS.md fallback contract). Only an explicit "search the web" (ExplicitWeb/Mixed) still fails closed —RetrievalPolicy::web_requirement_is_explicit().marketno longer fires insidemarketing) and a 240-char cap, so machine-generated service prompts stay out of it. The fixed phrases ("latest news","current weather", …) still apply at any length.Verification
cargo test— 360 passed, including 4 new regression tests: the real calendar synthesis prompt and "review the marketing copy I wrote today" stay onauto; a guessed-freshness turn on haiku and with web search disabled translates with no tools and no policy instruction instead of erroring; explicit vs guessed web requirement.leaves_a_service_synthesis_prompt_on_auto,does_not_match_generic_lookup_terms_inside_longer_words,test_translate_request_guessed_freshness_answers_without_web_search. (The 4th covers the new accessor, which doesn't exist pre-fix.)cargo clippy -- -D warnings(the exact CI command) clean;rustfmtapplied.retrieval_policy()/translate_request_inner()with the literal prompt text fromCalendarReaderService.swift, but I did not run a real Calendar import through a deployed desktop-backend. UNVERIFIED at that layer.Not merged
Prod desktop-backend was last promoted 2026-07-12 01:16; the offending commit landed 07-13 16:54, so this is live on
main/dev (and the beta lane), not on prod — the watchdog's auto-merge gate requires live prod impact. Landing this before the nextdesktop_promote_prodrun keeps it from ever reaching prod users.🤖 automated by hourly watchdog; opened for review, not merged.