Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ def _assemble_dialogue_history(
tools_parts.append(f"Agent: {agent_id}")
if details.tool_declarations:
for tool in details.tool_declarations:
for func in tool.function_declarations:
# Built-in tools such as google_search carry no declarations.
for func in tool.function_declarations or []:
tools_parts.append(f"- {func.name}: {func.description}")

self._formatted_instructions = "\n\n".join(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,42 @@ async def test_app_details_instructions_and_tools(self, evaluator):
assert "transfer_funds" in evaluator._formatted_tools
assert "Transfer money between accounts." in evaluator._formatted_tools

@pytest.mark.asyncio
async def test_app_details_with_built_in_tool(self, evaluator):
"""Tests that tools without function declarations are skipped."""
app_details = AppDetails(
agent_details={
"search_agent": AgentDetails(
name="search_agent",
instructions="You answer questions using search.",
tool_declarations=[
genai_types.Tool(google_search=genai_types.GoogleSearch()),
genai_types.Tool(
function_declarations=[
genai_types.FunctionDeclaration(
name="get_weather",
description="Get the weather for a city.",
)
]
),
],
)
},
)
invocations = [
_make_invocation(
user_text="What is the weather in Paris?",
agent_text="It is sunny.",
invocation_id="search_agent",
rubrics=_RUBRICS,
app_details=app_details,
),
]
evaluator._assemble_dialogue_history(invocations)

assert "get_weather" in evaluator._formatted_tools
assert "Get the weather for a city." in evaluator._formatted_tools

@pytest.mark.asyncio
async def test_invocation_without_user_content(self, evaluator):
"""Tests that invocations with no user text parts are handled gracefully."""
Expand Down
Loading