fix(ai): preserve Anthropic cache-write TTL breakdowns#746
Open
gouveags wants to merge 1 commit into
Open
Conversation
This was referenced Jul 16, 2026
Author
|
@greptile review |
Contributor
|
Reviews (1): Last reviewed commit: "fix(ai): preserve Anthropic cache-write ..." | Re-trigger Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
This PR depends on PostHog/posthog#71323 and will remain a draft until the server-side event contract is merged.
💡 Motivation and Context
PostHog/posthog#71323 adds separate costing for Anthropic's 5-minute and 1-hour cache writes. The Python SDK already preserves that breakdown in its native Anthropic wrappers, but two integrations drop it before ingestion.
Fixes #745. Related to PostHog/posthog#71306. Depends on PostHog/posthog#71323.
This change:
The PostHog Bedrock and Vertex clients reuse the native Anthropic message adapters. Aggregate-only events remain unchanged; invalid or empty TTL details fall back to the aggregate, and a valid breakdown replaces rather than adds to it.
Direct
boto3calls are outside this PR becauseposthog-pythonhas no boto3 Bedrock wrapper. The OTel integration forwards spans through a separate endpoint and is not changed.💚 How did you test it?
1629 passed, 59 skipped.135 passed, 9 skipped.📝 Checklist
If releasing new changes
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
I used Codex to inspect the server contract, audit the Python SDK integration paths, implement the focused changes, and run independent test, code, and writing reviews. No public session link is available.
The first pass focused on the LangChain callback. The broader audit showed that native Anthropic wrappers already preserve raw usage, while Claude Agent needed the same raw-usage path. The final diff reuses those existing mechanisms instead of adding provider pricing or a new integration layer.