fix(proxy): include zero usage in final message delta#2485
Conversation
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@claude review |
|
Claude finished @farion1231's task in 1m 51s —— View job Code Review
File: SummaryThe PR introduces two helper functions ( Positive Observations
Issues and Observations1. Semantic ambiguity: zero tokens vs. unknown usage
fn default_anthropic_usage_json() -> Value {
// Upstream did not report usage; fall back to zeros to satisfy the protocol.
log::debug!("[Claude/OpenRouter] No usage in stream; emitting zero-usage fallback");
json!({ "input_tokens": 0, "output_tokens": 0 })
}2. The
// Lines 123-125
let usage = usage_json
.filter(|usage| usage.is_object()) // <- always true in practice
.unwrap_or_else(default_anthropic_usage_json);3. The stream tracks if let Some(usage_json) = &chunk_usage_json {
latest_usage = Some(usage_json.clone());
if let Some((_, pending_usage)) = pending_message_delta.as_mut() {
*pending_usage = Some(usage_json.clone());
}
}This only updates 4. Test model name is fictional Minor: the test uses Overall AssessmentThe fix is correct for its stated goal and the refactoring is solid. Issues 1 and 4 are minor/informational. Issue 2 is a dead-code nitpick. Issue 3 is a pre-existing edge case worth being aware of but is out of scope for this PR. The PR is good to merge. Issues 1 and 3 could be addressed as follow-up if needed. |
|
@claude review (Re-running with the updated review prompt for comparison.) |
|
Claude finished @farion1231's task in 1m 5s —— View job Code Review (re-run with updated prompt)
LGTM. Small, well-scoped change: extracts No blocking issues found under the strict criteria. Items raised in the prior re-review (zero-vs-unknown semantics, the always-true |
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
farion1231
left a comment
There was a problem hiding this comment.
Thank you for your contribution!
Summary
message_deltaevents always include ausageobject.Test plan
cargo test --manifest-path src-tauri/Cargo.toml test_message_delta_includes_zero_usage_when_stream_has_no_usage