claude: log the cache split per call
A cache hit and a short prompt are indistinguishable from outside; this provider logged nothing per request at all, which is how an uncached bridge went unnoticed across 93 turns.
This commit is contained in:
parent
a10ef5e3ed
commit
dfc89d09ea
1 changed files with 14 additions and 1 deletions
|
|
@ -379,7 +379,20 @@ impl LlmProvider for ClaudeSubscriptionProvider {
|
|||
let status = resp.status();
|
||||
if status.is_success() {
|
||||
let text = resp.text().await.context("reading claude response body")?;
|
||||
return parse_completion(&text).map(|r| (r, strain));
|
||||
let result = parse_completion(&text)?;
|
||||
if let Some(usage) = &result.usage {
|
||||
// Without this the cache is invisible: a hit and a short
|
||||
// prompt look identical from the outside.
|
||||
info!(
|
||||
model = %model,
|
||||
prompt = usage.prompt_tokens,
|
||||
cache_read = usage.cache_read_tokens,
|
||||
cache_write = usage.cache_write_tokens,
|
||||
output = usage.completion_tokens,
|
||||
"claude usage"
|
||||
);
|
||||
}
|
||||
return Ok((result, strain));
|
||||
}
|
||||
|
||||
let body_text = resp.text().await.unwrap_or_default();
|
||||
|
|
|
|||
Loading…
Reference in a new issue