fix: replace nonexistent trace_tool_response with trace_merged_tool_calls in ADK patch#1289
fix: replace nonexistent trace_tool_response with trace_merged_tool_calls in ADK patch#1289MaxwellCalkin wants to merge 1 commit intoAgentOps-AI:mainfrom
Conversation
…alls in ADK instrumentation Fixes AgentOps-AI#1257. google.adk.telemetry.trace_tool_response does not exist in any supported version of google-adk (1.4.1+). The function was renamed to trace_merged_tool_calls, causing a warning on startup: Could not wrap google.adk.telemetry.trace_tool_response: module "google.adk.telemetry" has no attribute "trace_tool_response" Changes: - Replace _adk_trace_tool_response_wrapper with _adk_trace_merged_tool_calls_wrapper matching the current trace_merged_tool_calls(response_event_id, function_response_event) signature - Fix _adk_trace_tool_call_wrapper to correctly extract the tool object from args[0] and tool arguments from args[1], matching the current trace_tool_call(tool, args, function_response_event) signature (previously args[0] was incorrectly treated as the arguments dict) - Update patch_adk() to wrap trace_merged_tool_calls instead of trace_tool_response
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
themavik
left a comment
There was a problem hiding this comment.
This PR fixes the ADK patch to use trace_merged_tool_calls instead of the nonexistent trace_tool_response, and updates the trace_tool_call wrapper for the new signature.
Done well: The wrapper correctly extracts tool and tool_args from the new trace_tool_call(tool, args, function_response_event) signature. Adding tool_name to span attributes when tool has a name is useful. The trace_merged_tool_calls wrapper maps response_event_id and function_response_event from the new signature. The try/except around model_dump_json with fallback to less-than-serializable is a good defensive touch.
Suggestion: The old trace_tool_response took invocation_context, event_id, function_response_event. The new trace_merged_tool_calls drops invocation_id. If that was used for correlation elsewhere, consider whether response_event_id or another field can fill that role. Also worth verifying the ADK version that introduced trace_merged_tool_calls so the patch is version-gated or documented.
Summary
Fix Google ADK instrumentation error on startup:
Fixes #1257.
Problem
google.adk.telemetry.trace_tool_responsedoes not exist in any supported version ofgoogle-adk(1.4.1+). The function was renamed totrace_merged_tool_callswith a different signature:Additionally,
_adk_trace_tool_call_wrapperincorrectly extractsargs[0]as the tool arguments dict when it is actually thetoolobject. The currenttrace_tool_callsignature is:Changes
_adk_trace_tool_response_wrapperwith_adk_trace_merged_tool_calls_wrappermatching thetrace_merged_tool_calls(response_event_id, function_response_event)signature_adk_trace_tool_call_wrapperto correctly extract thetoolobject fromargs[0]and tool arguments fromargs[1]patch_adk()to wraptrace_merged_tool_callsinstead oftrace_tool_responseTest plan