Skip to content

fix: wait for agent idle before sending input to existing task#10

Merged
mafredri merged 1 commit intomainfrom
mafredri/fix-wait-for-idle-before-send
Mar 23, 2026
Merged

fix: wait for agent idle before sending input to existing task#10
mafredri merged 1 commit intomainfrom
mafredri/fix-wait-for-idle-before-send

Conversation

@mafredri
Copy link
Copy Markdown
Member

@mafredri mafredri commented Mar 23, 2026

When an existing task was already active, the action skipped
waitForTaskActive and called sendTaskInput immediately. But
active does not mean idle. If the agent is still processing a
previous prompt (current_state.state === "working"), the send
fails with a 409/502 from the server.

Now waitForTaskActive runs unconditionally for existing tasks.
It already handles the active+idle case correctly (returns
immediately), so this adds no delay when the agent is ready.

🤖 This PR was created with the help of Coder Agents, and has been reviewed by a human. 🏂🏻

Copy link
Copy Markdown
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

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

Changes look fine to me, thanks for catching this!

When an existing task has status 'active', the action previously skipped
waitForTaskActive and immediately called sendTaskInput. But the task can
be active while the agent is still processing a previous prompt
(current_state.state === 'working'). This causes 409/502 errors from
the server because the agent isn't ready to accept input.

Remove the status guard so waitForTaskActive always runs for existing
tasks. The function already handles the active+idle case correctly by
returning immediately.
@mafredri mafredri force-pushed the mafredri/fix-wait-for-idle-before-send branch from f8f105a to 5d349c5 Compare March 23, 2026 10:14
@mafredri mafredri marked this pull request as ready for review March 23, 2026 10:17
@mafredri mafredri merged commit ebe0b7f into main Mar 23, 2026
1 check passed
@mafredri mafredri deleted the mafredri/fix-wait-for-idle-before-send branch March 23, 2026 10:18
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.

2 participants