Repository navigation
feat(coderd): give descendant tools secret answers without showing them to the model - #126
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
…ions-2-questions-route # Conflicts: # coderd/apidoc/docs.go # coderd/apidoc/swagger.json
…ions-4-secret-answers
…hitecture document
…ers in key commands
Also send an empty options array for questions without options, and match the secret-answer route ID to its summary.
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: 29e887fbe7
ℹ️ 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
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: db2ed04d29
ℹ️ 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".
… replaced An answer past its TTL can be replaced while the message that reports it is still queued. The route now skips the send in that case, so the queued message reports the new answer and no second report reaches the child after the question is answered.
…e/descendant-questions-6-secret-substitution
|
@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-5-secret-answer-ttl # Conflicts: # coderd/database/dbauthz/fork_forkdb.go # coderd/database/dbauthz/fork_forkdb_test.go # coderd/database/dbmetrics/fork_forkdb.go # coderd/database/forkdb/chat_secret_answers.sql.go # coderd/database/forkdb/forkdbmock/forkdbmock.go # coderd/database/forkdb/querier.go # coderd/database/forkdb/queries/chat_secret_answers.sql # coderd/fork_chat_questions.go # coderd/fork_chat_questions_internal_test.go # coderd/fork_chat_questions_test.go # coderd/x/chatd/ARCHITECTURE.md
…e/descendant-questions-6-secret-substitution
…ions-6-secret-substitution
|
@codex review
|
|
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". |
Closing and reopening only to make GitHub recompute the merge ref against current main ( |
The merge ref now points at current main ( |
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
This is the third of four PRs for secret answers to descendant questions (R8.3). It stacks on #125, the 24 hour expiry. A descendant chat can now use a secret answer in its tools while the model still never sees the value. The model writes
{{secret:<call_id>}}where the value belongs, and chatd puts the value in at run time.The model still cannot ask a secret question. The
secretflag in theask_user_questionschema stays off until the root chat page has a masked input (PR7). Tests turn it on.What changes
withSecretAnswersreads the secret answers of a chat that can ask descendant questions. If the chat has any, it wraps every tool of the turn. An answer only arrives as the user message that starts a turn, so the answers hold for the whole turn. If the read fails, it wraps the tools anyway and each call reads the answers itself.execute,write_fileandedit_filesget each placeholder in their input replaced by the value, escaped for a JSON string. The stored tool call keeps the placeholder.spawn_agent,message_agentand every other tool keep the placeholder, because they pass their input to another model.MCPServerConfigIDand the optional methods the chat loop looks for:SerialToolCalls,HaltedToolCallError,ObserveStepToolCallsandObserveStepToolResults.ask_user_questionaccepts one question withsecret: true, a header, a question and no options. It records the question with the secret flag and tells the model which placeholder to write. The upstream tool would drop the flag, so the fork code handles that call.coderd/x/chatd/ARCHITECTURE.mdgets a TODO for the substitution. The document's owner writes the text.With the flag off
The flag is off in this PR, so the model can never ask a secret question. The secret answer route rejects a question that is not secret, so no chat has secret answers. Even so, some new code runs:
fork-nested-subagentson, the chat has a parent, not an explore subagent), turn setup reads the chat's secret answers once, an indexed read bychat_id. The read returns no rows, so no tool is wrapped and no tool call reads anything.A LIGHT server UAT of normal descendant chats checks this (results below).
Limits
Validation
TestSecretAnswerReachesToolsNotModel(chatd, Postgres, fake model): a child chat has a pending secret question and a stored answer, and gets the answer message. The model writes the placeholder inwrite_file, and the workspace gets the value. Thenread_filereturns the value, and the tool result shows the placeholder. The value is used with a quote and angle brackets, so its JSON escapings differ. No model request and no stored chat message contains the value in any of its forms.TestSecretAnswerTools,TestSubstituteSecretAnswers,TestScrubSecretAnswersandTestDescendantSecretQuestioncover the wrapping, the forwarded methods, the escaping, the longest-first scrub and the secret question checks. A chat without answers and the root chat keep their tools unwrapped. WithSerialToolCallsforwarding removed,TestSecretAnswerToolsfails.TestForkChatSecretAnswercovers the 8 byte floor.gofmtandgo vetpass.main. This PR targets the expiry PR's branch, so CI runs after the PRs below it merge.5a8382e4b, oMLX GLM-5.3-Flash) passed. A root spawned a child that asked a Red/Blue question and got a normal answer. The child's tools ran through the secret wrapper unchanged, and the root sawCHOSEN=Red. With a secret answer staged for another call of the child, the flow was the same. The staged value appeared only in itschat_secret_answersrow, and in no other table, no debug step and no server log line. A 5 byte secret answer got the 400 floor message.