fix: revert -p removal — Claude -p mode has full tool access

Claude -p (print mode) is non-interactive but retains full tool access
(Edit, Write, Bash, etc.) with --dangerously-skip-permissions. Removing
-p caused Claude to enter interactive mode which requires a TTY and
produces zero output when run as a subprocess with piped I/O.

Now delivers prompt via stdin for both Claude and Codex in agentic mode.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
chungyeong
2026-03-13 23:13:12 +09:00
parent d5fcc258b7
commit 99cbf171aa

View File

@@ -28,6 +28,12 @@ _NO_CHANGE_ACK_MARKERS = (
"no modifications were necessary", "no modifications were necessary",
"no update was necessary", "no update was necessary",
"already satisfied", "already satisfied",
"no changes needed",
"no fixes needed",
"everything is correct",
"code is correct as-is",
"already correct",
"no action required",
) )
_CHANGE_CLAIM_MARKERS = ( _CHANGE_CLAIM_MARKERS = (
"summary of all changes made", "summary of all changes made",
@@ -59,6 +65,14 @@ _CHANGE_CLAIM_MARKERS = (
"wrote the code", "wrote the code",
"refactored", "refactored",
"i refactored", "i refactored",
"completed all the changes",
"finished implementing",
"all tasks completed",
"done with the implementation",
"successfully implemented",
"completed the implementation",
"all changes have been made",
"changes are complete",
) )
@@ -419,11 +433,10 @@ def invoke_agent_agentic(
if agent.reasoning_effort and _supports_reasoning_effort(agent.command): if agent.reasoning_effort and _supports_reasoning_effort(agent.command):
cmd.extend(["-c", f'model_reasoning_effort="{agent.reasoning_effort}"']) cmd.extend(["-c", f'model_reasoning_effort="{agent.reasoning_effort}"'])
# Strip print-mode flags and stdin sentinel from args for agentic mode. # Strip stdin sentinel ("-") from args for agentic mode.
# -p / --print makes Claude a one-shot text completer that cannot use tools # Keep -p/--print: Claude -p mode still has full tool access (Edit, Write,
# or modify files, which defeats the entire purpose of agentic execution. # Bash, etc.) and is the correct mode for non-interactive subprocess use.
_STRIP_FOR_AGENTIC = {"-", "-p", "--print"} args = [a for a in agent.args if a != "-"]
args = [a for a in agent.args if a not in _STRIP_FOR_AGENTIC]
cmd.extend(args) cmd.extend(args)
# System prompt via flag if supported # System prompt via flag if supported
@@ -441,16 +454,9 @@ def invoke_agent_agentic(
else: else:
input_data = prompt input_data = prompt
else: else:
# claude: use positional arg with a pointer to the task file # claude -p: deliver prompt via stdin (same as codex).
# (avoids OS arg length limits for large prompts). # -p mode is non-interactive and reads from stdin, then exits.
# Send empty stdin so Claude receives EOF and exits after processing input_data = prompt
# instead of hanging in interactive mode waiting for more input.
input_data = ""
cmd.append(
f"Read the task file at {task_file} and execute all instructions in it. "
f"Work only inside the current directory and do not modify files "
f"outside it."
)
cmd_preview = " ".join(cmd[:6]) cmd_preview = " ".join(cmd[:6])
logger.debug( logger.debug(