Skip to content

Conversation

@farrelmahaztra
Copy link
Contributor

@farrelmahaztra farrelmahaztra commented Jan 9, 2026

Note

Fix tool listing initialization

  • Update Environment._env_list_tools to call _build_routing() when self._router.tools is empty, ensuring tools (including connector tools) are discovered and returned even if routing hasn't been built yet.

Written by Cursor Bugbot for commit d35e5d3. This will update automatically on new commits. Configure here.

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

@lorenss-m lorenss-m merged commit 004b930 into main Jan 9, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants