Repository navigation
feat(chatd): end wait_agent early for a pending family message - #428
Conversation
|
$> Coder Agents acted on behalf of @ibetitsmike.\n\n@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…gent-family-messages
|
$> Coder Agents acted on behalf of @ibetitsmike.\n\n@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Merged at head Gates on this exact head:
What this changes: behind Not exercised: a live coderd restart during a wait, and the 200 ms poll path used when the pubsub subscription fails. |
Closes #422
Problem
A parent blocked in
wait_agentgot amessage_family_chatmessage only after the wait ended. Family messages are steer queued messages, and steers reach the model only at a delivery point (before each model call,FinishTurn,FinishInterruption).awaitSubagentCompletionwatches only the child, so a message sat in the queue until the child finished or the wait timed out.Design
Behind the existing
fork-family-messagesexperiment,appendForkTools(fork file, no upstream hook line) wrapswait_agentlast infamilyMessageWaitTool(coderd/x/chatd/fork_family_message_wait.go).isSubagentTarget), the wrapper subscribes to the waiting chat'sChatStateUpdateChannelbefore the first read, reads the queue, then reads it again on each notification and on a 5 second fallback tick (200 ms if the subscription fails).<agent-message from_chat_id="), it cancels the inner wait and returns{chat_id, family_message_pending: true, note, status, title}.wait_agentcall replayed after a restart reads the queue again and returns at once if the message is still queued.familyMessageEnvelopePrefixis a new constant infork_family_messages.go. The envelope text is unchanged.Tradeoffs:
message_agentsteer to a chat blocked inwait_agentstill waits for the wait to end. That is outside chatd: a parent blocked in wait_agent gets family messages only after the wait ends #422.The same design is written as prose in the fork section of
coderd/x/chatd/ARCHITECTURE.md.Tests
All run in
coderd/x/chatd:flock ~/.fork-go.lock go test ./ -run 'TestWaitAgentEndsForFamilyMessage' -count=1 -v: PASS (0.31s). The parent spawns a child and callswait_agentwithtimeout_seconds3600. The child sendsmessage_family_chatand then blocks. The test asserts the parent's next model call sees the message, there is onewait_agentresult withfamily_message_pendingtrue and statusrunning, the message is in history once, the queue is empty and the child is still running.fork_tools.goreplaced by_ = p.withFamilyMessageWait, the same test FAILS after 25.13s at theEventuallydeadline (fork_family_message_wait_test.go:122). Hook restored.TestFamilyMessageWaitPendingandTestFamilyMessageWaitTool(internal): user steer is not pending, a family message is, a steer under edit holds the lane; experiment off leaves the tool unwrapped; a blocking wait ends for a family message behind a user steer and leaves both queued; a wait started with the message already queued (replay) ends at once; a finished child whose inner wrapper was canceled gets its real result from a second wait; a completed wait keeps its result.TestChatFamilySurvivesRestartis adapted: it asserted that family messages stay queued duringwait_agent, which this change fixes on purpose. It now checks that each blocked worker's message is delivered once before and after the restart, and that every wait result that is not a report hasfamily_message_pendingtrue.flock ~/.fork-go.lock go test ./ -run 'TestFamilyMessageWait|TestWaitAgentEndsForFamilyMessage|TestChatFamilySurvivesRestart' -count=5 -race: PASS. A read-only reviewer ran the same set with-count=25 -race: PASS.flock ~/.fork-go.lock go test ./coderd/x/chatd/... -count=1: PASS.golangci-lint run --config=.golangci.new-code.yaml --new-from-merge-base=origin/main ./coderd/x/chatd/: 0 issues. Full config on the package: no findings in changed files.Not exercised: a real coderd restart on a live server, and the 200 ms poll path when the pubsub subscription fails.
Size: 604 added lines, about 390 of them tests.
Pre-commit hook
The pre-commit hook is off in this worktree only (
git config --worktree coder.pre-commit false, see #407). Targeted checks run instead:gofmt -l, the tests above,golangci-lint(new-code config and full config oncoderd/x/chatd),make lint/emdash,make lint/architecture,make lint/typos(only findings already onmain, none in changed files).