@@ -136,7 +136,7 @@ def test_langchain_create_agent(
136136 )
137137 events = capture_events ()
138138
139- model_repsonse = get_model_response (
139+ model_response = get_model_response (
140140 nonstreaming_responses_model_response ,
141141 serialize_pydantic = True ,
142142 request_headers = {
@@ -160,7 +160,7 @@ def test_langchain_create_agent(
160160 with patch .object (
161161 llm .client ._client ._client ,
162162 "send" ,
163- return_value = model_repsonse ,
163+ return_value = model_response ,
164164 ) as _ :
165165 with start_transaction ():
166166 agent .invoke (
@@ -179,12 +179,9 @@ def test_langchain_create_agent(
179179 assert len (chat_spans ) == 1
180180 assert chat_spans [0 ]["origin" ] == "auto.ai.langchain"
181181
182- # Token usage is only available in newer versions of langchain (v0.2+)
183- # where usage_metadata is supported on AIMessageChunk
184- if "gen_ai.usage.input_tokens" in chat_spans [0 ]["data" ]:
185- assert chat_spans [0 ]["data" ]["gen_ai.usage.input_tokens" ] == 10
186- assert chat_spans [0 ]["data" ]["gen_ai.usage.output_tokens" ] == 20
187- assert chat_spans [0 ]["data" ]["gen_ai.usage.total_tokens" ] == 30
182+ assert chat_spans [0 ]["data" ]["gen_ai.usage.input_tokens" ] == 10
183+ assert chat_spans [0 ]["data" ]["gen_ai.usage.output_tokens" ] == 20
184+ assert chat_spans [0 ]["data" ]["gen_ai.usage.total_tokens" ] == 30
188185
189186 if send_default_pii and include_prompts :
190187 assert (
0 commit comments