Repository navigation
feat(coderd): list a chat family's pending descendant questions - #114
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
Adds the forkdb query ListPendingChatDescendantQuestionsByRoot with its dbauthz (read access to the root chat) and dbmetrics wrappers.
Lists the unanswered ask_user_question calls of the unarchived descendants in a chat's family behind fork-nested-subagents, so the root chat UI and API clients can answer them. Adds the codersdk types and client method and the generated swagger, API docs and TypeScript types.
…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.
…ions-1-chatd-tool # Conflicts: # coderd/database/forkdb/sqlc.yaml
…ions-1-chatd-tool # Conflicts: # coderd/x/chatd/fork_tools.go
…ndant-questions-2-questions-route
…ions-1-chatd-tool # Conflicts: # coderd/database/dbauthz/fork_forkdb_test.go
…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
…ions-2-questions-route # Conflicts: # coderd/database/dbauthz/fork_forkdb_test.go # coderd/database/forkdb/chat_descendant_questions.sql.go # coderd/database/forkdb/chat_descendant_questions_test.go # coderd/database/forkdb/queries/chat_descendant_questions.sql
…family question list
|
@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. 🎉 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". |
UAT round 2 on
|
| Check | Result |
|---|---|
Q1: real depth-2 family. Root 75ea5894 spawns a coordinator 9ba8baec, which spawns asker 66b7d00b, and the asker calls ask_user_question |
The route on the root lists exactly 1 entry. It is the grandchild's entry: parent_chat_id = the coordinator, chat_title = asker, tool_call_id = call_a44a6808, which matches both the message and the DB row, and the questions decode with labels Red,Blue. The root itself is not listed. The route returns the same list when called on the coordinator and on the grandchild. (06:31:57) |
Q2: answer Blue posted to the grandchild |
POST returns 200. Right after it, the route no longer lists the grandchild, and the grandchild replies CHOSEN=Blue. A fresh root with no descendants returns []. The 3 older PR1 families return [], so no family leaks into another. |
Q6 (new, the cleared rule): a child asks, then POST /api/v2/chats/{child}/clear |
Before the clear, the child is listed with status waiting. The clear returns 200 and writes the boundary rows: a model-only user row 227 with compressed=t, then the assistant and tool rows. Afterwards the route drops the child, while its chat_descendant_questions row stays, because pending is derived. (06:31:12) |
Q3: a second non-admin user, uatmember1794292412 with no roles |
The route returns 404 on the admin's root, coordinator and grandchild, the same as the upstream GET /chats/{id}. On the member's own empty root it returns [] with 200. Edge cases: an unknown UUID gets 404, a malformed ID 400, no token 401, POST 405, a trailing slash 404. |
Q4: the same build restarted with CODER_EXPERIMENTS='' |
The route returns 403, and the message names fork-nested-subagents. With the experiment off, an unknown chat UUID also gets 403. |
After the run I stopped the dev server and revoked the temporary oMLX sub-key.
Xum posted this comment on behalf of @ibetitsmike.
…ions-2-questions-route # Conflicts: # coderd/apidoc/docs.go # coderd/apidoc/swagger.json
|
@codex review
|
|
Codex Review: Didn't find any major issues. Chef's kiss. 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,GET /api/v2/chats/fork/{chat}/questionslists the unansweredask_user_questioncalls of the descendants in a chat's family, oldest first. The root chat UI (next PR) uses it to show a "Question from " card and to send the answer to the asking child. With the experiment off, the route answers 403.What changes
ListPendingChatDescendantQuestionsByRoot: the pending questions of the unarchived descendants of a root chat, with the asking chat's title and parent. "Pending" uses the same rule asGetPendingChatDescendantQuestionfrom feat(coderd): let descendant chats ask the user blocking questions behind fork-nested-subagents #86: no non-deleted user message newer than the question. Model-only user rows do not count, and a context boundary such as a clear retires the question.coderd/fork_chat_questions.goserves the route. Any chat of a family resolves to its root, so a child lists the same family as its root. The response is always a JSON array, nevernull. A row whose questions do not decode is logged and skipped, so it does not hide the family's other questions.codersdk.ChatDescendantQuestionandClient.ChatDescendantQuestions, plus the regenerated swagger, API schema docs andtypesGenerated.ts. The route is hidden from the generated API docs like the other fork chat routes.The route serves any family the caller can read, including families started by API clients, not only UI chats.
Validation
go build,go vet, forkdbgenerate.shdrift check and.github/fork/check-apidoc.sh: all pass.go testfor./coderd/database/forkdb/...,./coderd/database/dbmetrics/...,./coderd/x/chatd/...,dbauthz -run TestForkQuerier,./coderd -run TestForkChatand./coderd/coderdtest -run TestEndpointsDocumented(Postgres in Colima): all pass.[], another user got 404, and with the experiment off the route answered 403. The later commits merge feat(coderd): let descendant chats ask the user blocking questions behind fork-nested-subagents #86 and add the model-only and cleared filters with their tests.