fix(llm): return best_seen when escalations_remaining==0 and should_escalate#1759
Merged
fix(llm): return best_seen when escalations_remaining==0 and should_escalate#1759
Conversation
…scalate In both cascade_chat and cascade_chat_stream, the escalations_remaining==0 branch returned the current provider's response even when should_escalate was true. This ignored best_seen, potentially giving the caller a lower- quality response than an earlier provider had produced. Apply the same pattern already used for the budget-exhaustion branch: return best_seen.take().map_or(current, |(r, _)| r). Closes #1755.
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
cascade_chatandcascade_chat_stream, whenescalations_remaining == 0 && should_escalate, the current provider's response was returned instead ofbest_seen— discarding a potentially higher-quality earlier responsebest_seen.take().map_or(current, |(r, _)| r)cascade_escalations_exhausted_returns_best_seen_not_currentandcascade_stream_escalations_exhausted_returns_best_seen_not_current) verify the corrected behaviourTest plan
cargo nextest run --config-file .github/nextest.toml -p zeph-llm— all cascade tests pass, including the two new regression testscargo clippy --workspace --features full -- -D warnings— cleancargo +nightly fmt --check— cleanCloses #1755