commit 69173d2750e5cab2d6a94d1c152116be336341c2
parent 77e7e9a06140edc233811dccc1cb005b0402575d
Author: Brian Graham <brian@buildingbetterteams.de>
Date: Wed, 8 Apr 2026 09:21:29 +0200
Fix large prompt handling: use wrapper script instead of bash -c
bash -c with $(cat) broke on quotes in settings JSON.
Now writes a shell wrapper script that reads the prompt from file.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Diffstat:
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/harness/run.py b/harness/run.py
@@ -270,12 +270,15 @@ def invoke_claude(cell: dict, workspace: Path, run_dir: Path, project_dir: Path,
if ctx_file.exists():
cmd_base.extend(["--append-system-prompt", ctx_file.read_text()])
- # Build final command: for large prompts, use shell to read from file
+ # Build final command: for large prompts, write a shell wrapper script
if prompt_file:
- # Use shell to cat the prompt file into -p to avoid arg list limit
- cmd_str = " ".join(shlex.quote(c) for c in cmd_base)
- cmd = ["bash", "-c", f'{cmd_str} -p "$(cat {shlex.quote(str(prompt_file))})"']
- use_shell = False # already wrapped in bash -c
+ wrapper = Path(tempfile.mktemp(suffix=".sh", prefix="run-claude-"))
+ wrapper_lines = ["#!/bin/bash"]
+ wrapper_lines.append(f'PROMPT=$(cat {shlex.quote(str(prompt_file))})')
+ wrapper_lines.append(" ".join(shlex.quote(c) for c in cmd_base) + ' -p "$PROMPT"')
+ wrapper.write_text("\n".join(wrapper_lines))
+ wrapper.chmod(0o755)
+ cmd = ["bash", str(wrapper)]
else:
cmd = [*cmd_base, "-p", prompt]