Skip to content

Keep fallback retrieval failures distinct from empty results - #850

Merged
WaylandYang merged 3 commits into
deeplethe:devfrom
Maya-Kid:fix/chat-fallback-retrieval-errors
Sep 21, 2026
Merged

WaylandYang merged 3 commits into
deeplethe:devfrom
Maya-Kid:fix/chat-fallback-retrieval-errors

Conversation

@Maya-Kid

@Maya-Kid Maya-Kid commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Latest dev synchronization (2026-09-21)

Based on dev@474b904dc3e8014d42404a3c067af9906036a953; current head 5071b883b7fcfcfe6a745e49dd788817a5ed42ac.

Revalidated the combined integration tree 6cd976351b4d7cc7389730fce530526f4d197992 on isolated Linux PostgreSQL fixtures (all 675 tracked source files hash-matched):

The evidence-only handoff core remains frozen. Earlier validation below belongs to its stated historical heads. Automated browser checks do not replace the maintainer's requested visual review.


When a provider rejects tool calling, legacy_rag currently converts any retrieval error into an empty result and requests an ordinary answer. A database failure can therefore look like missing evidence and end with done.

Handle retrieval errors explicitly: log the diagnostic server-side, send the existing safe error event, and stop before requesting or saving a fallback answer. Successful empty retrieval and embedding-to-BM25 degradation keep their existing behavior.

Linux validation against an isolated migrated PostgreSQL database, using real Chat handlers and a local HTTP model substitute:

  • Reproduced the original false-success path by closing the fixture's database pool only after the initial tool request reached the upstream. Authentication/settings and user persistence had already succeeded; fallback retrieval then returned a real database access error. The original code still requested and streamed a plain answer with done; the fix emits error, sends no plain-model request, and stores no assistant answer.
  • Four new regressions pass: retrieval failure, genuinely empty search, failed embedding with a real BM25 hit, and provider 401/402/429/500 errors. Assertions include the existing two-request compatibility negotiation for 400/422.
  • Formatting, strict workspace clippy, all 14 Chat tests and all 6 retrieval tests pass with UTOPIA_TEST_REQUIRE_DB=1. CI adds the guarded fallback regressions to the PostgreSQL job.

No paid endpoint or business data was used. The change does not alter fallback eligibility, retrieval ranking, the empty-result prompt, persistence policy, or #845's finalization boundary. Client EOF semantics are a separate workstream; this PR guarantees the server emits an error without a success terminal.

Signed-off-by: dada-yan <BinjunYann@gmail.com>
Signed-off-by: dada-yan <BinjunYann@gmail.com>
@Maya-Kid
Maya-Kid force-pushed the fix/chat-fallback-retrieval-errors branch from 03d5af4 to 5071b88 Compare September 21, 2026 10:25
# Conflicts:
#	crates/utopia-server/src/api/chat_empty_reply_tests.rs
@WaylandYang
WaylandYang merged commit f6ce402 into deeplethe:dev Sep 21, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants