From 854509d9be674894b893cd7547a8444acb89804b Mon Sep 17 00:00:00 2001 From: Christopher Galpin <52485+CodeOptimist@users.noreply.github.com> Date: Fri, 7 Aug 2026 22:27:29 -0600 Subject: [PATCH] fix: append newline to shell wrapper to protect here-doc terminators When the agent generates a bash command that ends exactly on a here-document delimiter (like `EOF`) or an inline shell comment without a trailing newline, the agent's subshell wrapper `({command});` inadvertently appends the closing `);` directly to that last line. This causes the shell parser to absorb the closing parenthesis into the here-doc body or comment, leaving the subshell unclosed and resulting in a `Syntax error: end of file unexpected (expecting ")")` crash. By inserting a guaranteed newline immediately after the interpolated command `({command}\n);`, we isolate the wrapper's syntax from the LLM's raw output, ensuring here-docs and comments terminate cleanly. --- minion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/minion.py b/minion.py index 07e1079..6ee92f4 100644 --- a/minion.py +++ b/minion.py @@ -1565,7 +1565,7 @@ def _run_bash(command): # Inline: run the command in a subshell, then echo its exit status. # setsid detaches into a new session so terminal Ctrl+C / SIGINT can't # reach the background job. Redirect to the log file ourselves. - inner = f"({command}); echo \"[exit: $?]\"" + inner = f"({command}\n); echo \"[exit: $?]\"" wrapped = (f"setsid sh -c {shlex.quote(inner)} > {shlex.quote(log_path)} 2>&1 < /dev/null &\n" f"echo $!") r = subprocess.run(wrapped, shell=True, capture_output=True, text=True)