Google Gemini Grounding Tool: `'Tool' object has no attribute 'name'`
Checked other resources
- [X] I added a very descriptive title to this issue.
- [X] I searched the LangChain documentation with the integrated search.
- [X] I used the GitHub search to find a similar question and didn't find it.
- [X] I am sure that this is a bug in LangChain rather than my code.
- [x] The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
Example Code
from vertexai.generative_models import Tool, grounding
from langchain.agents import AgentExecutor, create_react_agent
tool = Tool.from_google_search_retrieval(grounding.GoogleSearchRetrieval())
try:
agent = create_react_agent(llm=llm, tools=[tool], prompt=prompt_template)
except Exception as error:
logger.exception(f"Error creating agent: {error}")
raise error
Error Message and Stack Trace (if applicable)
{
"level": "ERROR",
"location": "_initialize_chatbot_agent:160",
"message": "Error creating agent: 'Tool' object has no attribute 'name'",
"timestamp": "2025-01-10 01:56:14,301+0000",
"service": "chatbot_agent.py",
"exception": "Traceback (most recent call last):\n File \"/app/util/chatbot_agent.py\", line 158, in _initialize_chatbot_agent\n agent = create_react_agent(llm=llm, tools=self.tools, prompt=prompt_template)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/local/lib/python3.12/site-packages/langchain/agents/react/agent.py\", line 117, in create_react_agent\n tools=tools_renderer(list(tools)),\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/local/lib/python3.12/site-packages/langchain/tools/render.py\", line 38, in render_text_description\n return \"\\n\".join([f\"{tool.name}: {tool.description}\" for tool in tools])\n ^^^^^^^^^\nAttributeError: 'Tool' object has no attribute 'name'",
"exception_name": "AttributeError",
"stack_trace": {
"type": "AttributeError",
"value": "'Tool' object has no attribute 'name'",
"module": "builtins",
"frames": [
{
"file": "/app/util/chatbot_agent.py",
"line": 158,
"function": "_initialize_chatbot_agent",
"statement": "agent = create_react_agent(llm=llm, tools=self.tools, prompt=prompt_template)"
},
{
"file": "/usr/local/lib/python3.12/site-packages/langchain/agents/react/agent.py",
"line": 117,
"function": "create_react_agent",
"statement": "tools=tools_renderer(list(tools)),"
},
{
"file": "/usr/local/lib/python3.12/site-packages/langchain/tools/render.py",
"line": 38,
"function": "render_text_description",
"statement": "return \"\\n\".join([f\"{tool.name}: {tool.description}\" for tool in tools])"
}
]
}
}
Description
Using this as an example, I'm attempting to use gemini's grounding tool.
I expect my call to gemini to succeed. Instead, I get 'Tool' object has no attribute 'name'.
Looks like LangChain's BaseTool class expects a name attribute that google's Tool class doesn't implement, making them incompatible.
System Info
System Information
------------------
> OS: Darwin
> OS Version: Darwin Kernel Version 24.1.0: Thu Oct 10 21:06:57 PDT 2024; root:xnu-11215.41.3~3/RELEASE_ARM64_T6041
> Python Version: 3.12.8 (main, Dec 19 2024, 09:47:55) [Clang 16.0.0 (clang-1600.0.26.6)]
Package Information
-------------------
> langchain_core: 0.3.29
> langchain: 0.3.14
> langchain_community: 0.3.14
> langsmith: 0.1.147
> langchain_anthropic: 0.3.1
> langchain_google_genai: 2.0.8
> langchain_google_vertexai: 2.0.10
> langchain_openai: 0.2.14
> langchain_text_splitters: 0.3.5
Optional packages not installed
-------------------------------
> langserve
Other Dependencies
------------------
> aiohttp: 3.11.11
> anthropic: 0.42.0
> anthropic[vertexai]: Installed. No version info available.
> async-timeout: Installed. No version info available.
> dataclasses-json: 0.6.7
> defusedxml: 0.7.1
> filetype: 1.2.0
> google-cloud-aiplatform: 1.76.0
> google-cloud-storage: 2.19.0
> google-generativeai: 0.8.3
> httpx: 0.28.1
> httpx-sse: 0.4.0
> jsonpatch: 1.33
> langchain-mistralai: Installed. No version info available.
> langsmith-pyo3: Installed. No version info available.
> numpy: 1.26.4
> openai: 1.59.6
> orjson: 3.10.12
> packaging: 23.2
> pydantic: 2.9.2
> pydantic-settings: 2.7.1
> PyYAML: 6.0.2
> requests: 2.32.3
> requests-toolbelt: 1.0.0
> SQLAlchemy: 2.0.37
> tenacity: 9.0.0
> tiktoken: 0.8.0
> typing-extensions: 4.12.2
bumping this
Adding a +
me too.
model: qwen2.5:7b
I'm going to leave this issue open but I was able to get around this by ripping out the (now deprecated) create_react_agent and using ChatVertexAI.
Hi, @BwL1289. I'm Dosu, and I'm helping the LangChain team manage their backlog. I'm marking this issue as stale.
Issue Summary:
- You reported an
AttributeErrorwith the Google Gemini Grounding Tool in LangChain, related to a missing 'name' attribute in the 'Tool' object. - The issue persisted even after updating to the latest version, indicating a potential bug.
- You found a workaround by using
ChatVertexAIinstead of the deprecatedcreate_react_agent. - Other users, like Lorentzo92 and catsled, have reported similar issues.
Next Steps:
- Please confirm if this issue is still relevant with the latest version of LangChain. If so, feel free to comment to keep the discussion open.
- If there are no further updates, this issue will be automatically closed in 7 days.
Thank you for your understanding and contribution!