Skip to content

fix(langchain): capture cached tokens for OpenAI service tiers - #1207

Closed
darylaw-bt wants to merge 1 commit into
mainfrom
darylaw/fix-langchain-tier-cache-read
Closed

darylaw-bt wants to merge 1 commit into
mainfrom
darylaw/fix-langchain-tier-cache-read

Conversation

@darylaw-bt

Copy link
Copy Markdown

Summary

  • Record prompt_cached_tokens from LangChain’s priority_cache_read and flex_cache_read fields when cache_read is missing.
  • Preserve an explicit cache_read=0 and keep the reported prompt and total token counts intact.

Validation

  • The synthetic LangChain callback repro now reports 1,024 cached tokens for each of the three input keys.
  • The LangChain suite passed 21 tests each on latest and 0.3.28, including the recorded Flex response and the new regression cases.
  • Both Deep Agents cassette replay sessions passed, and the cassette usage report found no unused LangChain recordings.

@AbhiPrasad

Abhijeet Prasad (AbhiPrasad) commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

opened #1213 to fix this. It addresses some extra testing considerations. Closing this PR as a result. Thanks darylaw-bt!

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.

2 participants