Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion ddtrace/llmobs/_integrations/google_adk.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from inspect import isfunction
from typing import Any
from typing import Dict
from typing import List
Expand All @@ -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

Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion tests/contrib/google_adk/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading