Skip to content

Python SDK for AI agent monitoring, LLM cost tracking, benchmarking, and more. Integrates with most LLMs and agent frameworks including CrewAI, Agno, OpenAI Agents SDK, Langchain, Autogen, AG2, and CamelAI

Fix token counts in OpenAI Agents redux (#890)

Travis Dent14c4a3678d90
diff --git a/agentops/instrumentation/openai_agents/attributes/response.py b/agentops/instrumentation/openai_agents/attributes/response.py
index 62a62b90..def98b56 100644
--- a/agentops/instrumentation/openai_agents/attributes/response.py
+++ b/agentops/instrumentation/openai_agents/attributes/response.py
@@ -294,6 +294,10 @@ def get_response_usage_attributes(usage: 'ResponseUsage') -> AttributeMap:
# )
attributes = {}
+ attributes.update(_extract_attributes_from_mapping(
+ usage.__dict__,
+ RESPONSE_USAGE_ATTRIBUTES))
+
# input_tokens_details is a dict if it exists
if hasattr(usage, 'input_tokens_details'):
input_details = usage.input_tokens_details