Skip to content

feat(ai): restore promptCaching support for Anthropic and OpenAI caching stats#1855

Merged
nmaguiar merged 4 commits into
masterfrom
feat/restore-prompt-caching
Jun 26, 2026
Merged

feat(ai): restore promptCaching support for Anthropic and OpenAI caching stats#1855
nmaguiar merged 4 commits into
masterfrom
feat/restore-prompt-caching

Conversation

@nmaguiar

Copy link
Copy Markdown
Collaborator

Summary

  • Restores promptCaching option for the Anthropic provider in ow.ai.gpt, enabling Anthropic's prompt caching beta (anthropic-beta: prompt-caching-2024-07-31) with cache_control markers on system prompts and the last user message
  • Restores OpenAI stats capture for prompt_tokens_details.cached_tokens, audio_tokens, and completion_tokens_details.reasoning_tokens
  • Restores 3 unit tests: testAIOpenAIStatsCaptureIncludesCachedAndReasoning, testAIAnthropicPromptCachingHeaders, testAIAnthropicPromptCachingBodyAndStats

This feature was originally added via PR #1841 and reverted in PR #1843. It has been live in the t8 branch (via PR #1844) and this PR cherry-picks the same 4 implementation commits onto master.

Test plan

  • Run tests/autoTestAll.AI.js — all 3 new tests should pass
  • Verify ow.ai.gpt("anthropic", { promptCaching: true }) adds anthropic-beta header to requests
  • Verify getLastStats() returns tokens.cacheCreation and tokens.cacheRead for Anthropic responses

🤖 Generated with Claude Code

Copilot AI and others added 4 commits June 26, 2026 14:29
Agent-Logs-Url: https://github.com/OpenAF/openaf/sessions/62a5d58d-75bd-4f94-a820-746c4b047a40

Co-authored-by: nmaguiar <11761746+nmaguiar@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OpenAF/openaf/sessions/62a5d58d-75bd-4f94-a820-746c4b047a40

Co-authored-by: nmaguiar <11761746+nmaguiar@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OpenAF/openaf/sessions/62a5d58d-75bd-4f94-a820-746c4b047a40

Co-authored-by: nmaguiar <11761746+nmaguiar@users.noreply.github.com>
@nmaguiar nmaguiar merged commit 455ab6a into master Jun 26, 2026
1 check passed
@nmaguiar nmaguiar deleted the feat/restore-prompt-caching branch June 26, 2026 13:31
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