Repository navigation
fix(codecs): keep Anthropic stream usage when message_delta reports null - #1778
Conversation
…delta fields Signed-off-by: Sakshi Tapkir <[email protected]>
Signed-off-by: Sakshi Tapkir <[email protected]>
|
No actionable comments were generated in the recent review. WalkthroughThe Anthropic streaming codec now preserves accumulated usage values when an update reports null fields. A regression test checks that non-null output token updates still replace the earlier value. ChangesAnthropic streaming usage
Estimated code review effort: 2 (Simple) | ~8 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk:
|
|
/ok to test 97c8c74 |
greysonlalonde
left a comment
There was a problem hiding this comment.
thank you @Sakshitapkir03 !
Overview
Skips
nullvalues when merging Anthropicmessage_deltausage into themessage_startusage, so a streamed call keeps its input and cache token counts when the terminal delta reports them asnull.Details
crates/core/src/codec/anthropic.rs:observe_usageskipsnullvalues when extending the accumulated usage; non-null values, including0, still replace earlier ones.crates/core/tests/unit/codec/anthropic_tests.rs: addanthropic_streaming_codec_keeps_message_start_usage_when_delta_reports_null.message_deltaonly when they are notNone.message_deltakeep the behavior from fix: preserve Anthropic usage across stream events #996.Tested on macOS, on
release/0.11atcf0712e5:left: Null,right: Number(10)) and passes with it.cargo nextest run -p nemo-relay -E 'test(~anthropic)': 89 passed.just test-rust: 6733 passed, 4 skipped (withulimit -n 4096, since test(cli): raise the open-file limit for HTTP/1.1 concurrency tests #1736 is onmainonly). One unrelated ATOF timing test,unanswered_http_post_requests_record_flush_and_close_timeouts, was flaky and passed on retry and when run alone.cargo fmt --all -- --checkandcargo clippy -p nemo-relay --all-targets -- -D warningspass.npm auditanduv audit, which I skipped; this change touches no lockfiles.Not tested on Linux or Windows; CI covers those.
Where should the reviewer start?
observe_usageincrates/core/src/codec/anthropic.rs.Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)
Closes #1775
Summary by CodeRabbit
null, while still applying non-null updates.