Skip to content
Merged
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
2 changes: 2 additions & 0 deletions hud/environment/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,8 @@ def _setup_handlers(self) -> None:

async def _env_list_tools(self) -> list[mcp_types.Tool]:
"""Return all tools including those from connectors."""
if not self._router.tools:
await self._build_routing()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repeated _build_routing calls when no tools exist

Low Severity

The condition if not self._router.tools: cannot distinguish between "routing not built yet" and "routing built but with zero tools". Since an empty list is falsy in Python, if the environment genuinely has no tools (no local tools and no connections), _build_routing() will be called on every _env_list_tools() invocation. This causes unnecessary repeated async work. A boolean flag tracking whether routing has been built would be more reliable than checking if the tools list is empty.

🔬 Verification Test

Why verification test was not possible: This is a logical edge case that would require setting up the full environment infrastructure with mocked async methods to demonstrate the repeated calls. The bug is evident from code analysis: when _router.tools returns an empty list (valid state with zero tools), not [] evaluates to True, causing _build_routing() to be called every time _env_list_tools() is invoked.

Fix in Cursor Fix in Web

return self._router.tools

async def _env_call_tool(self, name: str, arguments: dict[str, Any] | None = None) -> list[Any]:
Expand Down
Loading