Agent Zero AI framework
Skip inherited tool-policy prompt filtering
Alessandroa754eed10369
diff --git a/helpers/tool_policy.py b/helpers/tool_policy.pyindex 2e57eabc2..3e14b78be 100644--- a/helpers/tool_policy.py+++ b/helpers/tool_policy.py@@ -209,6 +209,9 @@ def ensure_tool_allowed(def filter_tool_prompt(agent: Any, prompt_file: str, prompt: str) -> str:+ if get_policy(agent)["mode"] != "custom":+ return prompt+known_names = _policy_tool_names(agent)names = _prompt_tool_names(prompt_file, prompt, known_names)if names and not any(resolve_tool(agent, name).allowed for name in names):diff --git a/helpers/tool_policy.py.dox.md b/helpers/tool_policy.py.dox.mdindex ef3e8de80..2fe6094eb 100644--- a/helpers/tool_policy.py.dox.md+++ b/helpers/tool_policy.py.dox.md@@ -34,6 +34,8 @@- Missing policy inherits standard access. A custom policy records independentdefaults for local/plugin tools and canonical MCP tools; explicit allowed orblocked IDs take precedence over either default.+- Inherited prompt policy returns tool text unchanged without inventorying or+ resolving individual tools; only custom policy pays the filtering cost.- The `response` capability is a framework-required invariant: profile policycannot disable it, and the editor does not list it as a configurable tool.- `vision_load` remains owned by the active chat model's vision configuration;diff --git a/tests/test_tool_policy.py b/tests/test_tool_policy.pyindex d59317538..2db20350c 100644--- a/tests/test_tool_policy.py+++ b/tests/test_tool_policy.py@@ -132,6 +132,35 @@ def test_provider_native_schemas_omit_blocked_local_tool(assert [tool["name"] for tool in tools] == ["allowed"]+def test_inherited_prompt_filter_skips_tool_inventory(monkeypatch, tmp_path: Path):+ agent = _Agent(tmp_path)+ prompt = "### shell\nRun a command."+ policy_reads = 0++ def inherited_policy(_agent):+ nonlocal policy_reads+ policy_reads += 1+ return {+ "mode": "inherit",+ "default": "allow",+ "mcp_default": "allow",+ "allowed": [],+ "blocked": [],+ }++ monkeypatch.setattr(tool_policy, "get_policy", inherited_policy)+ monkeypatch.setattr(+ tool_policy,+ "_policy_tool_names",+ lambda _agent: pytest.fail("inherited policy inventoried tools"),+ )++ assert tool_policy.filter_tool_prompt(+ agent, "agent.system.tool.shell.md", prompt+ ) == prompt+ assert policy_reads == 1++def test_required_response_survives_default_block(monkeypatch, tmp_path: Path) -> None:_write_prompt(tmp_path,