fix(llm): skip empty string responses in cascade best-seen tracking#1758
Merged
fix(llm): skip empty string responses in cascade best-seen tracking#1758
Conversation
Guard the best_seen update in both cascade_chat and cascade_chat_stream: only store a provider response if it is non-empty. An empty string scored at 0.0 could become best_seen and be silently returned on all-fail fallback, giving the caller a worse outcome than an explicit error. Add three regression tests covering: cascade_chat with single empty provider, cascade_chat where empty best_seen must not be returned on all-fail, and cascade_chat_stream where an empty early-provider response must not shadow the last provider's real response. Closes #1754
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
best_seenupdate incascade_chatandcascade_chat_stream: only store a response if!response.is_empty()/!text.is_empty()0.0could silently becomebest_seenand be returned on all-fail fallback, giving the caller a worse outcome than an explicit errorcascade_chat, empty best-seen not returned on all-fail, stream variant with empty early providerCloses #1754
Test plan
cargo nextest run --config-file .github/nextest.toml -p zeph-llm --features full --lib— all existing + 3 new tests passcargo clippy --workspace --features full -- -D warnings— no warningscargo +nightly fmt --check— clean