Roo-Code/src
Hannes Rudolph d1baa6e849
fix: add cache reporting support for OpenAI-Native provider (#7602)
* fix: add cache reporting support for OpenAI-Native provider

- Add normalizeUsage method to properly extract cache tokens from Responses API
- Support both detailed token shapes (input_tokens_details) and legacy fields
- Calculate cache read/write tokens with proper fallbacks
- Include reasoning tokens when available in output_tokens_details
- Ensure accurate cost calculation using uncached input tokens

This fixes the issue where caching information was not being reported
when using the OpenAI-Native provider with the Responses API.

* fix: improve cache token normalization and add comprehensive tests

- Add fallback to derive total input tokens from details when totals are missing
- Remove unused convertToOpenAiMessages import
- Add comment explaining cost calculation alignment with Gemini provider
- Add comprehensive test coverage for normalizeUsage method covering:
  - Detailed token shapes with cached/miss tokens
  - Legacy field names and SSE-only events
  - Edge cases including missing totals with details-only
  - Cost calculation with uncached input tokens

* fix: address PR review comments

- Remove incorrect fallback to missFromDetails for cache write tokens
- Fix cost calculation to pass total input tokens (calculateApiCostOpenAI handles subtraction)
- Improve readability by extracting cache detail checks to intermediate variables
- Remove redundant ?? undefined
- Update tests to reflect correct behavior (miss tokens are not cache writes)
- Add clarifying comments about cache miss vs cache write tokens
2025-09-02 19:59:16 -04:00
..
__mocks__ feature: add toggle for disable mcp server tool from prompt (#3551) 2025-06-20 19:14:59 -04:00
__tests__ Move @roo-code/cloud to the Roo-Code repo (#7503) 2025-08-28 11:18:45 -07:00
activate feat: rename Account tab to Cloud tab (#7558) 2025-08-30 18:57:00 -04:00
api fix: add cache reporting support for OpenAI-Native provider (#7602) 2025-09-02 19:59:16 -04:00
assets PNPM + Turbo monorepo + Nightly releases (#3407) 2025-05-21 21:01:20 -07:00
core Cloud: fix provider syncing (#7603) 2025-09-02 15:18:21 -07:00
extension Mode and provider profile selector (#7545) 2025-08-29 16:48:06 -07:00
i18n Add support for Vercel embeddings (#7445) 2025-08-27 13:30:19 -04:00
integrations Fix claudeCode.notFound translation key (#7571) 2025-09-01 08:53:14 -04:00
services feat: add configurable embedding batch size for code indexing (#7464) 2025-09-01 21:36:56 -04:00
shared feat: rename Account tab to Cloud tab (#7558) 2025-08-30 18:57:00 -04:00
utils fix: special tokens should not break task processing (#7540) 2025-08-30 10:40:40 -04:00
workers Count tokens worker (#3037) 2025-04-29 12:29:25 -07:00
.gitignore PNPM + Turbo monorepo + Nightly releases (#3407) 2025-05-21 21:01:20 -07:00
.prettierignore PNPM + Turbo monorepo + Nightly releases (#3407) 2025-05-21 21:01:20 -07:00
.vscodeignore debug: Add ErrorBoundary component for better error handling (#5085) 2025-07-23 08:45:35 -04:00
esbuild.mjs Revert "fix: optimize README for VS Code marketplace to prevent UI freezing" (#6303) 2025-07-28 14:31:01 -04:00
eslint.config.mjs Fix linter errors (#3821) 2025-05-21 23:16:43 -07:00
extension.ts Cloud: fix provider syncing (#7603) 2025-09-02 15:18:21 -07:00
package.json feat: add configurable embedding batch size for code indexing (#7464) 2025-09-01 21:36:56 -04:00
package.nls.ca.json feat: add configurable embedding batch size for code indexing (#7464) 2025-09-01 21:36:56 -04:00
package.nls.de.json feat: add configurable embedding batch size for code indexing (#7464) 2025-09-01 21:36:56 -04:00
package.nls.es.json feat: add configurable embedding batch size for code indexing (#7464) 2025-09-01 21:36:56 -04:00
package.nls.fr.json feat: add configurable embedding batch size for code indexing (#7464) 2025-09-01 21:36:56 -04:00
package.nls.hi.json feat: add configurable embedding batch size for code indexing (#7464) 2025-09-01 21:36:56 -04:00
package.nls.id.json feat: add configurable embedding batch size for code indexing (#7464) 2025-09-01 21:36:56 -04:00
package.nls.it.json feat: add configurable embedding batch size for code indexing (#7464) 2025-09-01 21:36:56 -04:00
package.nls.ja.json feat: add configurable embedding batch size for code indexing (#7464) 2025-09-01 21:36:56 -04:00
package.nls.json feat: add configurable embedding batch size for code indexing (#7464) 2025-09-01 21:36:56 -04:00
package.nls.ko.json feat: add configurable embedding batch size for code indexing (#7464) 2025-09-01 21:36:56 -04:00
package.nls.nl.json feat: add configurable embedding batch size for code indexing (#7464) 2025-09-01 21:36:56 -04:00
package.nls.pl.json feat: add configurable embedding batch size for code indexing (#7464) 2025-09-01 21:36:56 -04:00
package.nls.pt-BR.json feat: add configurable embedding batch size for code indexing (#7464) 2025-09-01 21:36:56 -04:00
package.nls.ru.json feat: add configurable embedding batch size for code indexing (#7464) 2025-09-01 21:36:56 -04:00
package.nls.tr.json feat: add configurable embedding batch size for code indexing (#7464) 2025-09-01 21:36:56 -04:00
package.nls.vi.json feat: add configurable embedding batch size for code indexing (#7464) 2025-09-01 21:36:56 -04:00
package.nls.zh-CN.json feat: add configurable embedding batch size for code indexing (#7464) 2025-09-01 21:36:56 -04:00
package.nls.zh-TW.json feat: add configurable embedding batch size for code indexing (#7464) 2025-09-01 21:36:56 -04:00
tsconfig.json Move @roo-code/cloud to the Roo-Code repo (#7503) 2025-08-28 11:18:45 -07:00
turbo.json Improve turbo task dependency declarations (#4323) 2025-06-04 09:32:27 -07:00
vitest.config.ts Show console logging in vitests when the --no-silent flag is set (#7467) 2025-08-28 12:51:21 -04:00
vitest.setup.ts Show console logging in vitests when the --no-silent flag is set (#7467) 2025-08-28 12:51:21 -04:00