diff --git a/ddtrace/llmobs/_integrations/google_adk.py b/ddtrace/llmobs/_integrations/google_adk.py index 50a12dd1b86..9fcd517576e 100644 --- a/ddtrace/llmobs/_integrations/google_adk.py +++ b/ddtrace/llmobs/_integrations/google_adk.py @@ -1,3 +1,4 @@ +from inspect import isfunction from typing import Any from typing import Dict from typing import List @@ -18,6 +19,7 @@ from ddtrace.llmobs._integrations.base import BaseLLMIntegration from ddtrace.llmobs._integrations.google_utils import extract_message_from_part_google_genai from ddtrace.llmobs._integrations.google_utils import extract_messages_from_adk_events +from ddtrace.llmobs._utils import _get_attr from ddtrace.llmobs._utils import safe_json from ddtrace.trace import Span @@ -154,4 +156,15 @@ def _llmobs_set_tags_code_execute( def _get_agent_tools(self, tools): if not tools or not isinstance(tools, list): return [] - return [{"name": tool.name, "description": tool.description} for tool in tools] + + agent_tools = [] + for tool in tools: + if isfunction(tool): + tool_name = tool.__name__ + tool_description = tool.__doc__ or "" + else: + tool_name = _get_attr(tool, "name", "Agent Tool") + tool_description = _get_attr(tool, "description", "") + agent_tools.append({"name": tool_name, "description": tool_description}) + + return agent_tools diff --git a/releasenotes/notes/google-adk-tools-agent-manifest-fix-eff58eaeeaeef567.yaml b/releasenotes/notes/google-adk-tools-agent-manifest-fix-eff58eaeeaeef567.yaml new file mode 100644 index 00000000000..d274cbf5012 --- /dev/null +++ b/releasenotes/notes/google-adk-tools-agent-manifest-fix-eff58eaeeaeef567.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - | + LLM Observability: Fixes an issue where the Google ADK integration would throw an ``AttributeError`` when trying to access the ``name`` or ``description`` attributes of a tool. diff --git a/tests/contrib/google_adk/conftest.py b/tests/contrib/google_adk/conftest.py index aa93d643e3a..0e16da0b21e 100644 --- a/tests/contrib/google_adk/conftest.py +++ b/tests/contrib/google_adk/conftest.py @@ -124,7 +124,7 @@ async def setup_test_agent(): # Wrap Python callables as tools the agent can invoke tools = [ FunctionTool(func=search_docs), - FunctionTool(func=multiply), + multiply, ] # Enable code execution so the model can emit code blocks that get executed