Skip to content

Commit 20cc138

Browse files
jahoomaclaude
andcommitted
Remove wait-for command from tmux CLI agent
The wait-for command frequently causes 30-100s delays waiting for patterns that never appear. Replace all references with wait-idle, which is more reliable for waiting on output stabilization. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f0636fc commit 20cc138

File tree

1 file changed

+5
-39
lines changed

1 file changed

+5
-39
lines changed

agents/tmux-cli.ts

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const outputSchema = {
3535
items: {
3636
type: 'object' as const,
3737
properties: {
38-
script: { type: 'string' as const, description: 'Which helper command had the issue (e.g., "send", "capture", "wait-for")' },
38+
script: { type: 'string' as const, description: 'Which helper command had the issue (e.g., "send", "capture", "wait-idle")' },
3939
issue: { type: 'string' as const, description: 'What went wrong when using the helper script' },
4040
errorOutput: { type: 'string' as const, description: 'The actual error message or unexpected output' },
4141
suggestedFix: { type: 'string' as const, description: 'Suggested fix for the parent agent to implement' },
@@ -178,11 +178,6 @@ Captures show the **visible pane** by default. Add \`--full\` for the entire scr
178178
### Waiting
179179
180180
\`\`\`bash
181-
# Wait until a pattern appears in the visible pane (regex, default timeout: 30s)
182-
$HELPER wait-for "$SESSION" "Your guess:"
183-
$HELPER wait-for "$SESSION" "\\$" --timeout 10
184-
$HELPER wait-for "$SESSION" "ready" --timeout 60
185-
186181
# Wait until output is stable for N seconds (max 120s)
187182
$HELPER wait-idle "$SESSION" 3
188183
\`\`\`
@@ -210,8 +205,7 @@ If the CLI appears hung, try \`$HELPER key "$SESSION" C-c\` to interrupt. If it'
210205
- Use the provided tmux session as the single source of truth. Do not start a second session.
211206
- **Capture discipline:** Aim for 3-8 captures per run. Capture at key milestones: startup, after important interactions, on errors, and final state. Do NOT capture after every single input.
212207
- **Use \`--full\` on the final capture** to get complete scrollback history. Regular captures only show the visible pane (~30 lines), keeping them small and focused.
213-
- **Use \`wait-for\` before sending input** when you need to wait for a prompt or specific output to appear. This is more reliable than guessing wait times.
214-
- **Wait guidance:** Most CLIs need 1-2 seconds to process input. Use \`--wait-idle 2\` on send or \`--wait 2\` on capture. For streaming CLIs, use \`--wait-idle 3\` or higher.
208+
- **Wait guidance:** Most CLIs need 1-2 seconds to process input. Use \`--wait-idle 2\` on send or \`--wait 2\` on capture. For streaming CLIs, use \`--wait-idle 3\` or higher. Use \`wait-idle\` to wait for output to stabilize before sending more input.
215209
- Use \`--label\` on captures to make filenames descriptive.
216210
- If the CLI already shows enough evidence in the current viewport, do not keep recapturing.`,
217211

@@ -222,8 +216,8 @@ If the CLI appears hung, try \`$HELPER key "$SESSION" C-c\` to interrupt. If it'
222216
A tmux session has been started for you. A setup message will announce the session name, helper script path, and the initial terminal output. Your command has already been sent to the session.
223217
224218
1. **Check the initial output** provided in the setup message. If you see errors like "command not found" or "No such file", report failure immediately.
225-
2. **Interact with the CLI** using the helper commands documented in the system prompt (send, key, capture, wait-for, etc.).
226-
3. **Capture output** at key milestones. Use \`wait-for\` to wait for expected prompts before sending input.
219+
2. **Interact with the CLI** using the helper commands documented in the system prompt (send, key, capture, wait-idle, etc.).
220+
3. **Capture output** at key milestones. Use \`wait-idle\` to wait for output to stabilize before sending more input.
227221
4. **Final capture** with full scrollback before stopping: \`$HELPER capture "$SESSION" --full --label "final"\`
228222
5. **Stop the session**: \`$HELPER stop "$SESSION"\`
229223
@@ -248,7 +242,7 @@ set -e
248242
249243
usage() {
250244
echo "Usage: $0 <command> [args]"
251-
echo "Commands: start, send, capture, stop, key, raw, wait-for, wait-idle, status"
245+
echo "Commands: start, send, capture, stop, key, raw, wait-idle, status"
252246
exit 1
253247
}
254248
@@ -362,33 +356,6 @@ case "$CMD" in
362356
cat "$CAPTURE_FILE"
363357
;;
364358
365-
wait-for)
366-
# wait-for <session> <pattern> [--timeout N]
367-
# Polls visible pane until grep matches the pattern (default timeout: 30s)
368-
SESSION="$1"; shift
369-
PATTERN=""; TIMEOUT=30
370-
while [[ $# -gt 0 ]]; do
371-
case $1 in
372-
--timeout) TIMEOUT="$2"; shift 2 ;;
373-
*) PATTERN="$1"; shift ;;
374-
esac
375-
done
376-
[[ -z "$SESSION" || -z "$PATTERN" ]] && { echo "Usage: wait-for <session> <pattern> [--timeout N]" >&2; exit 1; }
377-
MAX_END=$(( $(date +%s) + TIMEOUT ))
378-
while true; do
379-
if tmux capture-pane -t "$SESSION" -p 2>/dev/null | grep -q "$PATTERN"; then
380-
echo "Found: $PATTERN"
381-
break
382-
fi
383-
NOW=$(date +%s)
384-
if (( NOW >= MAX_END )); then
385-
echo "Timed out after \${TIMEOUT}s waiting for: $PATTERN" >&2
386-
exit 1
387-
fi
388-
sleep 0.25
389-
done
390-
;;
391-
392359
wait-idle)
393360
# wait-idle <session> [stable-seconds]
394361
SESSION="$1"; STABLE_SECS="\${2:-2}"
@@ -562,7 +529,6 @@ esac
562529
'- Send + wait for output: `' + helperPath + ' send "' + sessionName + '" "..." --wait-idle 3`\n' +
563530
'- Send key: `' + helperPath + ' key "' + sessionName + '" C-c`\n' +
564531
'- Raw tmux send-keys: `' + helperPath + ' raw "' + sessionName + '" "text" Enter`\n' +
565-
'- Wait for pattern: `' + helperPath + ' wait-for "' + sessionName + '" "pattern" --timeout 30`\n' +
566532
'- Capture visible pane: `' + helperPath + ' capture "' + sessionName + '" --label "..."`\n' +
567533
'- Capture full scrollback: `' + helperPath + ' capture "' + sessionName + '" --full --label "final"`\n' +
568534
'- Capture without ANSI colors: `' + helperPath + ' capture "' + sessionName + '" --strip-ansi`\n' +

0 commit comments

Comments
 (0)