fix(agent-loop): answer workspace-trust dialog by piping a newline to stdin
The new Claude Code trust dialog appeared inside the tmux PTY despite -p mode and stdout being piped, blocking the agent indefinitely. With < /dev/null the dialog could never be answered. Replace < /dev/null with printf '\n' | so the Enter keypress confirms the default "Yes, I trust this folder" option. After that single newline stdin reaches EOF, which -p mode ignores. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
130fbbe699
commit
6d4a1a0586
@@ -175,11 +175,14 @@ def _start_agent(prompt: str, session_name: str) -> str:
|
||||
# Kill any stale session with this name before creating a new one.
|
||||
subprocess.run(["tmux", "kill-session", "-t", session_name], capture_output=True)
|
||||
|
||||
# printf '\n' answers the workspace-trust dialog (press Enter to confirm the
|
||||
# default "Yes, I trust this folder") when claude shows it despite -p mode.
|
||||
# After that newline, stdin hits EOF, which -p mode ignores.
|
||||
shell_cmd = (
|
||||
f"claude --dangerously-skip-permissions"
|
||||
f"printf '\\n' | claude --dangerously-skip-permissions"
|
||||
f" --name {shlex.quote(session_name)}"
|
||||
f" -p {shlex.quote(prompt)}"
|
||||
f" < /dev/null 2>&1 | tee {shlex.quote(str(log_file))}"
|
||||
f" 2>&1 | tee {shlex.quote(str(log_file))}"
|
||||
)
|
||||
subprocess.run(
|
||||
["tmux", "new-session", "-d", "-s", session_name, "bash", "-c", shell_cmd],
|
||||
|
||||
Reference in New Issue
Block a user