Version
7.25.0
Steps to Reproduce
PostHog/posthog#71323 adds separate token fields for Anthropic's 5-minute and 1-hour cache writes. I checked each Python integration to see whether that breakdown reaches ingestion.
Two paths currently lose it:
- The LangChain callback reads the aggregate cache-write count but ignores
ephemeral_5m_input_tokens and ephemeral_1h_input_tokens from usage_metadata.input_token_details.
- The Claude Agent SDK processor copies aggregate usage fields but discards the nested
cache_creation object.
For example, pass this synthetic usage payload through the LangChain callback:
{
"input_tokens": 800,
"output_tokens": 50,
"input_token_details": {
"cache_read": 200,
"cache_creation": 0,
"ephemeral_5m_input_tokens": 300,
"ephemeral_1h_input_tokens": 200,
},
}
Expected Result
The resulting $ai_generation event keeps the aggregate and the complete TTL pair:
$ai_cache_creation_input_tokens = 500
$ai_cache_creation_5m_input_tokens = 300
$ai_cache_creation_1h_input_tokens = 200
For this LangChain payload, normalized uncached input is 100: 800 - 200 cache reads - 500 cache writes.
Native PostHog Anthropic clients, including the Bedrock and Vertex wrappers, already preserve the official nested breakdown in $ai_usage; the server PR can extract it. LangGraph uses the same PostHog LangChain callback, so it is covered by the callback fix.
Actual Result
The LangChain path emits an aggregate value of zero, omits both TTL fields, and leaves the 500 cache-write tokens in normalized input. The Claude Agent SDK path emits only its aggregate cache-write value.
The SDK follow-up should fix those loss points, retain aggregate-only behavior, and keep malformed or unavailable TTL data on the existing fallback. Direct boto3/OTel traffic is not included: PostHog Python does not wrap that client, and current instrumentation does not expose the TTL split.
This issue is the Python SDK follow-up to PostHog/posthog#71306 and PostHog/posthog#71323. The companion PR should remain draft until the server-side interface is merged.
Version
7.25.0
Steps to Reproduce
PostHog/posthog#71323 adds separate token fields for Anthropic's 5-minute and 1-hour cache writes. I checked each Python integration to see whether that breakdown reaches ingestion.
Two paths currently lose it:
ephemeral_5m_input_tokensandephemeral_1h_input_tokensfromusage_metadata.input_token_details.cache_creationobject.For example, pass this synthetic usage payload through the LangChain callback:
{ "input_tokens": 800, "output_tokens": 50, "input_token_details": { "cache_read": 200, "cache_creation": 0, "ephemeral_5m_input_tokens": 300, "ephemeral_1h_input_tokens": 200, }, }Expected Result
The resulting
$ai_generationevent keeps the aggregate and the complete TTL pair:For this LangChain payload, normalized uncached input is
100:800 - 200 cache reads - 500 cache writes.Native PostHog Anthropic clients, including the Bedrock and Vertex wrappers, already preserve the official nested breakdown in
$ai_usage; the server PR can extract it. LangGraph uses the same PostHog LangChain callback, so it is covered by the callback fix.Actual Result
The LangChain path emits an aggregate value of zero, omits both TTL fields, and leaves the 500 cache-write tokens in normalized input. The Claude Agent SDK path emits only its aggregate cache-write value.
The SDK follow-up should fix those loss points, retain aggregate-only behavior, and keep malformed or unavailable TTL data on the existing fallback. Direct
boto3/OTel traffic is not included: PostHog Python does not wrap that client, and current instrumentation does not expose the TTL split.This issue is the Python SDK follow-up to PostHog/posthog#71306 and PostHog/posthog#71323. The companion PR should remain draft until the server-side interface is merged.