Skip to content

The agent that grows with you

fix(plugins): lifecycle launches accept plugin toolsets

Evac5a3231c531a
diff --git a/agent/subagent_lifecycle.py b/agent/subagent_lifecycle.py
index ff724f2daeb..658654717f8 100644
--- a/agent/subagent_lifecycle.py
+++ b/agent/subagent_lifecycle.py
@@ -462,8 +462,9 @@ class SubagentLifecycleService:
raise SubagentLifecycleError("metadata exceeds 8192 bytes.")
if not request.allowed_toolsets:
return
- from toolsets import TOOLSETS
- unknown = set(request.allowed_toolsets) - set(TOOLSETS)
+ # Plugin and registry-alias toolsets count as known, as they do for delegate_task.
+ from toolsets import validate_toolset
+ unknown = {name for name in request.allowed_toolsets if not validate_toolset(name)}
if unknown:
raise SubagentLifecycleError(f"Unknown toolsets: {', '.join(sorted(unknown))}.")
enabled = getattr(parent, "enabled_toolsets", None)
diff --git a/tests/agent/test_subagent_lifecycle.py b/tests/agent/test_subagent_lifecycle.py
index ba638ff8853..34fe488f136 100644
--- a/tests/agent/test_subagent_lifecycle.py
+++ b/tests/agent/test_subagent_lifecycle.py
@@ -401,3 +401,16 @@ def test_routing_provider_validation(routing_lifecycle, provider):
assert str(exc.value) == "provider must be a non-empty string of at most 64 characters."
build.assert_not_called()
resolve.assert_not_called()
+
+
+def test_plugin_toolsets_are_known_toolsets(lifecycle, monkeypatch):
+ monkeypatch.setattr("toolsets._get_plugin_toolset_names", lambda: {"plugin-tools"})
+ parent = SimpleNamespace(session_id="parent-plugin", enabled_toolsets=["file", "plugin-tools"])
+ service = SubagentLifecycleService(lambda: parent)
+ handle = service.launch(SubagentLaunchRequest(goal="use the plugin", allowed_toolsets=("plugin-tools",)))
+ assert service.wait(handle, timeout_seconds=2).state is SubagentState.SUCCEEDED
+ with pytest.raises(SubagentLifecycleError, match="Unknown toolsets: nope"):
+ service.launch(SubagentLaunchRequest(goal="use the plugin", allowed_toolsets=("nope",)))
+ narrow = SubagentLifecycleService(lambda: SimpleNamespace(session_id="parent-narrow", enabled_toolsets=["file"]))
+ with pytest.raises(SubagentLifecycleError, match="broaden"):
+ narrow.launch(SubagentLaunchRequest(goal="use the plugin", allowed_toolsets=("plugin-tools",)))