Skip to content

Commit dd0fbe5

Browse files
authored
Merge pull request #269 from hud-evals/invalidate-routing
Invalidate routing on add_tool
2 parents bb8e740 + 49bfa98 commit dd0fbe5

8 files changed

Lines changed: 18 additions & 5 deletions

File tree

docs/docs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"icon": "code",
3434
"versions": [
3535
{
36-
"version": "0.5.5",
36+
"version": "0.5.6",
3737
"groups": [
3838
{
3939
"group": "Get Started",

hud/agents/claude.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def to_api_tool(tool: types.Tool) -> BetaToolUnionParam | None:
303303
display_width_px=computer_settings.ANTHROPIC_COMPUTER_WIDTH,
304304
display_height_px=computer_settings.ANTHROPIC_COMPUTER_HEIGHT,
305305
)
306-
elif tool.name == "computer":
306+
elif tool.name == "computer" or tool.name.endswith("_computer"):
307307
logger.warning(
308308
"Renamed tool %s to 'computer', dropping original 'computer' tool",
309309
selected_computer_tool.name,

hud/agents/gemini_cua.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ def _to_gemini_tool(self, tool: types.Tool) -> genai_types.Tool | None:
123123
)
124124
)
125125

126+
if tool.name == "computer" or tool.name.endswith("_computer"):
127+
return None
128+
126129
# For non-computer tools, use the parent implementation
127130
return super()._to_gemini_tool(tool)
128131

hud/agents/operator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ def _to_openai_tool(
129129
display_height=self._operator_display_height,
130130
environment=self._operator_environment,
131131
)
132+
if tool.name == "computer" or tool.name.endswith("_computer"):
133+
return None
132134
return super()._to_openai_tool(tool)
133135

134136
def _extract_tool_call(self, item: Any) -> MCPToolCall | None:

hud/environment/environment.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ def as_tools(self) -> list[mcp_types.Tool]:
182182

183183
return tools
184184

185+
def add_tool(self, obj: Any, **kwargs: Any) -> None:
186+
super().add_tool(obj, **kwargs)
187+
self._routing_built = False
188+
185189
async def call_tool(self, call: Any, /, **kwargs: Any) -> Any:
186190
"""Call a tool, auto-detecting format and returning matching result format.
187191
@@ -446,6 +450,10 @@ async def _execute_tool(self, name: str, arguments: dict[str, Any]) -> MCPToolRe
446450
logger.debug("Mock mode: returning mock result for tool %s", name)
447451
return self._get_mock_result(name, arguments)
448452

453+
# Rebuild routing if invalidated (e.g., after add_tool)
454+
if not self._routing_built:
455+
await self._build_routing()
456+
449457
if self._router.is_local(name):
450458
# Call tool manager directly to avoid FastMCP context requirement
451459
result = await self._tool_manager.call_tool(name, arguments)

hud/utils/tests/test_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ def test_import():
55
"""Test that the package can be imported."""
66
import hud
77

8-
assert hud.__version__ == "0.5.5"
8+
assert hud.__version__ == "0.5.6"

hud/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
from __future__ import annotations
66

7-
__version__ = "0.5.5"
7+
__version__ = "0.5.6"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "hud-python"
3-
version = "0.5.5"
3+
version = "0.5.6"
44
description = "SDK for the HUD platform."
55
readme = "README.md"
66
requires-python = ">=3.11, <3.13"

0 commit comments

Comments
 (0)