Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions app/nullius/catalogue/agents/jiuwenswarm/agent.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"NULLIUS_BASE_URL": "{base_url}",
"NULLIUS_KEY": "{key}",
"NULLIUS_MODEL": "{model}",
"NULLIUS_REASONING": "{opt_reasoning_effort}"
"NULLIUS_REASONING": "{opt_reasoning_effort}",
"NULLIUS_WEB_TOOLS": "{opt_web_tools}"
}
},
"options": {
Expand All @@ -35,6 +36,15 @@
"max"
],
"default": "default"
},
"web_tools": {
"label": "Web tools",
"summary": "free_search, paid_search and fetch_webpage, JiuwenSwarm's web tools: `off` turns on its permission guard to refuse them, its built-in rules off and every other tool allowed; `default` leaves the guard off, as it ships.",
"values": [
"default",
"off"
],
"default": "default"
}
},
"default": "0.2.8",
Expand Down Expand Up @@ -107,7 +117,8 @@
"NULLIUS_KEY": "{key}",
"NULLIUS_MODEL": "{model}",
"NULLIUS_REASONING": "{opt_reasoning_effort}",
"WEB_RESEARCH_MAX_FETCHES": "{opt_web_max_fetches}"
"WEB_RESEARCH_MAX_FETCHES": "{opt_web_max_fetches}",
"NULLIUS_WEB_TOOLS": "{opt_web_tools}"
}
},
"fidelity": {
Expand Down
25 changes: 25 additions & 0 deletions app/nullius/catalogue/agents/jiuwenswarm/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
JHOME = os.path.join(HOME, ".jiuwenswarm")
CONFIG = os.path.join(JHOME, "config")
READY_SECONDS = 240
# its web search and page fetch: the tools as the model sees them, and the MCP ones its config.yaml lists
WEB_TOOLS = ("free_search", "paid_search", "fetch_webpage", "mcp_free_search", "mcp_paid_search", "mcp_fetch_webpage")


def say(*a):
Expand Down Expand Up @@ -132,6 +134,28 @@ def reasoning_level():
os.replace(path + ".part", path)


def web_tools():
"""The run's web tools (the option web_tools, NULLIUS_WEB_TOOLS): ``off`` denies JiuwenSwarm's own web search
and page fetch tools in its ``permissions.tools``, and turns on the guard that enforces them; default leaves
both as it ships."""
if os.environ.get("NULLIUS_WEB_TOOLS") != "off":
return
import yaml
path = os.path.join(CONFIG, "config.yaml")
with open(path) as f:
data = yaml.safe_load(f) or {}
# its permission guard, off as it ships, enforces the denials: on with its own extra rules off, so every
# other tool stays as its defaults allow it
guard = data.setdefault("permissions", {})
guard["enabled"], guard["package_builtin_rules"] = True, False
tools = guard.setdefault("tools", {})
for name in WEB_TOOLS:
tools[name] = "deny"
with open(path + ".part", "w") as f:
yaml.safe_dump(data, f, allow_unicode=True, sort_keys=False)
os.replace(path + ".part", path)


def mcp_into_config(servers):
"""ACP's stdio MCP servers as JiuwenSwarm's ``mcp.servers`` entries."""
import portalocker
Expand Down Expand Up @@ -301,6 +325,7 @@ def run(runtime_socket, cli_prompt=None):
return 1
memory_off()
reasoning_level()
web_tools()
ports = free_ports(4)
write_env(ports)
env = dict(os.environ, PYTHONIOENCODING="utf-8", PYTHONUNBUFFERED="1",
Expand Down
32 changes: 32 additions & 0 deletions app/tests/test_jiuwenswarm_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,38 @@ def test_vendor_default_range_and_environment_are_version_specific(self):
self.assertEqual(env["WEB_RESEARCH_MAX_FETCHES"], value)


class WebTools(unittest.TestCase):
"""A benchmark that turns agents' web tools off (``web_tools``): 0.2.9's search and page fetch denied in its config."""
def test_off_denies_its_web_tools_and_default_leaves_the_config_alone(self):
yaml = SimpleNamespace(safe_load=json.load, safe_dump=lambda data, stream, **kw: json.dump(data, stream)) # JSON is YAML
with tempfile.TemporaryDirectory() as directory, patch.dict("sys.modules", {"yaml": yaml}), \
patch.object(agent, "CONFIG", directory):
path = os.path.join(directory, "config.yaml")
before = {"permissions": {"enabled": False, "package_builtin_rules": True,
"tools": {"bash": "allow", "mcp_free_search": "allow"}}, "react": {}}
off = {"enabled": True, "package_builtin_rules": False, # the guard on, its own extra rules off
"tools": {"bash": "allow", **{n: "deny" for n in agent.WEB_TOOLS}}}
for value, expected in (("default", before["permissions"]), ("off", off)):
with self.subTest(value=value), patch.dict(os.environ, {"NULLIUS_WEB_TOOLS": value}):
with open(path, "w") as f:
json.dump(before, f)
agent.web_tools()
with open(path) as f:
self.assertEqual(json.load(f)["permissions"], expected)

def test_every_version_hands_the_wrapper_the_runs_value(self):
from nullius.standard.contract import definitions
from nullius.standard.runner import run
path = os.path.join(APP, "nullius", "catalogue", "agents", "jiuwenswarm", "agent.json")
with open(path) as f:
raw = json.load(f)
for version in ("0.2.7", "0.2.8", "0.2.9"):
with self.subTest(version=version), tempfile.TemporaryDirectory() as home:
current = dict(definitions.resolve(raw, version), _here=os.path.dirname(path))
env = run.agent_env(current, "/install", home, "http://127.0.0.1:1", "fixture", {"web_tools": "off"})
self.assertEqual(env["NULLIUS_WEB_TOOLS"], "off")


class RuntimeSocket(unittest.TestCase):
def test_startup_uses_the_installed_acp_entry_point(self):
# Upstream moved the bridge module into agent_gateway in 0.2.9;
Expand Down
1 change: 1 addition & 0 deletions docs/agents/supported/jiuwenswarm.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ openJiuwen's WorkSwarm agent.
| Option | Values, default in bold | What it sets | Versions |
|---|---|---|---|
| `reasoning_effort` | **`default`**, `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max` | How much reasoning the model uses before answering, with `default` leaving the choice to the provider. | every version |
| `web_tools` | **`default`**, `off` | free_search, paid_search and fetch_webpage, JiuwenSwarm's web tools: `off` turns on its permission guard to refuse them, its built-in rules off and every other tool allowed; `default` leaves the guard off, as it ships. | every version |
| `web_max_fetches` | default `3` | Pages fetched per invocation. | `jiuwenswarm@0.2.9` |

## Benchmarks it fits
Expand Down