Skip to content
Closed
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
5 changes: 5 additions & 0 deletions agent/background_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,11 @@ def _bg_review_auto_deny(command, description, **kwargs):
quiet_mode=True,
)
}
# Allow read-only file tools β€” they have no side effects and
# are needed for the review agent to inspect config, prior

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the unchanged review prompt and denial text below as well: they still say only memory/skill tools are allowed and explicitly tell the model not to attempt other tools. Without that, the model is instructed not to use this newly permitted tool.

# outputs, or skill references (issue #45877).
review_whitelist.add("read_file")
review_whitelist.add("search_files")
set_thread_tool_whitelist(
review_whitelist,
deny_msg_fmt=(
Expand Down
66 changes: 66 additions & 0 deletions tests/run_agent/test_background_review_cache_parity.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,69 @@ def close(self):
f"disabled_toolsets mismatch: {captured.get('disabled_toolsets')!r} "
f"vs expected {agent.disabled_toolsets!r}"
)


def test_background_review_whitelist_includes_read_only_file_tools():
"""read_file and search_files must be allowed in background review (issue #45877).

These tools are read-only and side-effect-free β€” blocking them forces
cron agents to use terminal(cat/grep) workarounds or operate blindly.
"""
import run_agent

agent = _make_agent_stub(run_agent.AIAgent)

captured = {}

class _Recorder:
"""Lightweight stand-in for AIAgent that avoids provider resolution."""

def __init__(self, *args, **kwargs):
self._cached_system_prompt = None
self._memory_write_origin = None
self._memory_write_context = None
self._memory_store = None
self._memory_enabled = None
self._user_profile_enabled = None
self._memory_nudge_interval = None
self._skill_nudge_interval = None
self.suppress_status_output = None
self.session_start = None
self.session_id = None
self.compression_enabled = True

def run_conversation(self, *args, **kwargs):
raise RuntimeError("stop after recording β€” don't actually call the API")

def shutdown_memory_provider(self):
pass

def close(self):
pass

# Intercept set_thread_tool_whitelist to capture the whitelist set.
def _capturing_stwl(whitelist, **kwargs):
captured["whitelist"] = set(whitelist)

import hermes_cli.plugins as _plugins_mod

with patch.object(run_agent, "AIAgent", _Recorder), \
patch("threading.Thread", _SyncThread), \
patch.object(_plugins_mod, "set_thread_tool_whitelist", _capturing_stwl):
agent._spawn_background_review(
messages_snapshot=[],
review_memory=True,
review_skills=False,
)

assert "whitelist" in captured, (
"set_thread_tool_whitelist was never called β€” "
"review may have failed before reaching whitelist setup"
)
tools = captured["whitelist"]
assert "read_file" in tools, (
"read_file must be in the background review whitelist"
)
assert "search_files" in tools, (
"search_files must be in the background review whitelist"
)
Loading