You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Preserves the one-hour cache-write token subset in libsy.client_call observability and forwards it through the Switchyard NeMo Relay plugin.
Why
Switchyard already retains ephemeral_1h_input_tokens internally, but libsy observability exported only the combined cache-creation count. Relay therefore could not distinguish five-minute and one-hour cache writes for precise pricing.
This is an accounting-only change. It does not alter request construction, cache TTL selection, routing, or model behavior.
Notes for reviewers
Start with:
crates/libsy-llm-client/src/observability.rs for the new span attribute.
crates/switchyard-nemo-relay-plugin/src/span_capture.rs for Relay forwarding.
Focused libsy observability and Relay plugin tests cover propagation of a mixed cache-write split. Existing responses without the optional one-hour field retain their current behavior
Summary by CodeRabbit
New Features
Usage reporting now includes a separate count of input tokens used to create a one-hour cache, when that count is available. This value is preserved independently from total input tokens and other cache usage counts, making usage details more informative without changing how existing token counts are calculated.
The client now records optional one-hour cache-creation input tokens in tracing. The relay captures the field as ephemeral one-hour cache usage. Tests check the recorded value, the relay mapping, and the input-token calculation.
Changes
One-hour cache token usage
Layer / File(s)
Summary
Record one-hour cache usage crates/libsy-llm-client/src/observability.rs, crates/libsy-llm-client/src/run.rs, crates/libsy-llm-client/tests/observability.rs
The client records the optional one-hour cache-creation token count as gen_ai.usage.cache_creation_1h.input_tokens. The observability test checks that the span contains the value.
Map cache usage to response crates/switchyard-nemo-relay-plugin/src/span_capture.rs
The relay allowlists the tracing field and maps it to usage.cache_creation.ephemeral_1h_input_tokens. The test checks that this value is kept separate while the input-token count excludes cache-read and standard cache-creation tokens.
This change exposes one-hour cache-write counts in observability and forwards them to Relay without altering requests or routing. Cost estimates will not separate five-minute and one-hour writes until the Relay dependency reads the new field; that is a follow-up and does not block merging.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title clearly and concisely describes the main change: exposing one-hour cache writes in observability.
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage
Explanation
Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 4 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
A rabbit checks the tracing stream, One-hour tokens join the scheme. The relay keeps their count in view, While input totals stay true. Then hops away beneath the moon.
Comment @coderabbitai help to get the list of available commands.
187-190: Major · Data Integrity & Integration · Heavy lift
Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Preserve the split through Relay pricing.
Relay 0.10.0’s RawAnthropicUsage does not read cache_creation, and its pricing code applies one rate to all cache writes. Mixed five-minute and one-hour writes therefore still receive a single-rate estimate. (raw.githubusercontent.com)
Coordinate Relay codec and pricing support, and add an integration test that checks the resulting cost.
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
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
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.
What
Preserves the one-hour cache-write token subset in
libsy.client_callobservability and forwards it through the Switchyard NeMo Relay plugin.Why
Switchyard already retains
ephemeral_1h_input_tokensinternally, but libsy observability exported only the combined cache-creation count. Relay therefore could not distinguish five-minute and one-hour cache writes for precise pricing.This is an accounting-only change. It does not alter request construction, cache TTL selection, routing, or model behavior.
Notes for reviewers
Start with:
crates/libsy-llm-client/src/observability.rsfor the new span attribute.crates/switchyard-nemo-relay-plugin/src/span_capture.rsfor Relay forwarding.Focused libsy observability and Relay plugin tests cover propagation of a mixed cache-write split. Existing responses without the optional one-hour field retain their current behavior
Summary by CodeRabbit