The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(relay): native Anthropic stream spans keep their input and cache token counts
kshitijk4poor3fc3caeb98e0
diff --git a/agent/relay_llm.py b/agent/relay_llm.pyindex 85f52be2587..270cbc9a66f 100644--- a/agent/relay_llm.py+++ b/agent/relay_llm.py@@ -648,7 +648,9 @@ class AnthropicStreamAccumulator:if "usage" in payload:usage, current_usage = payload["usage"], self._message.get("usage")if isinstance(current_usage, dict) and isinstance(usage, dict):- usage = {**current_usage, **usage}+ # The SDK's MessageDeltaUsage serializes unset fields as null; they must not+ # erase message_start's input/cache counts.+ usage = {**current_usage, **{k: v for k, v in usage.items() if v is not None}}self._message["usage"] = usage_EVENT_HANDLERS = {