mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
fix: Parallelize tool resolution in LlmAgent.canonical_tools()
Previously we resolved tools sequentially by awaiting _convert_tool_union_to_tools() in a loop -- reduce the latency by resolving tools concurrently. Co-authored-by: Kathy Wu <wukathy@google.com> PiperOrigin-RevId: 872979105
This commit is contained in:
committed by
Copybara-Service
parent
bef3f117b4
commit
7478bdaa98
@@ -451,6 +451,27 @@ class TestCanonicalTools:
|
||||
assert tools[0].name == 'vertex_ai_search'
|
||||
assert tools[0].__class__.__name__ == 'VertexAiSearchTool'
|
||||
|
||||
async def test_multiple_tools_resolution(self):
|
||||
"""Test that multiple tools are resolved correctly."""
|
||||
|
||||
def _tool_1():
|
||||
pass
|
||||
|
||||
def _tool_2():
|
||||
pass
|
||||
|
||||
agent = LlmAgent(
|
||||
name='test_agent',
|
||||
model='gemini-pro',
|
||||
tools=[_tool_1, _tool_2],
|
||||
)
|
||||
ctx = await _create_readonly_context(agent)
|
||||
tools = await agent.canonical_tools(ctx)
|
||||
|
||||
assert len(tools) == 2
|
||||
assert tools[0].name == '_tool_1'
|
||||
assert tools[1].name == '_tool_2'
|
||||
|
||||
|
||||
# Tests for multi-provider model support via string model names
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
Reference in New Issue
Block a user