Skip to content

fix(coderd/x/chatd): keep wait_agent waiting on a paused child - #29292

Merged
mafredri merged 81 commits into
mainfrom
mathias/codagt-1026-wait-agent-paused
Oct 30, 2026
Merged

mafredri merged 81 commits into
mainfrom
mathias/codagt-1026-wait-agent-paused

Conversation

@mafredri

@mafredri mafredri commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

Stacked on #29215, which adds the paused chat status.

checkSubagentCompletion treated every status except running and interrupting as done, so wait_agent on a paused child returned the child's last assistant message as its final report while a queued message was still under edit. A paused child is not done: wait_agent keeps waiting, and on timeout returns status: "paused" with timed_out: true. The wait_agent and list_agents descriptions say that a paused timeout is expected.

Closes https://linear.app/codercom/issue/CODAGT-1026

🤖 This PR was created with the help of Coder Agents on behalf of @mafredri, and will be reviewed by a human. 🏂🏻

@linear-code

linear-code Bot commented Sep 14, 2026

Copy link
Copy Markdown

CODAGT-1026

@mafredri
mafredri force-pushed the mathias/codagt-1026-wait-agent-paused branch 2 times, most recently from f383243 to 390e952 Compare September 15, 2026 10:39
@mafredri
mafredri force-pushed the mathias/codagt-971-queue-hold-backend branch from 28604ca to c188dec Compare September 17, 2026 15:19
@mafredri
mafredri force-pushed the mathias/codagt-1026-wait-agent-paused branch 3 times, most recently from 49b952e to 7eaa8eb Compare September 18, 2026 15:48
@mafredri
mafredri force-pushed the mathias/codagt-971-queue-hold-backend branch from 738bfa2 to b1c103e Compare September 22, 2026 13:45
@mafredri
mafredri force-pushed the mathias/codagt-1026-wait-agent-paused branch from 7eaa8eb to b9d6842 Compare September 22, 2026 13:49
@mafredri
mafredri marked this pull request as ready for review September 23, 2026 11:28
@mafredri
mafredri force-pushed the mathias/codagt-971-queue-hold-backend branch from b1c103e to e39136c Compare September 28, 2026 19:36
@mafredri
mafredri requested a review from a team as a code owner September 28, 2026 19:36
@mafredri
mafredri force-pushed the mathias/codagt-1026-wait-agent-paused branch from b9d6842 to 5534e79 Compare September 28, 2026 19:36
@coderagents

coderagents Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Documentation Check

Updates Needed

  • docs/ai-coder/agents/index.md (open) - The interrupt_agent row says it "transitions to waiting or running if there are queued messages." This PR adds a third outcome: the sub-agent also transitions to paused while its owner is editing its next queued message. Add paused to that sentence.
  • docs/ai-coder/agents/architecture.md (open) - The interrupt_agent row repeats the same "transitions to waiting or running if there are queued messages" wording and has the same gap; add the paused outcome here too.

Automated review via Coder Agents

@jakehwll jakehwll left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks fine... not sure why it landed on agents-frontend team 😅

@mafredri
mafredri force-pushed the mathias/codagt-971-queue-hold-backend branch from e39136c to 1ba2bd6 Compare October 2, 2026 13:43
@mafredri
mafredri force-pushed the mathias/codagt-1026-wait-agent-paused branch from 5534e79 to 1e231c0 Compare October 2, 2026 13:43
@mafredri
mafredri force-pushed the mathias/codagt-971-queue-hold-backend branch from 1ba2bd6 to cfdf0a0 Compare October 2, 2026 14:44
@mafredri
mafredri force-pushed the mathias/codagt-1026-wait-agent-paused branch from 1e231c0 to c0fa601 Compare October 2, 2026 14:46
@mafredri
mafredri force-pushed the mathias/codagt-971-queue-hold-backend branch from cfdf0a0 to 23b1d9c Compare October 2, 2026 17:35
@mafredri
mafredri force-pushed the mathias/codagt-1026-wait-agent-paused branch 2 times, most recently from a892700 to 88fd17e Compare October 5, 2026 08:21
@mafredri
mafredri force-pushed the mathias/codagt-971-queue-hold-backend branch from 23b1d9c to 4804321 Compare October 5, 2026 08:21
@mafredri
mafredri force-pushed the mathias/codagt-1026-wait-agent-paused branch from 88fd17e to 323b32c Compare October 5, 2026 09:13
@mafredri
mafredri force-pushed the mathias/codagt-971-queue-hold-backend branch from 1e63c30 to ab006da Compare October 5, 2026 11:51
@mafredri
mafredri force-pushed the mathias/codagt-1026-wait-agent-paused branch 2 times, most recently from 9e90e08 to 85d02b6 Compare October 12, 2026 09:05
@mafredri
mafredri force-pushed the mathias/codagt-971-queue-hold-backend branch from ab006da to 4cbb257 Compare October 12, 2026 09:05
mafredri and others added 24 commits October 30, 2026 12:29
Move the editing migration to 000634 after main's 000633, and keep the
paused archive refusal message in main's shared chat update path.
The paused resume delete guard and the paused auto-archive candidate
test repeat checks that TestQueuedMessagePromotionRequiresSingleDelete
and TestAutoArchiveCandidateQueriesAgree already make through the same
code.

TestQueueAdvanceKeepsLastError and the last_error column of
TestEditing_LeavingPaused seed last_error by a direct row write onto
R, I, and P chats. No transition stores last_error outside error: every
exit from E0, E1, and E1P clears it, so those inputs never occur. The
matrix already covers their state outcomes and queue links.
Main added migration 000634_aibridge_interception_organization, so the
queued-message editing_since migration and its test move to 000635.
Regenerate the chat API docs for main's project_id parameter change.
A queued content edit links its files, but dropping that LinkFiles
call failed no test.
Only FinishError and ReconcileInvalidState store a last_error, both in
error, and every transition out of E0, E1, and E1P clears it. The chats
that advanceQueue sees (R, I, P) therefore never carry one, so
promoteQueuedRow can clear it for all callers and the last_error
parameters on promoteQueuedRow and advanceQueue go away.
Editing a row that was already sent or removed returned 404 while
other rows were queued, but 409 with the internal transition error in
Detail once the queue was empty, because the state check runs before
the row lookup. Every unarchived, valid state that refuses the edit
has an empty queue, so the row is gone in that case too.
queue_wait runs from the queued row's created_at to its promotion, and
editing a queued row does not change created_at, so a row's time under
edit counts toward queue_wait.
Renumber the editing_since migration to 000638 after main's 000637 and regenerate the database wrappers.
A paused child finished a turn with a queued message under edit and
continues when the edit ends. checkSubagentCompletion treated any status
other than running or interrupting as done, so wait_agent returned the
child's partial report as its result. paused is now not-done: the parent
waits, and on timeout receives status "paused" with timed_out. The
list_agents status legend gains the value.

Closes CODAGT-1026.

Co-authored-by: Coder Agents <noreply@coder.com>
The list_agents legend and the wait_agent description name the chat
statuses; paused goes last like every other status list, and the
wait_agent sentence states what a paused timeout means.
An interrupted child whose next queued message is under edit finishes
the interruption in paused, not waiting or running, so the
interrupt_agent description lists that outcome.
This branch only adds the paused sentence to the wait_agent
description. The other two sentences TestWaitAgentToolSchema checked
were already there and untested on main.
@mafredri
mafredri force-pushed the mathias/codagt-971-queue-hold-backend branch from 7954fdb to 5eb7389 Compare October 30, 2026 13:10
@mafredri
mafredri force-pushed the mathias/codagt-1026-wait-agent-paused branch from 62ba452 to 7023358 Compare October 30, 2026 13:10
Base automatically changed from mathias/codagt-971-queue-hold-backend to main October 30, 2026 13:52
@mafredri
mafredri merged commit c3436cb into main Oct 30, 2026
30 of 31 checks passed
@mafredri
mafredri deleted the mathias/codagt-1026-wait-agent-paused branch October 30, 2026 13:58
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants