@@ -42,7 +42,6 @@ def wrapped_get_model(cls, agent, run_config):
4242 async def wrapped_fetch_response (* args , ** kwargs ):
4343 # type: (*Any, **Any) -> Any
4444 response = await original_fetch_response (* args , ** kwargs )
45- # Store model from raw response in context variable
4645 if hasattr (response , "model" ):
4746 agent ._sentry_raw_response_model = str (response .model )
4847 return response
@@ -55,7 +54,6 @@ async def wrapped_get_response(*args, **kwargs):
5554 with ai_client_span (agent , kwargs ) as span :
5655 result = await original_get_response (* args , ** kwargs )
5756
58- # Retrieve response model from context and attach to ModelResponse
5957 response_model = getattr (agent , "_sentry_raw_response_model" , None )
6058 if response_model :
6159 result ._sentry_response_model = response_model
@@ -66,6 +64,8 @@ async def wrapped_get_response(*args, **kwargs):
6664 SPANDATA .GEN_AI_RESPONSE_MODEL , response_model
6765 )
6866
67+ delattr (agent , "_sentry_raw_response_model" )
68+
6969 update_ai_client_span (span , agent , kwargs , result )
7070
7171 return result
0 commit comments