diff --git a/agent/background_review.py b/agent/background_review.py index d9f6ea5950de..bb879cde1edb 100644 --- a/agent/background_review.py +++ b/agent/background_review.py @@ -474,19 +474,21 @@ def _bg_review_auto_deny(command, description, **kwargs): quiet_mode=True, ) } + # Allow read-only file tools for cron background review (issue #45877) + review_whitelist.update({"read_file", "search_files"}) set_thread_tool_whitelist( review_whitelist, deny_msg_fmt=( "Background review denied non-whitelisted tool: " - "{tool_name}. Only memory/skill tools are allowed." + "{tool_name}. Only memory/skill/read-only-file tools are allowed." ), ) try: review_agent.run_conversation( user_message=( prompt - + "\n\nYou can only call memory and skill " - "management tools. Other tools will be denied " + + "\n\nYou can only call memory, skill management, and read-only file " + "tools (read_file, search_files). Other tools will be denied " "at runtime — do not attempt them." ), conversation_history=messages_snapshot, diff --git a/tests/run_agent/test_background_review_toolset_restriction.py b/tests/run_agent/test_background_review_toolset_restriction.py index f94ef831ae94..1b79cd5e0e72 100644 --- a/tests/run_agent/test_background_review_toolset_restriction.py +++ b/tests/run_agent/test_background_review_toolset_restriction.py @@ -127,12 +127,18 @@ def _no_init(self, *args, **kwargs): assert "skill_manage" in whitelist assert "skill_view" in whitelist assert "skills_list" in whitelist + # read-only file tools must be allowed (issue #45877) + assert "read_file" in whitelist + assert "search_files" in whitelist # dangerous tools must NOT be in the whitelist assert "terminal" not in whitelist assert "send_message" not in whitelist assert "delegate_task" not in whitelist assert "web_search" not in whitelist assert "execute_code" not in whitelist + # write file tools must NOT be in the whitelist + assert "write_file" not in whitelist + assert "patch" not in whitelist def test_background_review_agent_tools_are_limited():