Repository navigation
feat(coderd): let descendant chats ask the user blocking questions behind fork-nested-subagents - #86
Conversation
…hind fork-nested-subagents A delegated chat that is not an explore subagent gets a blocking ask_user_question tool. The call records the question in the new chatd.chat_descendant_questions table and ends the turn; the answer is the next user message. The parent's wait_agent reports needs_input while the child's question is unanswered and, when called while it is pending, waits for the answer before it waits for the child.
…c and cover the late question TestDescendantQuestionEndsTurn raced the child's turn against the root's wait_agent call: when the question was already pending, wait_agent waited the default five minutes and the test hit its deadline (about 1 in 3 to 1 in 15 runs). The root's wait_agent now starts once the question is pending, with a 1 second timeout. TestDescendantQuestionWaitAgent now also covers a question the child asks while the parent waits on it, which only the racy end-to-end path exercised. TestAppendForkTools now includes wait_agent, so wrapping it with the experiment off fails.
…ions-1-chatd-tool # Conflicts: # coderd/database/forkdb/forkdbmock/forkdbmock.go # coderd/database/forkdb/querier.go # coderd/database/forkdb/sqlc.yaml
|
@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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bca159a339
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
…tions wait_agent now always runs the wrapped tool, so include_tool_calls and its validation apply while a question is pending, a question asked before an inner timeout is reported, and a failed question lookup is an error. Model-only user rows from lifecycle hooks no longer answer a question.
|
@codex review
|
|
Codex Review: Didn't find any major issues. Can't wait for the next one! 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". |
…ions-1-chatd-tool # Conflicts: # coderd/database/forkdb/sqlc.yaml
|
@codex review
|
|
Codex Review: Didn't find any major issues. Swish! 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". |
…ions-1-chatd-tool # Conflicts: # coderd/x/chatd/fork_tools.go
|
@codex review
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 01f9c60dbf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
…ions-1-chatd-tool # Conflicts: # coderd/database/dbauthz/fork_forkdb_test.go
|
@codex review
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1ca1464aba
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
|
@codex review
|
|
Codex Review: Didn't find any major issues. Can't wait for the next one! 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". |
Focused UAT on
|
| Time (UTC) | Event |
|---|---|
| 03:47:23.291 | The child (asker) calls ask_user_question. The question row is stored as call_e613bf0c, and the child's turn ends (waiting). |
| 03:47:29.191 | The root calls wait_agent once (timeout_seconds: 900). The call stays blocked while the question is pending. |
| 03:51:56.661 | The answer is posted to the child chat (POST /api/v2/chats/<child>/messages, HTTP 200). |
| 03:52:00.786 | The child replies CHOSEN=Blue. |
| 03:52:00.813 | The root's wait_agent returns 27 ms later with report CHOSEN=Blue, status waiting and no needs_input. |
| 03:52:10.912 | The root replies ROOT_SAW=CHOSEN=Blue. |
The UAT driver's first answer POST had no body (a script bug), so the answer went out about four minutes later than planned. The single wait call stayed blocked on the pending question for that whole time.
S8: replaced question. Result: pass. I staged this case in the database because a model can't reliably hit a 2-second window.
| Time (UTC) | Event |
|---|---|
| 03:53:06.232 | The child asks call_5e38787a. The root's first wait_agent returns needs_input. |
| 03:53:19.533 | The root's second wait_agent starts (timeout_seconds: 900). |
| 03:53:33.025 | The question row is replaced (tool_call_id staged-replacement, with a new "Size" question). |
| 03:53:33.574 | wait_agent returns 0.55 s later, within one poll, with needs_input: true and the Size question. Before the fix, it would have waited until the 900 s timeout. |
Both chats were archived afterwards, the dev server was stopped, and the temporary model key was revoked.
Xum posted this comment on behalf of @ibetitsmike.
…ions-1-chatd-tool # Conflicts: # coderd/database/dbauthz/fork_forkdb.go # coderd/database/dbmetrics/fork_forkdb.go # coderd/database/forkdb/sqlc.yaml # coderd/x/chatd/ARCHITECTURE.md
|
@codex review
|
|
Codex Review: Didn't find any major issues. Breezy! 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". |
Closing and reopening only to make GitHub recompute the merge ref against current main ( |
The merge ref now points at current main ( |
Merge evidence for head
|
Part of #73
With
fork-nested-subagentson, a delegated chat that is not an explore subagent gets a blockingask_user_question. Its question is meant for the user, not the parent agent. When the experiment is off, the tool list and the stop list match upstream.What changes
chat_descendant_questions(one row per chat,chat_idprimary key, cascades on chat delete) with the forkdb queriesUpsertChatDescendantQuestionandGetPendingChatDescendantQuestion. A question is pending until the chat gets a non-deleted user message newer than the question. Model-only user rows, such as lifecycle hook context, do not count.fork_descendant_questions.gowraps upstream'sask_user_questionso that it also records the question.forkStopAfterToolsadds the tool to the stop list, so the call ends the child's turn. The child's next user message is the answer.wait_agenton a child with an unanswered question returnsneeds_input: true, the questions, and a note. If the question is already pending whenwait_agentis called, it waits (until its timeout) for the answer and the child's report.turn_environment.go(theStopAfterToolshook). The rest is wired throughappendForkTools.ARCHITECTURE.mdgets two TODO lines only; the author writes the prose.Root-chat UI and the family questions endpoint come in later PRs of #73.
Known behavior
builtinPlanToolAllowedallowsask_user_questiononly for root chats.Validation
go build ./coderd/... ./enterprise/cmd/coder,go vet,chatdmig check, and the forkdbgenerate.shdrift check: all pass.go test ./coderd/x/chatd/...,./coderd/database/forkdb/...,./coderd/database/dbmetrics/...anddbauthz -run TestForkQuerier(Postgres in Colima): all pass.main.