Skip to content

bugfix: expose prefix cache usage in responses#80

Draft
bupt-ycq wants to merge 1 commit into
xLLM-AI:mainfrom
bupt-ycq:main
Draft

bugfix: expose prefix cache usage in responses#80
bupt-ycq wants to merge 1 commit into
xLLM-AI:mainfrom
bupt-ycq:main

Conversation

@bupt-ycq

Copy link
Copy Markdown

Summary

  • propagate prefix-cache token counts from RPC OutputUsage into the internal usage model
  • expose usage.prompt_tokens_details.cached_tokens in streaming and non-streaming OpenAI responses
  • centralize RPC output conversion and OpenAI usage serialization, with regression coverage

Why

Prefix-cache token counts were dropped while converting RPC generation results into the service's internal usage model. As a result, OpenAI-compatible responses could not report how many prompt tokens were served from the prefix cache.

User impact

Clients can now observe prefix-cache effectiveness through usage.prompt_tokens_details.cached_tokens. The field is present with 0 when no prompt tokens were cached.

Tests

  • cmake --build build --target response_handler_usage_test xllm_rpc_service_test -j2
  • build/tests/xllm_service/scheduler/response_handler_usage_test (2 tests passed)
  • build/xllm_service/rpc_service/xllm_rpc_service_test (2 tests passed)

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

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