The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(agent): fall back to messages.create on Anthropic stream usage aggregation errors
hejuntt1014d26909c99e16
diff --git a/agent/anthropic_adapter.py b/agent/anthropic_adapter.pyindex 98fc1ba8183..8efe353a66f 100644--- a/agent/anthropic_adapter.py+++ b/agent/anthropic_adapter.py@@ -717,6 +717,15 @@ def _is_stream_unavailable_error(exc: Exception) -> bool:return Trueif "unexpected event order" in err_lower:return True+ # Anthropic SDK accumulate_event() assumes message_start carried a usage+ # object; some Anthropic-compatible providers (e.g. MiniMax api.minimaxi.com)+ # emit usage: null on message_start and only populate it on message_delta,+ # so get_final_message() raises AttributeError on output_tokens (#60683).+ if isinstance(exc, AttributeError):+ if "output_tokens" in err_lower:+ return True+ if "nonetype" in err_lower and "usage" in err_lower:+ return Trueif "invokemodelwithresponsestream" not in err_lower:return Falsefrom agent.bedrock_adapter import is_streaming_access_denied_error