mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #107] [MERGED] serve: report cached prompt tokens, llama.cpp timings and GET /v1/status #2460
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#2460
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/107
Author: @architectds
Created: 9/29/2026
Status: ✅ Merged
Merged: 9/29/2026
Merged by: @Niko1221
Base:
main← Head:api-status📝 Commits (1)
28e6c8eserve: report the cached prompt tokens, llama.cpp timings and GET /v1/status📊 Changes
2 files changed (+188 additions, -7 deletions)
View changed files
📝
serve/server.py(+85 -7)📝
serve/test_server.py(+103 -0)📄 Description
The conversation cache reuses prompt prefixes, and
/metricsalready records the reuse per request. But the chat APIs don't report it, so clients show a cached prompt as 0% cached. Front-ends that read speed from llama.cpp'stimingsshow nothing.This PR adds the missing fields and changes nothing else in the replies:
OpenAI (
/v1/chat/completions):usage.prompt_tokens_details.cached_tokensis the part of the prompt the conversation cache held. It's on the last streamed chunk and on a whole reply.Anthropic (
/v1/messages): the finalusagesplitsinput_tokensfromcache_read_input_tokens, the way Anthropic's API counts them. That's the stream'smessage_deltaand a whole reply.message_startstill carries the whole prompt, the only count known before the engine reads it.llama.cpp's
timingsgo on the last chunk and on a whole reply:prompt_n,cache_n,prompt_ms,prompt_per_second,predicted_n,predicted_ms,predicted_per_secondand the per-token ms. They come from the engine's own clock, the same numbers/metricsshows.GET /v1/statusis a small read-only summary for front-ends that poll their server rather than guess. It's behind the API key when one is set. It gives:The Monitor's
/metricsis unchanged.An engine without a clock (the mock engine) reports no
timingsand 0 cached tokens.Tested:
python -m unittest serve.test_server serve.test_mcppasses. The newUsageAndStatusclass covers both APIs, streaming,/v1/statusand the no-clock case.cached_tokens: 2784, withtimingscache_n: 2784, prompt_n: 20;/v1/statusfor its speed panel and for image upload.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
__shared__ alignas(16) int4does not compile (clang 18 / ROCm 6.3.3) #4441__shared__ alignas(16) int4does not compile (clang 18 / ROCm 6.3.3) #4923