Load no MCP server in a headless claude call that is denied tools
CI / tests (pull_request) Successful in 3m45s
CI / tests (pull_request) Successful in 3m45s
This commit is contained in:
@@ -208,7 +208,7 @@ def judge_args(rung: Rung, driver: str) -> list[str]:
|
|||||||
return [
|
return [
|
||||||
"--json-schema", json.dumps(judge_schema(driver)),
|
"--json-schema", json.dumps(judge_schema(driver)),
|
||||||
*rung.flags(),
|
*rung.flags(),
|
||||||
"--tools", "",
|
"--tools", "", "--strict-mcp-config",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ def command_of(pid: int, shells: list[Shell]) -> str:
|
|||||||
def investigated(shells: list[Shell], rung: Rung, root: str, effects: Effects) -> dict[str, typing.Any] | Failure:
|
def investigated(shells: list[Shell], rung: Rung, root: str, effects: Effects) -> dict[str, typing.Any] | Failure:
|
||||||
"""A headless claude's verdict on the worker holding shells, as SCHEMA has it, or why there is none. It runs without tools, so it judges only the evidence it is handed."""
|
"""A headless claude's verdict on the worker holding shells, as SCHEMA has it, or why there is none. It runs without tools, so it judges only the evidence it is handed."""
|
||||||
evidence = "\n\n".join(f"Shell {shell.pid}: {shell.command}\nIts processes, as pid, state, CPU and command line:\n{chr(10).join(shell.processes) or 'none'}\nThe end of its output:\n{shell.output or 'none'}" for shell in shells)
|
evidence = "\n\n".join(f"Shell {shell.pid}: {shell.command}\nIts processes, as pid, state, CPU and command line:\n{chr(10).join(shell.processes) or 'none'}\nThe end of its output:\n{shell.output or 'none'}" for shell in shells)
|
||||||
reply = claude_reply(effects.claude, ["--json-schema", json.dumps(SCHEMA), *rung.flags(), "--tools", ""], root, PROMPT + "\n" + evidence, "the stuck check")
|
reply = claude_reply(effects.claude, ["--json-schema", json.dumps(SCHEMA), *rung.flags(), "--tools", "", "--strict-mcp-config"], root, PROMPT + "\n" + evidence, "the stuck check")
|
||||||
if isinstance(reply, Limited):
|
if isinstance(reply, Limited):
|
||||||
return Failure(f"claude hit a limit: {reply.said}")
|
return Failure(f"claude hit a limit: {reply.said}")
|
||||||
if isinstance(reply, Failure):
|
if isinstance(reply, Failure):
|
||||||
|
|||||||
@@ -139,6 +139,11 @@ class JudgePrompt(unittest.TestCase):
|
|||||||
"""What the judge of a-driver reads of a transcript holding entries."""
|
"""What the judge of a-driver reads of a transcript holding entries."""
|
||||||
return judge.Brief("Do it.", "## Goals", records, "the project's decisions", answer_destinations, kinds(*entries), escalated_at, "a-driver")
|
return judge.Brief("Do it.", "## Goals", records, "the project's decisions", answer_destinations, kinds(*entries), escalated_at, "a-driver")
|
||||||
|
|
||||||
|
def test_runs_with_no_tools_and_loads_no_mcp_server(self):
|
||||||
|
args = judge.judge_args(Rung("claude-opus-5-5", "medium"), "a-driver")
|
||||||
|
self.assertEqual(args[args.index("--tools") + 1 :], ["", "--strict-mcp-config"])
|
||||||
|
self.assertNotIn("--mcp-config", args)
|
||||||
|
|
||||||
def test_shows_the_transcripts_tail_and_returns_what_it_showed(self):
|
def test_shows_the_transcripts_tail_and_returns_what_it_showed(self):
|
||||||
entries = [assistant({"type": "text", "text": "old " + "x" * judge.JUDGE_PROMPT_CHARS}), assistant({"type": "text", "text": "new"})]
|
entries = [assistant({"type": "text", "text": "old " + "x" * judge.JUDGE_PROMPT_CHARS}), assistant({"type": "text", "text": "new"})]
|
||||||
prompt, grounds = judge.judge_prompt(self.brief(entries, 0))
|
prompt, grounds = judge.judge_prompt(self.brief(entries, 0))
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class StuckWorkers(unittest.TestCase):
|
|||||||
streamed, fake, said, _, record = self.worker_with(ASSISTANT, None, None, None, held=[shell()], replies=[verdict()])
|
streamed, fake, said, _, record = self.worker_with(ASSISTANT, None, None, None, held=[shell()], replies=[verdict()])
|
||||||
[(args, prompt)] = fake.made("claude")
|
[(args, prompt)] = fake.made("claude")
|
||||||
self.assertEqual(args[args.index("--model") + 1 :][:3], ["claude-opus-5-5", "--effort", "medium"])
|
self.assertEqual(args[args.index("--model") + 1 :][:3], ["claude-opus-5-5", "--effort", "medium"])
|
||||||
self.assertEqual(args[args.index("--tools") + 1], "")
|
self.assertEqual(args[args.index("--tools") + 1 :][:2], ["", "--strict-mcp-config"])
|
||||||
self.assertEqual(json.loads(args[args.index("--json-schema") + 1])["properties"]["verdict"]["enum"], ["working", "waiting on a person", "stuck"])
|
self.assertEqual(json.loads(args[args.index("--json-schema") + 1])["properties"]["verdict"]["enum"], ["working", "waiting on a person", "stuck"])
|
||||||
self.assertTrue(prompt.endswith("\n\nShell 7: bin/run-tests\nIts processes, as pid, state, CPU and command line:\n8 S 2.0 s python3 -m pytest\n9 S 0.0 s sh -c trap '' INT; sleep 999\nThe end of its output:\ncollected 40 items"))
|
self.assertTrue(prompt.endswith("\n\nShell 7: bin/run-tests\nIts processes, as pid, state, CPU and command line:\n8 S 2.0 s python3 -m pytest\n9 S 0.0 s sh -c trap '' INT; sleep 999\nThe end of its output:\ncollected 40 items"))
|
||||||
line = "stuck check: a headless claude judged the worker stuck, naming process 8 (python3 -m pytest): pytest waits on a shell that ignores SIGINT" + sign(1600, 1600)
|
line = "stuck check: a headless claude judged the worker stuck, naming process 8 (python3 -m pytest): pytest waits on a shell that ignores SIGINT" + sign(1600, 1600)
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class Scores:
|
|||||||
|
|
||||||
def asked(issue: EpicIssue, rule: str, goals: str, language: str, rung: Rung, claude: Claude, cwd: str) -> Scores | Failure | Limited:
|
def asked(issue: EpicIssue, rule: str, goals: str, language: str, rung: Rung, claude: Claude, cwd: str) -> Scores | Failure | Limited:
|
||||||
"""The scores claude gives the issue. rule is the text every plan item is scored by, and goals says which goals the issue may move and how to name each. Nothing is written: the caller checks the answer against the plan's format and sets it."""
|
"""The scores claude gives the issue. rule is the text every plan item is scored by, and goals says which goals the issue may move and how to name each. Nothing is written: the caller checks the answer against the plan's format and sets it."""
|
||||||
reply = claude_reply(claude, ["--json-schema", json.dumps(SCHEMA), *rung.flags(), "--tools", ""], cwd, prompt(issue, rule, goals, language), "the scoring")
|
reply = claude_reply(claude, ["--json-schema", json.dumps(SCHEMA), *rung.flags(), "--tools", "", "--strict-mcp-config"], cwd, prompt(issue, rule, goals, language), "the scoring")
|
||||||
return reply if isinstance(reply, Failure | Limited) else answer_of(structured_output(reply))
|
return reply if isinstance(reply, Failure | Limited) else answer_of(structured_output(reply))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ def picked(store: EpicStore, issue: EpicIssue, team: LabelRepos, rule: str, rung
|
|||||||
known = recorded(issue, team)
|
known = recorded(issue, team)
|
||||||
if known is not None:
|
if known is not None:
|
||||||
return known
|
return known
|
||||||
reply = claude_reply(claude, ["--json-schema", json.dumps(PICK_SCHEMA), *rung.flags(), "--tools", ""], cwd, prompt(rule, issue), "the repo pick")
|
reply = claude_reply(claude, ["--json-schema", json.dumps(PICK_SCHEMA), *rung.flags(), "--tools", "", "--strict-mcp-config"], cwd, prompt(rule, issue), "the repo pick")
|
||||||
if isinstance(reply, Failure | Limited):
|
if isinstance(reply, Failure | Limited):
|
||||||
return reply
|
return reply
|
||||||
answer = answer_of(structured_output(reply))
|
answer = answer_of(structured_output(reply))
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ def finished(issues: list[EpicIssue], key: str) -> bool:
|
|||||||
|
|
||||||
def prediction(issue: EpicIssue, by_person: bool, rule: str, language: str, checkouts: tuple[str, ...], rung: Rung, claude: Claude, cwd: str) -> Prediction | Failure | Limited:
|
def prediction(issue: EpicIssue, by_person: bool, rule: str, language: str, checkouts: tuple[str, ...], rung: Rung, claude: Claude, cwd: str) -> Prediction | Failure | Limited:
|
||||||
"""The repos claude predicts the item changes, from the code in checkouts."""
|
"""The repos claude predicts the item changes, from the code in checkouts."""
|
||||||
flags = ["--json-schema", json.dumps(SPLIT_SCHEMA), *rung.flags(), "--tools", "Read,Grep,Glob", *(arg for each in checkouts for arg in ("--add-dir", each))]
|
flags = ["--json-schema", json.dumps(SPLIT_SCHEMA), *rung.flags(), "--tools", "Read,Grep,Glob", "--strict-mcp-config", *(arg for each in checkouts for arg in ("--add-dir", each))]
|
||||||
reply = claude_reply(claude, flags, cwd, prompt(issue, by_person, rule, language, checkouts), "the repo split")
|
reply = claude_reply(claude, flags, cwd, prompt(issue, by_person, rule, language, checkouts), "the repo split")
|
||||||
return reply if isinstance(reply, Failure | Limited) else answer_of(structured_output(reply))
|
return reply if isinstance(reply, Failure | Limited) else answer_of(structured_output(reply))
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class TheCall(unittest.TestCase):
|
|||||||
self.assertEqual(self.ask(claude), answer_of(ANSWER))
|
self.assertEqual(self.ask(claude), answer_of(ANSWER))
|
||||||
args, cwd, _ = claude.calls[0]
|
args, cwd, _ = claude.calls[0]
|
||||||
self.assertEqual(cwd, "/state/scoring")
|
self.assertEqual(cwd, "/state/scoring")
|
||||||
self.assertEqual(args[:9], ["-p", "--json-schema", json.dumps(SCHEMA), "--model", "claude-sonnet-5-5", "--effort", "medium", "--tools", ""])
|
self.assertEqual(args[:10], ["-p", "--json-schema", json.dumps(SCHEMA), "--model", "claude-sonnet-5-5", "--effort", "medium", "--tools", "", "--strict-mcp-config"])
|
||||||
|
|
||||||
def test_names_the_scoring_where_claude_fails(self) -> None:
|
def test_names_the_scoring_where_claude_fails(self) -> None:
|
||||||
failed = self.ask(Claude("", 1))
|
failed = self.ask(Claude("", 1))
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class RepoPick(unittest.TestCase):
|
|||||||
self.pick(claude)
|
self.pick(claude)
|
||||||
args, cwd, _ = claude.calls[0]
|
args, cwd, _ = claude.calls[0]
|
||||||
self.assertEqual(cwd, "/rules")
|
self.assertEqual(cwd, "/rules")
|
||||||
self.assertEqual(args[:9], ["-p", "--json-schema", json.dumps(PICK_SCHEMA), "--model", "claude-sonnet-5-5", "--effort", "medium", "--tools", ""])
|
self.assertEqual(args[:10], ["-p", "--json-schema", json.dumps(PICK_SCHEMA), "--model", "claude-sonnet-5-5", "--effort", "medium", "--tools", "", "--strict-mcp-config"])
|
||||||
|
|
||||||
def test_puts_the_rule_and_the_item_in_the_prompt(self) -> None:
|
def test_puts_the_rule_and_the_item_in_the_prompt(self) -> None:
|
||||||
claude = says({"pick": "claude"})
|
claude = says({"pick": "claude"})
|
||||||
|
|||||||
@@ -156,8 +156,8 @@ class Split_(unittest.TestCase):
|
|||||||
self.run_split(claude)
|
self.run_split(claude)
|
||||||
args, cwd, prompt = claude.calls[0]
|
args, cwd, prompt = claude.calls[0]
|
||||||
self.assertEqual(cwd, "/rules")
|
self.assertEqual(cwd, "/rules")
|
||||||
self.assertEqual(args[:12], ["-p", "--json-schema", json.dumps(SPLIT_SCHEMA), "--model", "claude-sonnet-5-5", "--effort", "medium", "--tools", "Read,Grep,Glob", "--add-dir", "/repos/api", "--add-dir"])
|
self.assertEqual(args[:13], ["-p", "--json-schema", json.dumps(SPLIT_SCHEMA), "--model", "claude-sonnet-5-5", "--effort", "medium", "--tools", "Read,Grep,Glob", "--strict-mcp-config", "--add-dir", "/repos/api", "--add-dir"])
|
||||||
self.assertEqual(args[12], "/repos/web")
|
self.assertEqual(args[13], "/repos/web")
|
||||||
self.assertIn(RULE, prompt)
|
self.assertIn(RULE, prompt)
|
||||||
self.assertIn("## Item ABC-100: Count the runs.", prompt)
|
self.assertIn("## Item ABC-100: Count the runs.", prompt)
|
||||||
self.assertIn("write each part's change in Swedish.", prompt)
|
self.assertIn("write each part's change in Swedish.", prompt)
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ def match(findings: tuple[str, ...], replay_report: str, root: str, rung: Rung,
|
|||||||
"A finding it raises only as 🟢 or ❓, or not at all, is not listed.\n\n"
|
"A finding it raises only as 🟢 or ❓, or not at all, is not listed.\n\n"
|
||||||
f"The findings:\n{numbered}\n\nThe other report:\n{replay_report}"
|
f"The findings:\n{numbered}\n\nThe other report:\n{replay_report}"
|
||||||
)
|
)
|
||||||
args = ["--json-schema", json.dumps(MATCH_SCHEMA), *rung.flags(), "--tools", ""]
|
args = ["--json-schema", json.dumps(MATCH_SCHEMA), *rung.flags(), "--tools", "", "--strict-mcp-config"]
|
||||||
reply = claude_reply(effects.claude, args, root, prompt, "claude")
|
reply = claude_reply(effects.claude, args, root, prompt, "claude")
|
||||||
if isinstance(reply, Failure | Limited):
|
if isinstance(reply, Failure | Limited):
|
||||||
return reply
|
return reply
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ class Match(unittest.TestCase):
|
|||||||
self.assertEqual(cwd, "/code/p")
|
self.assertEqual(cwd, "/code/p")
|
||||||
self.assertIn("1. 🔴 a\n\n2. 🟡 b\n\nThe other report:\nthe other report", prompt)
|
self.assertIn("1. 🔴 a\n\n2. 🟡 b\n\nThe other report:\nthe other report", prompt)
|
||||||
self.assertEqual(json.loads(args[args.index("--json-schema") + 1]), replay.MATCH_SCHEMA)
|
self.assertEqual(json.loads(args[args.index("--json-schema") + 1]), replay.MATCH_SCHEMA)
|
||||||
self.assertEqual(args[args.index("--tools") + 1], "")
|
self.assertEqual(args[args.index("--tools") + 1 :][:2], ["", "--strict-mcp-config"])
|
||||||
self.assertEqual(args[args.index("--model"):args.index("--model") + 4], REFERENCE.flags())
|
self.assertEqual(args[args.index("--model"):args.index("--model") + 4], REFERENCE.flags())
|
||||||
|
|
||||||
def test_takes_the_numbers_in_range_and_fails_on_a_reply_of_another_shape(self):
|
def test_takes_the_numbers_in_range_and_fails_on_a_reply_of_another_shape(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user