Skip to content

The agent that grows with you

fix(tool_search): cover the dispatcher's local-entry guard directly; reuse _core_tool_names

teknium191279b01f32d
diff --git a/tests/tools/test_connector_local_batches.py b/tests/tools/test_connector_local_batches.py
index 9eb129a424b..da393bff9cc 100644
--- a/tests/tools/test_connector_local_batches.py
+++ b/tests/tools/test_connector_local_batches.py
@@ -95,3 +95,20 @@ def test_single_local_unwrap_keeps_session_db_todo_store_and_setup_callback(tmp_
finally:
db.close()
reset_session_vars()
+
+
+def test_dispatch_connector_batch_guard_echoes_first_entry(monkeypatch):
+ """Direct call: the dispatcher's own local-entry guard (unreachable via tool_call, which
+ partitions first) must reject with the echoed retry shape before any entry runs."""
+ import model_tools
+ from tools.connectors.dispatch import dispatch_connector_batch
+
+ invoked = []
+ monkeypatch.setattr(model_tools, "handle_function_call", lambda *a, **kw: invoked.append(a))
+ calls = [{"name": "session_search", "arguments": {"query": "alpha"}},
+ {"name": "connectors__gmail__SEND_EMAIL", "arguments": {}}]
+ result = json.loads(dispatch_connector_batch(
+ calls, model_tools._CallIds(), user_task=None, enabled_tools=None,
+ middleware_trace=[], enabled_toolsets=None, disabled_toolsets=None))
+ assert 'Retry with only: {"calls":[{"name":"session_search","arguments":{"query":"alpha"}}]}' in result["error"]
+ assert invoked == []
diff --git a/tools/tool_search_validation.py b/tools/tool_search_validation.py
index 8ac593717b1..a0cc28c67d3 100644
--- a/tools/tool_search_validation.py
+++ b/tools/tool_search_validation.py
@@ -212,12 +212,8 @@ def not_deferrable_error(name: str) -> str:
tool (call it without the bridge) vs. an unknown name — typically a deferred MCP tool
cited by its bare suffix instead of the full ``mcp__<server>__<tool>`` name. Telling
the second group 'call it directly' is the opposite of what they must do."""
- try:
- from toolsets import _HERMES_CORE_TOOLS
- core = frozenset(_HERMES_CORE_TOOLS)
- except Exception:
- core = frozenset()
- if name in core or _registry_entry(name) is not None:
+ from tools.tool_search import _core_tool_names # late: tool_search imports this module
+ if name in _core_tool_names() or _registry_entry(name) is not None:
return (f"'{name}' is a directly-listed tool, not a deferred one. "
"Call it directly instead of via tool_call.")
suffix = f"__{name}"