Skip to content

feat(llm): add best-seen response tracking to cascade_chat_stream#1753

Merged
bug-ops merged 1 commit intomainfrom
feat-llm-cascade-chat-stream-b
Mar 14, 2026
Merged

feat(llm): add best-seen response tracking to cascade_chat_stream#1753
bug-ops merged 1 commit intomainfrom
feat-llm-cascade-chat-stream-b

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

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

Summary

  • Adds best_seen: Option<(String, f64)> accumulation in cascade_chat_stream's early-provider loop, mirroring the existing cascade_chat behavior introduced in feat(llm): cascade routing — try cheap provider first, escalate on degenerate output #1721
  • On budget exhaustion with should_escalate=true, returns the highest-scoring prior response instead of the current provider's response
  • On last-provider stream error, returns best_seen if available rather than propagating the error

Test plan

  • cascade_stream_budget_returns_best_seen — budget exhausts in early loop, best_seen returned
  • cascade_stream_budget_returns_best_seen_not_current — 4 providers, budget=17 tokens, p1 (16t) < p2 (1t) → p1 returned over p2 at exhaustion
  • cascade_stream_last_fails_returns_best_seen — last provider errors, best_seen from early providers returned
  • cascade_stream_all_fail_returns_error — no best_seen accumulated, error propagated

All 5431 tests pass.

Closes #1722.

@github-actions github-actions bot added enhancement New feature or request documentation Improvements or additions to documentation llm zeph-llm crate (Ollama, Claude) rust Rust code changes size/M Medium PR (51-200 lines) and removed enhancement New feature or request labels Mar 14, 2026
cascade_chat_stream now accumulates best_seen: Option<(String, f64)> in
the early-provider loop, mirroring the existing cascade_chat behavior.

On budget exhaustion (should_escalate=true), returns the highest-scoring
prior response instead of the current one. On last-provider stream error,
returns best_seen if available rather than propagating the error.

Closes #1722.
@bug-ops bug-ops force-pushed the feat-llm-cascade-chat-stream-b branch from 9a8fd51 to 99bcdc5 Compare March 14, 2026 15:44
@bug-ops bug-ops enabled auto-merge (squash) March 14, 2026 15:44
@github-actions github-actions bot added the enhancement New feature or request label Mar 14, 2026
@bug-ops bug-ops merged commit 7f0bf99 into main Mar 14, 2026
15 checks passed
@bug-ops bug-ops deleted the feat-llm-cascade-chat-stream-b branch March 14, 2026 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request 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.

feat(llm): cascade_chat_stream best-seen response tracking

1 participant