Skip to content

hotfix: fix dispatch command breaking on multi-line prompts#653

Merged
marcusquinn merged 1 commit intomainfrom
hotfix/dispatch-multiline-prompt
Feb 8, 2026
Merged

hotfix: fix dispatch command breaking on multi-line prompts#653
marcusquinn merged 1 commit intomainfrom
hotfix/dispatch-multiline-prompt

Conversation

@marcusquinn
Copy link
Owner

Summary

  • Fixes supervisor worker dispatch failing silently when prompts contain newlines (from t173 worker restrictions)
  • Workers were receiving malformed commands and printing help text instead of executing tasks
  • Root cause: printf '%q' produces $'\n' sequences that break inside bash -c double-quoted strings

Root Cause

build_dispatch_cmd() correctly builds multi-line prompts (task description + worker restrictions + memory context). But cmd_dispatch() embeds the escaped command in a bash -c string:

nohup bash -c "... && $(printf '%q ' "${cmd_parts[@]}") > ..." &

The $'\n' from printf '%q' gets split across lines inside the double-quoted bash -c argument, producing invalid syntax. The worker process receives a truncated/malformed command and exits immediately with the help text.

Fix

Write dispatch commands to temp script files (pids/{task_id}-dispatch.sh) and execute those instead. The printf '%q' output is valid bash when written to its own file — the $'\n' sequences are interpreted correctly by the script's own bash process.

Applied to both cmd_dispatch (tabby + headless paths) and cmd_reprompt.

Impact

  • All supervisor-dispatched workers since PR fix: enforce worker TODO.md restriction with multi-layer guards (t173) #649 (t173) were affected — the multi-line worker restriction text was added in that PR
  • This explains why t175 and t176 immediately failed with ambiguous_skipped_ai (EXIT:1, 28-line logs containing only help text)
  • The batch self-improvement-02 will work after this fix is deployed

Testing

  • ShellCheck: zero violations
  • All 78 supervisor state machine tests pass (77 passed, 1 skipped)
  • Verified generated dispatch script is syntactically valid (bash -n passes)
  • Verified $'\n' sequences are correctly interpreted in standalone script files

The bash -c construction used printf '%q' to escape cmd_parts, but
multi-line prompts (from t173 worker restrictions) produce $'\n'
sequences that break when embedded in bash -c double-quoted strings.
Workers received malformed commands and printed help text instead of
executing.

Fix: write dispatch commands to temp script files in pids/ directory
and execute those instead. This is robust regardless of prompt content.
Fixes both cmd_dispatch (tabby + headless) and cmd_reprompt paths.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 8, 2026

Warning

Rate limit exceeded

@marcusquinn has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 14 minutes and 40 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch hotfix/dispatch-multiline-prompt

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link

Summary of Changes

Hello @marcusquinn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical issue where supervisor-dispatched workers would silently fail when processing multi-line prompts. The problem was traced to how bash -c incorrectly handles printf '%q' output containing newlines when embedded directly. The solution involves refactoring the command dispatch mechanism to write the full command into a temporary, executable shell script, which is then executed, ensuring correct interpretation of complex multi-line commands and restoring proper worker functionality.

Highlights

  • Problem Addressed: Fixes silent failures in supervisor worker dispatch when prompts contain newlines, which caused workers to receive malformed commands and print help text instead of executing tasks.
  • Root Cause Identified: The issue stemmed from printf '%q' generating $'\n' sequences that were incorrectly parsed when embedded within bash -c double-quoted strings, leading to invalid syntax.
  • Solution Implemented: Dispatch commands are now written to temporary, executable shell script files (e.g., pids/{task_id}-dispatch.sh or pids/{task_id}-reprompt.sh) and then executed. This approach ensures correct interpretation of $'\n' sequences by the script's own bash process, bypassing the bash -c quoting problem.
  • Impact: This fix resolves issues for all supervisor-dispatched workers affected by multi-line worker restrictions introduced in PR fix: enforce worker TODO.md restriction with multi-layer guards (t173) #649, explaining previous immediate failures like ambiguous_skipped_ai.
  • Verification: The changes have been validated with ShellCheck (zero violations), all 78 supervisor state machine tests (77 passed, 1 skipped), and explicit checks for generated dispatch script syntactic validity (bash -n passes) and correct interpretation of newline sequences in standalone scripts.
Changelog
  • .agents/scripts/supervisor-helper.sh
    • Introduced a new mechanism to create temporary dispatch scripts (pids/{task_id}-dispatch.sh and pids/{task_id}-reprompt.sh) for cmd_dispatch and cmd_reprompt functions.
    • These scripts encapsulate the full command, including cd, export, and the exec call with properly quoted command parts.
    • The nohup bash -c calls in cmd_dispatch (for both tabby and headless modes) and cmd_reprompt were updated to execute these newly created temporary scripts instead of directly embedding the command string, thereby resolving quoting issues with multi-line prompts.
Activity
  • No specific activity (comments, reviews, progress updates) has been provided in the context.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link

github-actions bot commented Feb 8, 2026

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 37 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Sun Feb 8 19:43:05 UTC 2026: Code review monitoring started
Sun Feb 8 19:43:05 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 37

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 37
  • VULNERABILITIES: 0

Generated on: Sun Feb 8 19:43:08 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 8, 2026

@marcusquinn marcusquinn merged commit e9a4566 into main Feb 8, 2026
11 checks passed
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively resolves a critical issue where multi-line prompts broke command dispatching. The solution of writing commands to temporary script files instead of using bash -c with complex quoting is a solid approach. My review identifies a minor issue with this new approach: the temporary dispatch scripts are not cleaned up after execution, which can lead to file accumulation and violates the repository's style guide. I've provided suggestions to add cleanup steps to the execution commands.

Comment on lines 3130 to 3144
if [[ "$dispatch_mode" == "tabby" ]]; then
# Tabby: attempt to open in a new tab via OSC 1337 escape sequence
log_info "Opening Tabby tab for $task_id..."
local tab_cmd
tab_cmd="cd '${worktree_path}' && ${headless_env} ${cmd_parts[*]} > '${log_file}' 2>&1; echo \"EXIT:\$?\" >> '${log_file}'"
tab_cmd="'${dispatch_script}' > '${log_file}' 2>&1; echo \"EXIT:\$?\" >> '${log_file}'"
printf '\e]1337;NewTab=%s\a' "$tab_cmd" 2>/dev/null || true
# Also start background process as fallback (Tabby may not support OSC 1337)
# Use nohup + disown to survive parent (cron) exit
nohup bash -c "cd '${worktree_path}' && export ${headless_env} && $(printf '%q ' "${cmd_parts[@]}") > '${log_file}' 2>&1; echo \"EXIT:\$?\" >> '${log_file}'" &>/dev/null &
nohup bash -c "'${dispatch_script}' > '${log_file}' 2>&1; echo \"EXIT:\$?\" >> '${log_file}'" &>/dev/null &
else
# Headless: background process
# Use nohup + disown to survive parent (cron) exit — without this,
# workers die after ~2 minutes when the cron pulse script exits
nohup bash -c "cd '${worktree_path}' && export ${headless_env} && $(printf '%q ' "${cmd_parts[@]}") > '${log_file}' 2>&1; echo \"EXIT:\$?\" >> '${log_file}'" &>/dev/null &
nohup bash -c "'${dispatch_script}' > '${log_file}' 2>&1; echo \"EXIT:\$?\" >> '${log_file}'" &>/dev/null &
fi

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The newly created dispatch_script is not removed after execution. This will lead to an accumulation of script files in the pids directory over time. The repository style guide requires that temporary files are cleaned up.

To address this, I suggest appending a cleanup command (rm -f '${dispatch_script}') to the commands that execute the script.

Suggested change
if [[ "$dispatch_mode" == "tabby" ]]; then
# Tabby: attempt to open in a new tab via OSC 1337 escape sequence
log_info "Opening Tabby tab for $task_id..."
local tab_cmd
tab_cmd="cd '${worktree_path}' && ${headless_env} ${cmd_parts[*]} > '${log_file}' 2>&1; echo \"EXIT:\$?\" >> '${log_file}'"
tab_cmd="'${dispatch_script}' > '${log_file}' 2>&1; echo \"EXIT:\$?\" >> '${log_file}'"
printf '\e]1337;NewTab=%s\a' "$tab_cmd" 2>/dev/null || true
# Also start background process as fallback (Tabby may not support OSC 1337)
# Use nohup + disown to survive parent (cron) exit
nohup bash -c "cd '${worktree_path}' && export ${headless_env} && $(printf '%q ' "${cmd_parts[@]}") > '${log_file}' 2>&1; echo \"EXIT:\$?\" >> '${log_file}'" &>/dev/null &
nohup bash -c "'${dispatch_script}' > '${log_file}' 2>&1; echo \"EXIT:\$?\" >> '${log_file}'" &>/dev/null &
else
# Headless: background process
# Use nohup + disown to survive parent (cron) exit — without this,
# workers die after ~2 minutes when the cron pulse script exits
nohup bash -c "cd '${worktree_path}' && export ${headless_env} && $(printf '%q ' "${cmd_parts[@]}") > '${log_file}' 2>&1; echo \"EXIT:\$?\" >> '${log_file}'" &>/dev/null &
nohup bash -c "'${dispatch_script}' > '${log_file}' 2>&1; echo \"EXIT:\$?\" >> '${log_file}'" &>/dev/null &
fi
if [[ "$dispatch_mode" == "tabby" ]]; then
# Tabby: attempt to open in a new tab via OSC 1337 escape sequence
log_info "Opening Tabby tab for $task_id..."
local tab_cmd
tab_cmd="'${dispatch_script}' > '${log_file}' 2>&1; echo \"EXIT:\$?\" >> '${log_file}'; rm -f '${dispatch_script}'"
printf '\e]1337;NewTab=%s\a' "$tab_cmd" 2>/dev/null || true
# Also start background process as fallback (Tabby may not support OSC 1337)
# Use nohup + disown to survive parent (cron) exit
nohup bash -c "'${dispatch_script}' > '${log_file}' 2>&1; echo \"EXIT:\$?\" >> '${log_file}'; rm -f '${dispatch_script}'" &>/dev/null &
else
# Headless: background process
# Use nohup + disown to survive parent (cron) exit — without this,
# workers die after ~2 minutes when the cron pulse script exits
nohup bash -c "'${dispatch_script}' > '${log_file}' 2>&1; echo \"EXIT:\$?\" >> '${log_file}'; rm -f '${dispatch_script}'" &>/dev/null &
fi
References
  1. Rule feat: add /session-review and /full-loop commands for comprehensive AI workflow #33 states that temporary files must have a trap cleanup. While a trap is not directly applicable here due to the background process, the principle of cleaning up temporary files still applies. The generated dispatch scripts are temporary and should be removed after use. (link)


# Use nohup + disown to survive parent (cron) exit
nohup bash -c "cd '${work_dir}' && $(printf '%q ' "${cmd_parts[@]}") > '${new_log_file}' 2>&1; echo \"EXIT:\$?\" >> '${new_log_file}'" &>/dev/null &
nohup bash -c "'${dispatch_script}' > '${new_log_file}' 2>&1; echo \"EXIT:\$?\" >> '${new_log_file}'" &>/dev/null &

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The temporary dispatch_script created for reprompting is not cleaned up after execution, which violates the style guide rule for temporary files. This will cause script files to accumulate in the pids directory.

Suggested change
nohup bash -c "'${dispatch_script}' > '${new_log_file}' 2>&1; echo \"EXIT:\$?\" >> '${new_log_file}'" &>/dev/null &
nohup bash -c "'${dispatch_script}' > '${new_log_file}' 2>&1; echo \"EXIT:\$?\" >> '${new_log_file}'; rm -f '${dispatch_script}'" &>/dev/null &
References
  1. Rule feat: add /session-review and /full-loop commands for comprehensive AI workflow #33 states that temporary files must have a trap cleanup. The principle of cleaning up temporary files applies here. The generated dispatch scripts are temporary and should be removed after use. (link)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant