fix: pass harness prompts through stdin

This commit is contained in:
김경종
2026-06-12 17:30:25 +09:00
parent 13cf2af899
commit 2bab84beb6
2 changed files with 26 additions and 2 deletions
+2 -2
View File
@@ -373,8 +373,8 @@ class StepExecutor:
prompt = preamble + step_file.read_text(encoding="utf-8")
result = subprocess.run(
["codex", "exec", "--dangerously-bypass-approvals-and-sandbox", "--json", prompt],
cwd=self._root, capture_output=True, text=True, timeout=1800,
["codex", "exec", "--dangerously-bypass-approvals-and-sandbox", "--json", "-"],
cwd=self._root, capture_output=True, text=True, input=prompt, timeout=1800,
)
if result.returncode != 0:
+24
View File
@@ -281,6 +281,30 @@ class ExecuteRunnerSafetyTests(unittest.TestCase):
self.assertEqual(cm.exception.code, 1)
def test_invoke_codex_passes_prompt_through_stdin(self):
execute = load_execute()
with tempfile.TemporaryDirectory() as tmp:
root = Path(tmp)
write_phase(root)
executor = make_executor(execute, root)
step = {"step": 1, "name": "Docs"}
long_preamble = "x" * 40000
def fake_run(cmd, **kwargs):
return subprocess.CompletedProcess(cmd, 0, '{"event":"done"}\n', "")
with patch.object(execute.subprocess, "run", side_effect=fake_run) as run_mock:
executor._invoke_codex(step, long_preamble)
cmd = run_mock.call_args.args[0]
kwargs = run_mock.call_args.kwargs
self.assertEqual(
cmd,
["codex", "exec", "--dangerously-bypass-approvals-and-sandbox", "--json", "-"],
)
self.assertEqual(kwargs["input"], long_preamble + "# Step 1\n")
self.assertEqual(kwargs["cwd"], str(root))
if __name__ == "__main__":
unittest.main()