Skip to content

fix(llm): carry the cache-write TTL split from Anthropic message_start usage - #4

Merged
danielzarioiu merged 1 commit into
synapse/v1.6.0-compat1from
feat/cache-write-ttl-split-streaming
Oct 10, 2026
Merged

danielzarioiu merged 1 commit into
synapse/v1.6.0-compat1from
feat/cache-write-ttl-split-streaming

Conversation

@danielzarioiu

Copy link
Copy Markdown
Member

Follow-up to #3, driven by the RC2 production canary: the terminal message_delta usage carries NO cache_creation split on the real Anthropic streaming wire — the split is reported at message_start (input-side usage final; production probe aggregate 67759 with {5m: 67759, 1h: 0}).

Forwards the split from message_start in both streaming converters; the terminal delta wins when it carries a split and no longer clobbers start evidence when it does not. Evidence-safety: captured production usage shows a small aggregate with an all-zero split (sub-minimum no-op cache writes) — forwarded as authoritative Some(0)/Some(0) rather than gated to unknown, which would flood cache_write_ttl_ambiguous fail-closed noise for every sub-minimum cache_control marker; matches what the provider actually bills. Buffered semantics unchanged (bc74277). Goldens gain exactly the two evidence fields (per-diff verified). agent-llm 427/427, agentgateway 2229/2229, fmt+clippy clean.

…t usage

RC2 production canary proved the terminal message_delta usage carries NO
cache_creation split on the real Anthropic streaming wire — the CLI-visible
split (production probe: aggregate 67759 with {5m: 67759, 1h: 0}) is reported
at message_start, where input-side usage is final. RC2's delta-only read
therefore still left streaming writes TTL-ambiguous.

- passthrough + translation MessageStart handlers now forward
  usage.cache_creation into evidence; the terminal MessageDelta still wins
  when IT carries a split, and no longer clobbers start evidence when it
  does not.
- Evidence-safety note replacing the earlier consistency-guard idea:
  captured production usage shows a small aggregate alongside an all-zero
  split (stream_basic: aggregate 13, thinking: aggregate 1). That shape is
  the provider's authoritative sub-minimum no-op write evidence — the
  classes are authoritative and the residual aggregate meters at zero.
  Gating it to unknown would flood cache_write_ttl_ambiguous fail-closed
  noise for every sub-minimum cache_control marker; forwarding it matches
  what the provider actually bills. The four anthropic streaming goldens
  gain exactly the two evidence fields with 0 values (verified per-diff).
- buffered cache_ttl_split keeps bc74277 semantics (no guard).

agent-llm 427/427 (423 + 4), agentgateway 2229/2229, fmt + clippy clean.
@danielzarioiu
danielzarioiu merged commit 6a82e01 into synapse/v1.6.0-compat1 Oct 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant