Open
Conversation
Replace the blind 5-second wait + unverified sendMessage with a proper polling loop that: 1. Polls for agent process existence (up to 30s) 2. Polls for agent idle state via detectActivity (up to 60s) 3. Sends the message once the agent is ready 4. Verifies delivery by checking for active state (3 attempts) 5. Logs warnings on failure instead of silently swallowing errors This reuses patterns from `ao send` (busy detection + retry) and the integration test (waitForTuiReady polling for ❯ prompt). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| console.warn( | ||
| `[ao] Session ${sessionId}: agent not idle after ${READY_POLL_TIMEOUT_MS / 1000}s. Sending prompt anyway.`, | ||
| ); | ||
| } |
There was a problem hiding this comment.
Misleading warning when waiting_input exits loop early
Low Severity
When detectActivity returns "waiting_input", the Step 2 loop breaks early without setting agentReady = true. The subsequent warning then claims "agent not idle after 60s" even though the timeout was never reached — the loop exited because the agent was in waiting_input state. This logs incorrect elapsed time and hides the actual reason (a permission/trust prompt), which could mislead operators debugging delivery issues.
Additional Locations (1)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
setTimeout+ unverifiedsendMessage()insession-manager.tswith a polling-based ready-detection loopdetectActivity()(up to 60s) before sending the promptactivestate after send (3 attempts with retry)console.warnon failure instead of silently swallowing errors — user sees actionable retry instructions (ao send <session>)Problem
ao spawndelivered the initial prompt via a fixed 5-second delay + blindruntime.sendMessage(), which failed ~50% of the time because Claude Code takes longer than 5s to start (trust prompt, loading CLAUDE.md, etc.). Errors were silently caught, leaving users with idle sessions that never received instructions.Test plan
detectActivitycalled multiple times)🤖 Generated with Claude Code