mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
The system-prompt directive layer and the briefing block both opened
with "FIRST ACTION REQUIRED: run ToolSearch to activate deferred
Edit/Write". That premise is false: per Claude Code 2.1.114, ToolSearch
gates only deferred MCP tools, never built-ins — and it is not even a
callable tool in the agent runtime. Built-ins are loaded at spawn via
the `--tools` flag and gated solely by the per-role permission rules
(the actual Edit/Write breakage was the global Write(*)/Edit(*) deny +
single-slash path, fixed in c0ba335). So weak models dutifully chased a
nonexistent ToolSearch, concluded Edit/Write were unavailable, and
rewrote whole files via destructive shell redirection.
Both touch points now affirm the role's built-in tools are loaded and
ready, tell the agent NOT to call ToolSearch, and (for authoring roles)
explicitly steer away from whole-file shell redirection — directly
countering the clobber behaviour. Role prompt files (developer,
cell_pm, main_pm, board) updated to match. Dead
_read_tool_load_from_role_prompt (no callers) removed. Directive tests
rewritten to lock the corrected behaviour.
80 lines
2.9 KiB
Python
80 lines
2.9 KiB
Python
"""#167: the briefing's _build_tool_load_block must not push ToolSearch.
|
|
|
|
Earlier (smoke-8) the block instructed agents to run a ToolSearch call
|
|
to "activate deferred built-in tools". That premise was false —
|
|
ToolSearch is MCP-only, never gates built-ins, and is not callable in
|
|
the agent runtime — so weak models chased a nonexistent tool and fell
|
|
back to destructive shell file-writes. The real cause of "Edit not
|
|
enabled in this context" was a permission bug fixed separately.
|
|
|
|
The block now affirms the role's built-in tools are loaded and ready,
|
|
tells the agent NOT to call ToolSearch, and (for authoring roles)
|
|
steers away from whole-file shell redirection.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from unittest.mock import patch
|
|
|
|
from roboco.runtime.orchestrator import AgentOrchestrator
|
|
|
|
|
|
def _orch() -> AgentOrchestrator:
|
|
with patch.object(AgentOrchestrator, "__init__", return_value=None):
|
|
orch = AgentOrchestrator.__new__(AgentOrchestrator)
|
|
orch._TOOL_LOAD_CACHE = {}
|
|
return orch
|
|
|
|
|
|
def _tool_names(block: str) -> list[str]:
|
|
"""Exact tool tokens (so 'TodoWrite' is not mistaken for 'Write')."""
|
|
line = next(ln for ln in block.splitlines() if "available now:" in ln)
|
|
seg = line.split("available now: ", 1)[1]
|
|
return seg.split(".", 1)[0].split(", ")
|
|
|
|
|
|
def test_developer_block_affirms_tools_no_toolsearch_call() -> None:
|
|
block = _orch()._build_tool_load_block("developer")
|
|
assert "Your tools are ready" in block
|
|
assert "ToolSearch(query=" not in block
|
|
assert "are deferred" not in block
|
|
names = _tool_names(block)
|
|
assert "Edit" in names and "Write" in names
|
|
|
|
|
|
def test_developer_block_steers_away_from_shell_redirection() -> None:
|
|
block = _orch()._build_tool_load_block("developer")
|
|
assert "shell redirection" in block
|
|
assert "Edit/Write" in block
|
|
|
|
|
|
def test_documenter_block_lists_edit_and_write() -> None:
|
|
names = _tool_names(_orch()._build_tool_load_block("documenter"))
|
|
assert "Edit" in names and "Write" in names
|
|
|
|
|
|
def test_qa_block_excludes_edit_and_write() -> None:
|
|
block = _orch()._build_tool_load_block("qa")
|
|
assert "Your tools are ready" in block
|
|
names = _tool_names(block)
|
|
assert "Edit" not in names and "Write" not in names
|
|
assert "Read" in names and "Bash" in names
|
|
|
|
|
|
def test_pm_blocks_exclude_edit_and_write() -> None:
|
|
for role in ("main_pm", "cell_pm", "product_owner", "head_marketing", "auditor"):
|
|
names = _tool_names(_orch()._build_tool_load_block(role))
|
|
assert "Edit" not in names, f"{role} must not list Edit"
|
|
assert "Write" not in names, f"{role} must not list Write"
|
|
|
|
|
|
def test_unknown_role_returns_empty() -> None:
|
|
assert _orch()._build_tool_load_block("nonexistent") == ""
|
|
|
|
|
|
def test_role_cache_works() -> None:
|
|
orch = _orch()
|
|
first = orch._build_tool_load_block("developer")
|
|
second = orch._build_tool_load_block("developer")
|
|
assert first is second
|