JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
fix(teams): surface leader permission interrupts to users
DL12326e4007a5bcd6
diff --git a/jiuwenswarm/agents/swarm/config_specs.py b/jiuwenswarm/agents/swarm/config_specs.pyindex 78acc50391..766001cee5 100644--- a/jiuwenswarm/agents/swarm/config_specs.py+++ b/jiuwenswarm/agents/swarm/config_specs.py@@ -407,9 +407,10 @@ def _team_common_rail_names(role: str) -> tuple[str, ...]:def _code_base_rail_names(role: str) -> tuple[str, ...]:"""Code-profile rails minus permission interrupt; leaders omit code todo planning.- ``PERMISSION_INTERRUPT`` is excluded for all team members: it relies on a- frontend user response that headless teammates cannot provide, and even the- leader's interrupt path is unreliable in a team context.+ ``PERMISSION_INTERRUPT`` remains excluded from code.team/team.plan for all+ members: teammates are headless, and these profiles retain their historical+ Leader-mediated approval path. Ordinary chat-team Leaders are assembled by+ ``_build_team_capability_specs`` and do receive the user-facing interrupt."""names = tuple(name for name in _CODE_RAIL_NAMES@@ -473,6 +474,9 @@ def _build_team_capability_specs()if enable_permissions and role == "teammate":+ # Teammates are headless in a Team run. TeamPermissionRail forwards+ # ASK decisions to the Leader's approve_tool flow instead of creating+ # a frontend interrupt for the teammate itself.rails_specs.append(RailSpec(type=registry.TEAM_PERMISSION,@@ -481,11 +485,22 @@ def _build_team_capability_specs()if enable_permissions and role == "leader":- rails_specs.append(- RailSpec(- type=registry.TEAM_PERMISSION_POLICY,- params=_rail_params(registry.TEAM_PERMISSION_POLICY, config),- ),+ # These Rails serve different consumers: the policy Rail teaches the+ # Leader how to approve teammate requests, while PermissionInterruptRail+ # exposes the Leader's own ASK decisions through the user-facing Team+ # stream. Keeping both mounted avoids silently auto-approving Leader+ # tool calls and does not change teammate approval semantics.+ rails_specs.extend(+ [+ RailSpec(+ type=registry.TEAM_PERMISSION_POLICY,+ params=_rail_params(registry.TEAM_PERMISSION_POLICY, config),+ ),+ RailSpec(+ type=registry.PERMISSION_INTERRUPT,+ params=_rail_params(registry.PERMISSION_INTERRUPT, config),+ ),+ ])rails_specs.extend(_role_evolution_rails(config, role))diff --git a/tests/agents/swarm/test_manifest_catalog.py b/tests/agents/swarm/test_manifest_catalog.pyindex f9cb23b455..59e2765a46 100644--- a/tests/agents/swarm/test_manifest_catalog.py+++ b/tests/agents/swarm/test_manifest_catalog.py@@ -246,6 +246,36 @@ def test_config_specs_bakes_attribute_params() -> None:)+def test_chat_team_permissions_mount_user_interrupt_only_on_leader() -> None:+ """Chat-team leaders ask the user; teammates continue asking the leader."""+ from jiuwenswarm.agents.swarm.config_specs import build_member_capability_specs++ config = {+ "permissions": {"enabled": True},+ "models": {"default": {"model_client_config": {"model_name": "gpt-4o"}}},+ }+ leader_rails, _ = build_member_capability_specs(+ config, "team", "leader", enable_permissions=True+ )+ teammate_rails, _ = build_member_capability_specs(+ config, "team", "teammate", enable_permissions=True+ )+ leader_by_type = {spec.type: spec.params for spec in leader_rails}+ teammate_by_type = {spec.type: spec.params for spec in teammate_rails}++ assert registry.TEAM_PERMISSION_POLICY in leader_by_type+ assert registry.PERMISSION_INTERRUPT in leader_by_type+ assert registry.TEAM_PERMISSION not in leader_by_type+ assert leader_by_type[registry.PERMISSION_INTERRUPT] == {+ "permissions_config": {"enabled": True},+ "model_name": "gpt-4o",+ }++ assert registry.TEAM_PERMISSION in teammate_by_type+ assert registry.PERMISSION_INTERRUPT not in teammate_by_type+ assert registry.TEAM_PERMISSION_POLICY not in teammate_by_type++def test_config_specs_maps_review_trigger_for_leader(monkeypatch: pytest.MonkeyPatch,) -> None: