Skip to content

fix(llm): skip empty string responses in cascade best-seen tracking#1758

Merged
bug-ops merged 2 commits intomainfrom
cascade-best-seen-empty-string
Mar 14, 2026
Merged

fix(llm): skip empty string responses in cascade best-seen tracking#1758
bug-ops merged 2 commits intomainfrom
cascade-best-seen-empty-string

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 14, 2026

Summary

  • Guard best_seen update in cascade_chat and cascade_chat_stream: only store a response if !response.is_empty() / !text.is_empty()
  • An empty string scored at 0.0 could silently become best_seen and be returned on all-fail fallback, giving the caller a worse outcome than an explicit error
  • Add three regression tests: single empty provider in cascade_chat, empty best-seen not returned on all-fail, stream variant with empty early provider

Closes #1754

Test plan

  • cargo nextest run --config-file .github/nextest.toml -p zeph-llm --features full --lib — all existing + 3 new tests pass
  • cargo clippy --workspace --features full -- -D warnings — no warnings
  • cargo +nightly fmt --check — clean

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
@github-actions github-actions bot added documentation Improvements or additions to documentation llm zeph-llm crate (Ollama, Claude) rust Rust code changes bug Something isn't working size/M Medium PR (51-200 lines) labels Mar 14, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 14, 2026 16:20
@bug-ops bug-ops merged commit 7466096 into main Mar 14, 2026
15 checks passed
@bug-ops bug-ops deleted the cascade-best-seen-empty-string branch March 14, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation llm zeph-llm crate (Ollama, Claude) rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(llm): cascade best-seen can capture empty string response

1 participant