Skip to content

feat: let descendant chats ask secret questions - #153

Merged
ibetitsmike merged 151 commits into
mainfrom
mike/descendant-questions-7-secret-input
Nov 10, 2026
Merged

ibetitsmike merged 151 commits into
mainfrom
mike/descendant-questions-7-secret-input

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

Part of #73

Xum opened this PR on behalf of @ibetitsmike.

This PR turns on secret questions for descendant chats. #126 and #136 built the storage, the substitution into tool input and the scrub of tool output, with the secret flag of ask_user_question off. Here a child agent can ask the user for a value such as an API token, and the user answers it on the root chat page in a masked field. The value reaches the child's execute, write_file and edit_files calls through a {{secret:<tool call ID>}} placeholder, and never enters a chat message or a model-visible row.

What changes

  • Server: ask_user_question in a descendant chat of the fork-nested-subagents experiment now offers the secret property and handles a secret question. A computer-use chat still gets no secret property, because its screenshots reach the model without the scrub.
  • Pending questions: a secret question now stays pending until the message of the secret answer route answers it. Before, any later visible user message retired a question. With the flag on, a message that the user queued before the child asked would be promoted at the end of the turn and answer the secret question without the value. GetPendingChatDescendantQuestion and ListPendingChatDescendantQuestionsByRoot now retire a secret question only with a user message that starts with Answer to ask_user_question call <tool call ID>:, which only the answer route writes. A clear still retires every question. That message retires the question even after an edit deletes it, so a consumed secret question cannot come back.
  • Decline: the route also takes declined: true with no value, for a value the user cannot or will not give as a secret, such as one shorter than the 8 byte floor. The child gets a message that the user declined and can ask again without the secret option. A decline deletes a stored answer to that question in the same transaction. A decline is refused while the report of an answer is queued.
  • Prompt hooks: a user_prompt_submit hook's input_override does not apply to the answer or decline message. coderd writes that text, which holds no user input, and the pending rule needs it as written.
  • Stored answers: a new question no longer deletes the answers to earlier questions, so output that shows an earlier value is still scrubbed. Answers expire after 24 hours.
  • Root chat dock: a secret question shows a masked password field with the question, a note that the subagent's tools get the value but the model never sees it, Submit and Decline. Submit posts the value to POST /api/v2/chats/fork/{chat}/questions/secret-answer with the tool call ID in the body. The field keeps no draft and writes nothing to local storage. An error from the route, such as the 8 byte floor, shows under the field and points to Decline.
  • Child chat tool card: the ask_user_question card of an open secret question shows the question with no form and a notice to answer it in the root chat's question panel, so the user cannot answer it as a chat message.

With the flag off

The fork-nested-subagents experiment gates descendant questions. With it off, no chat is a descendant chat, so no secret question can exist, and the dock and tool card render as before.

Validation

  • TestDescendantSecretQuestion covers the schema with the flag on, the computer-use refusal, the refusal while a message is queued and the recorded secret question.
  • TestForkChatSecretQuestionQueuedMessage queues a message on a running child, records a secret question, and drives the turn to its end. The queued message is delivered and the secret question stays pending.
  • TestGetPendingChatDescendantQuestion covers a secret question that an ordinary message and the answer message of another question leave pending, and that its own answer message retires.
  • ForkDescendantQuestionDock.test.tsx types a value into the masked field and checks the request body of the secret answer route, that no chat message is sent, and that local storage does not hold the value. It also checks that an error marks the field invalid, is part of its accessible description, and clears once the value changes. forkSecretQuestions.test.ts checks that a secret question in the arguments or the result marks the tool card as not answerable. The SecretQuestion story captures the descendant chat's secret question with its notice to answer it in the root chat and no form.
  • TestForkChatSecretAnswer covers the route's refusals, the stored value staying out of messages, the busy-chat queue, and a decline that deletes a stored answer and retires the question. TestSecretQuestionRefusesSubagentMessage checks that a decline is refused while the answer's report is queued and that the stored answer stays. TestForkChatSecretAnswerPromptOverride checks that a hook that rewrites every prompt cannot keep an answered or declined question pending.
  • Negative controls (the fix reverted, the test run, the fix restored) failed the matching tests for the deleted report, the decline, the kept answers, the deleted stored answer on decline, the queued decline refusal and the prompt override.
  • UAT on a branch server (3200) as a member user, flag on:
    • On 5ed0bce, a child asked a secret question, the value was submitted in the root page dock, and the child's execute printed the expected sha256 of the value. The value was in 0 of 128 text columns of chat and message tables (the answer store was the 1 control hit) and 0 times in the server log. Sending, editing, a wrong ID and a second answer were refused with 409, and a short value with 400. The field has autocomplete="off" and password manager ignore attributes.
    • On 23b0596, Decline in the dock retired the question with no stored row. The child asked again, the second answer reached execute with the expected sha256, and the server log had 0 hits.
    • Flag off: the fork routes return 403, a child message and an edit return 200, and no dock renders.
    • The tests above cover the commits after 23b0596 (decline deleting a stored answer, the prompt override, the queued decline refusal, the dock's stale error, error semantics and disabled-form text, the descendant chat's secret notice, the story fixes, and an apidoc description). They had no UAT.

…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
…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
…com:ibetitsmike/coder into mike/descendant-questions-3-question-dock
…ions-2-questions-route

# Conflicts:
#	coderd/apidoc/docs.go
#	coderd/apidoc/swagger.json
…com:ibetitsmike/coder into mike/descendant-questions-3-question-dock
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this comment on behalf of @ibetitsmike.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c00f1ba03c

ℹ️ 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".

Comment thread coderd/x/chatd/fork_subagents.go Resolved
The coderd test raced a promotion of the queued report, so either 409
satisfied it. The chatd test queues the report itself.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this comment on behalf of @ibetitsmike.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b99bcd95ae

ℹ️ 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".

…o the field and explain secret questions in descendant chats
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this comment on behalf of @ibetitsmike.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ab08929b52

ℹ️ 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".

…the secret question story to the visual capture
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this comment on behalf of @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 4809559f6f

ℹ️ 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".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum (AI agent) closed and reopened this on behalf of @ibetitsmike.

Closing and reopening only to make GitHub recompute the merge ref against current main (18aec9ebaf) and run fork-ci on it. The head is unchanged.

@ibetitsmike ibetitsmike reopened this Nov 10, 2026
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum (AI agent) closed and reopened this again on behalf of @ibetitsmike.

The merge ref now points at current main (18aec9ebaf), but the run started by the first reopen was queued against the old merge ref. This second reopen starts fork-ci on the recomputed merge. The head is unchanged.

@ibetitsmike ibetitsmike reopened this Nov 10, 2026
@ibetitsmike
ibetitsmike merged commit dfc24a4 into main Nov 10, 2026
21 of 28 checks passed
@ibetitsmike
ibetitsmike deleted the mike/descendant-questions-7-secret-input branch November 10, 2026 21:52
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum (AI agent) merged this on behalf of @ibetitsmike.

Merge evidence for head 4809559f6f9353d7725c1e575b137a33bfddf341:

  • fork-ci pull_request run 42906917589 passed; its build job checked out Merge 4809559f6f into 18aec9ebaf (current main). Run 42898765226 had also passed on this head against 5654571bb0. All checks green.
  • Codex on this exact head: no major issues (comment 6778963790). 0 of 24 review threads unresolved. Declined with replies: concurrent-action and flag-flip races (two answers at once, a model answer against a user decline, a definition rename between turns, an answer submitted around a flag flip, the secret-mode snapshot after the UI answer).
  • UAT on :3200 with a real model at 5ed0bce1c4: the secret question flow passed with fork-nested-subagents on and off, and the value appeared in no message, transcript or server log. The decline path re-UAT at 23b059645a passed. Later commits are narrow fixes with tests and negative controls (a decline drops the stored answer, secret answer reports survive prompt hook overrides, a decline is refused while the answer report is queued, form error accessibility, and the descendant notice).
  • No migration.

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.

1 participant