Function `<tool_name>`- Not found in tools_dict
Describe the bug When using Claude in google-adk . Even if the tool name is present, it gives me this tool not found error. It only happens on the second try of the function call. It's super weird, haven't figured it out why.
I have other agents with Gemini Model, this behaviour doesn't happen.
I get this error
File "/app/.venv/lib/python3.13/site-packages/google/adk/flows/llm_flows/functions.py", line 649, in _get_tool_and_context
raise ValueError(
f'Function {function_call.name} is not found in the tools_dict.'
)
ValueError: Function query_surveys is not found in the tools_dict.
To Reproduce
from google.adk import Agent
from google.adk.models.anthropic_llm import Claude
from google.adk.models.registry import LLMRegistry
LLMRegistry.register(Claude)
claude_model="claude-sonnet-4-5@20250929"
root_agent = Agent(
model=claude_model,
name="root_agent",
instruction=get_instruction(),
tools=[query_surveys],
description=(
"Get's survey Information"
),
)
Expected behavior It's not a wrong tool call since the tool name is right.
Desktop (please complete the following information):
- OS: Linux
- Python version(python -V): 3.12
- ADK version(pip show google-adk): 1.16.0
Model Information:
- Are you using LiteLLM: No
- Which model is being used: "claude-sonnet-4-5@20250929" (vertexai)
@me-her It looks like the 'google-adk' agent might be having trouble with tool registration on subsequent calls, especially with Claude. I've put together a corrected script,that properly sets up the agent and its context. Could you please try running this in your environment. It should help us to check if the issue is resolved or if we need to dig deeper. Thanks!
import asyncio
from typing import Optional, Any
from google.adk.agents import LlmAgent
from google.adk.agents.invocation_context import InvocationContext, new_invocation_context_id
from google.adk.events.event import Event
from google.adk.models.anthropic_llm import Claude
from google.adk.models.registry import LLMRegistry
from google.adk.tools import FunctionTool
from google.adk.sessions.base_session_service import BaseSessionService, ListSessionsResponse, GetSessionConfig
from google.adk.sessions.session import Session
# Mock SessionService
class MockSessionService(BaseSessionService):
def __init__(self):
self.sessions = {}
async def create_session(
self,
*,
app_name: str,
user_id: str,
state: Optional[dict[str, Any]] = None,
session_id: Optional[str] = None,
) -> Session:
if session_id is None:
session_id = f"{app_name}-{user_id}-{len(self.sessions) + 1}"
new_session = Session(session_id=session_id, app_name=app_name, user_id=user_id, state=state or {})
self.sessions[session_id] = new_session
return new_session
async def get_session(
self,
*,
app_name: str,
user_id: str,
session_id: str,
config: Optional[GetSessionConfig] = None,
) -> Optional[Session]:
return self.sessions.get(session_id)
async def list_sessions(self, *, app_name: str, user_id: str) -> ListSessionsResponse:
user_sessions = [
s for s in self.sessions.values() if s.app_name == app_name and s.user_id == user_id
]
return ListSessionsResponse(sessions=user_sessions)
async def delete_session(self, *, app_name: str, user_id: str, session_id: str) -> None:
if session_id in self.sessions:
del self.sessions[session_id]
def update_session(self, session: Session):
self.sessions[session.session_id] = session
# Mock the tool function
def query_surveys(query: str) -> str:
"""
Queries the survey database.
"""
return f"Results for query: {query}"
def get_instruction():
return "You are a helpful assistant."
async def main():
LLMRegistry.register(Claude)
claude_model="claude-sonnet-4-5@20250929"
root_agent = LlmAgent(
model=claude_model,
name="root_agent",
instruction=get_instruction(),
tools=[FunctionTool(func=query_surveys)],
description=(
"Get's survey Information"
),
)
# Create a mock session service and session
session_service = MockSessionService()
app_name = "test_app"
user_id = "test_user"
session = await session_service.create_session(app_name=app_name, user_id=user_id)
# Create an invocation context
ctx = InvocationContext(
agent=root_agent,
session_service=session_service,
session=session,
invocation_id=new_invocation_context_id(),
user_content= "Can you query the surveys for 'customer satisfaction'?"
)
# First call
print("First call to the agent:")
async for event in root_agent.run_async(ctx):
print(f"Event (first call): {event}")
if event.is_final_response():
print(f"Final response (first call): {event.content.parts[0].text}")
# Second call
print("\nSecond call to the agent:")
# We need to create a new context for the second call,
# but carry over the history.
# This is a simplified example. A real application would need to manage
# the conversation history more robustly.
new_ctx = InvocationContext(
agent=root_agent,
session_service=session_service,
session=session,
invocation_id=new_invocation_context_id(),
user_content="Can you query the surveys for 'employee engagement'?",
history=session.events,
)
async for event in root_agent.run_async(new_ctx):
print(f"Event (second call): {event}")
if event.is_final_response():
print(f"Final response (second call): {event.content.parts[0].text}")