_expand_parent_toolsets built the parent's tool surface from each toolset's declared `tools` only, so a composite parent's `includes` were invisible: a child of a `debugging` parent (terminal/process_manage + includes web/file) asking for `file` or `web` was refused, and `safe` / `hermes-gateway` parents could grant nothing but their own name. Same root cause as the `_strip_blocked_tools` fix in the previous commit (#111700, "Related" section). Both sides of the subset check now use the resolved static surface (`resolve_toolset(name, include_registry=False)`), so a child may request any toolset whose real tools the parent genuinely holds, and still never gains a tool the parent lacks. Candidates that resolve to nothing are not expanded into (they cannot be a meaningful subset). Co-authored-by: DresvyanskiyDenis <dresvyanskiydenis@gmail.com>
48 lines
2.0 KiB
Python
48 lines
2.0 KiB
Python
"""Tests for composite toolset expansion in delegate_task intersection."""
|
|
|
|
import unittest
|
|
|
|
from tools.delegate_tool import _expand_parent_toolsets, _strip_blocked_tools
|
|
|
|
|
|
class TestExpandParentToolsets(unittest.TestCase):
|
|
"""Verify _expand_parent_toolsets recognises individual toolsets within composites."""
|
|
|
|
def test_composite_hermes_cli_expands_web(self):
|
|
"""hermes-cli includes web_search/web_extract → 'web' should be in expansion."""
|
|
expanded = _expand_parent_toolsets({"hermes-cli"})
|
|
self.assertIn("web", expanded)
|
|
self.assertIn("terminal", expanded)
|
|
self.assertIn("browser", expanded)
|
|
# Original composite is preserved
|
|
self.assertIn("hermes-cli", expanded)
|
|
|
|
|
|
def test_intersection_with_expanded_composite(self):
|
|
"""End-to-end: requesting ['web'] from parent with ['hermes-cli'] yields ['web']."""
|
|
parent_toolsets = {"hermes-cli"}
|
|
expanded = _expand_parent_toolsets(parent_toolsets)
|
|
toolsets = ["web"]
|
|
child_toolsets = [t for t in toolsets if t in expanded]
|
|
self.assertEqual(child_toolsets, ["web"])
|
|
|
|
def test_included_toolsets_of_composite_parent_are_grantable(self):
|
|
"""A composite parent holds its ``includes`` too (#111700): ``debugging`` = terminal/process_manage +
|
|
includes web/file, so a child may request ``web``/``file`` — but never a toolset the parent lacks."""
|
|
expanded = _expand_parent_toolsets({"debugging"})
|
|
self.assertTrue({"debugging", "terminal", "web", "file"} <= expanded)
|
|
self.assertNotIn("browser", expanded)
|
|
self.assertNotIn("hermes-cli", expanded)
|
|
|
|
def test_composites_with_allowed_included_tools_are_not_stripped(self):
|
|
toolsets = ["safe", "hermes-gateway", "hermes-cli", "delegation", "kanban"]
|
|
|
|
self.assertEqual(
|
|
_strip_blocked_tools(toolsets),
|
|
["safe", "hermes-gateway", "hermes-cli"],
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|