Skip to content

fix: accept vLLM created_cache_tokens in chat usage - #2994

Closed
berlineric wants to merge 1 commit into
theagentrouter:mainfrom
berlineric:fix/vllm-created-cache-tokens
Closed

berlineric wants to merge 1 commit into
theagentrouter:mainfrom
berlineric:fix/vllm-created-cache-tokens

Conversation

@berlineric

Copy link
Copy Markdown

Description

OpenAI-compatible vLLM backends can report prompt cache writes as usage.prompt_tokens_details.created_cache_tokens. PromptTokensDetails currently accepts cache_write_tokens and cache_creation_input_tokens, so these cache writes are not captured in gateway accounting.

Accept created_cache_tokens through the existing CacheWriteTokensValue accessor. Preserve the existing greatest-value normalization across aliases without summing duplicate counts. Keep outgoing JSON normalized to the existing official/legacy fields.

The shared accessor is used by streaming and non-streaming chat completion translators. Add schema tests and translator tests for cold prompts, warm prompts, and overlapping aliases.

Validation

  • go test ./internal/apischema/openai ./internal/translator -count=1 passed.
  • git diff --check passed.
  • make precommit attempted; blocked at API documentation generation with make: go: Permission denied. Draft until the full precommit gate is resolved. Unrelated generated changes were discarded.
  • No deployed gateway images or cluster configurations changed.

AI Assistance

GitHub Copilot assisted with implementation and regression tests.

Release Notes

Accept vLLM created_cache_tokens usage as cache-write accounting in OpenAI-compatible chat responses.

Signed-off-by: Erik Berlin <eberlin@habana.ai>
@netlify

netlify Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for theagentrouter canceled.

Name Link
🔨 Latest commit a4c2686
🔍 Latest deploy log https://app.netlify.com/projects/theagentrouter/deploys/6af04418f938d9fb085ac06c

@berlineric

Copy link
Copy Markdown
Author

Withdrawing this draft: the requesting deployment now needs only cached_tokens/cache-read accounting and does not need the proposed cache-creation alias support.

@berlineric berlineric closed this Nov 8, 2026
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