Skip to content

Commit 62c396c

Browse files
committed
fix ut
1 parent 188e3bb commit 62c396c

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

pydantic_client/base.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,19 @@ def _request(self, request_info: RequestInfo) -> Any:
9393
def register_agno_tools(self, agent):
9494
"""
9595
Register all agno tools of this client instance to the given agent.
96-
Each tool will be registered with its description, parameters, and a call bound to this instance.
97-
98-
:param agent: The agent instance which supports .register_tool(name, description, parameters, call)
96+
Compatible with agno agent's set_tools/add_tool API.
9997
"""
98+
tools = []
10099
for tool_info in self.get_agno_tools():
101100
tool_name = tool_info['name']
102-
agent.register_tool(
101+
tool = dict(
103102
name=tool_name,
104103
description=tool_info.get('description', ''),
105104
parameters=tool_info.get('parameters', {}),
106105
call=lambda params, tool_name=tool_name: getattr(self, tool_name)(**params)
107106
)
107+
tools.append(tool)
108+
agent.set_tools(tools)
108109

109110
@classmethod
110111
def get_agno_tools(cls) -> List[Dict[str, Any]]:

tests/test_base_client_cov.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ class DummyAgent:
77
def __init__(self):
88
self.tools = []
99

10-
def register_tool(self, name, description, parameters, call):
11-
self.tools.append((name, description, parameters, call))
10+
def set_tools(self, tools):
11+
self.tools = tools
1212

1313

1414
class TestClient(BaseWebClient):
@@ -59,6 +59,6 @@ def test_register_agno_tools_and_get_agno_tools():
5959
client = TestClient(base_url="http://a")
6060
agent = DummyAgent()
6161
client.register_agno_tools(agent)
62-
assert any(t[0] == 'tool_method' for t in agent.tools)
62+
assert any(t["name"] == 'tool_method' for t in agent.tools)
6363
tools = TestClient.get_agno_tools()
6464
assert any(t['name'] == 'tool_method' for t in tools)

0 commit comments

Comments
 (0)