Repository navigation
feat: add the message_family_chat tool behind fork-family-messages - #265
Conversation
Adds the fork-family-messages experiment and the message_family_chat chat tool. A chat sends a text message to any other chat with the same root (its parent, a sibling or another descendant) by chat ID. Delivery follows message_agent: an idle recipient starts a turn, a busy recipient gets the message before its next model call, and no turn is interrupted. The message arrives in an agent-message envelope with the sender chat ID and title. Each send records a chatd.chat_family_messages row in the send transaction, and a sender may send at most 60 messages in the rolling hour. Chats outside the family, unknown chats, archived chats and the sender itself are refused. Refs #247
@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: 24c507b784
ℹ️ 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 (head now includes a merge of main at 0896529; no PR changes) |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b9f2509259
ℹ️ 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".
Addresses the Codex review of #265: - Escape <agent-message> wrapper tags (case and spacing variants) in the body and sender title, so a sender cannot close the envelope early. - Record each message under the tool-call occurrence ID and return the recorded recipient on a replayed call, so a worker restart does not deliver the message twice. - Drop the sender's rows older than the rate window in the send transaction, so the ledger stays bounded. - Include message_family_chat in the Task alias of custom agent tool policies, so disallowing Task also blocks family messages. Refs #247
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ae6a9f37a4
ℹ️ 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".
Addresses the second Codex review of #265: - Return hook dispatch failures as tool execution errors, as spawn_agent does, so the sender fails closed. - Refuse calls without a deterministic tool-call ID, which replay deduplication needs. - Resolve the family root with subagentRootChatID, so first-level children without a root ID reach their parent and siblings. - Index chat_family_messages.recipient_chat_id for the chat delete cascade. - Keep the agent-message envelope around a user_prompt_submit hook's prompt override. - Word the reply hint so it holds when the recipient lacks the tool. Refs #247
@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". |
Add organization_id (the sending chat's organization) to chatd.chat_family_messages, filter the rate-limit, replay and prune queries by it, and lead the sender index with it. Refs #247
Replace the fork-family-messages TODO with the behavior of message_family_chat and chatd.chat_family_messages after the organization_id change.
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 532d35d69b
ℹ️ 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 ON DELETE CASCADE from chats looks up rows by sender_chat_id alone, which an index leading with organization_id cannot serve.
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! 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". |
…ages-1-tool # Conflicts: # docs/reference/api/schemas.md
@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". |
Merged as
The UAT carries over to the merged head. Normalized for index and hunk lines, its diff against main matches the tested diff except for the generated Experiment enum table in |
…cture-fork-docs # Conflicts: # coderd/x/chatd/ARCHITECTURE.md
…ges (#266) * feat: add the message_family_chat tool behind fork-family-messages Adds the fork-family-messages experiment and the message_family_chat chat tool. A chat sends a text message to any other chat with the same root (its parent, a sibling or another descendant) by chat ID. Delivery follows message_agent: an idle recipient starts a turn, a busy recipient gets the message before its next model call, and no turn is interrupted. The message arrives in an agent-message envelope with the sender chat ID and title. Each send records a chatd.chat_family_messages row in the send transaction, and a sender may send at most 60 messages in the rolling hour. Chats outside the family, unknown chats, archived chats and the sender itself are refused. Refs #247 * fix(coderd): harden message_family_chat delivery Addresses the Codex review of #265: - Escape <agent-message> wrapper tags (case and spacing variants) in the body and sender title, so a sender cannot close the envelope early. - Record each message under the tool-call occurrence ID and return the recorded recipient on a replayed call, so a worker restart does not deliver the message twice. - Drop the sender's rows older than the rate window in the send transaction, so the ledger stays bounded. - Include message_family_chat in the Task alias of custom agent tool policies, so disallowing Task also blocks family messages. Refs #247 * feat(coderd): add the list_family_chats tool behind fork-family-messages With fork-family-messages on, every chat turn also gets list_family_chats. It lists the unarchived chats of the caller's family (the same root), the root first and then by creation time, so the model can find the chat IDs that message_family_chat takes. Each entry has the chat ID, parent chat ID, title, status and the caller's relation to the chat: self, parent, root, child, sibling or other. At most 100 chats are listed, and truncated is set when the family has more. The new forkdb query ListChatFamilyMembers authorizes as a read of the root chat. The Task tool alias of custom agents now includes list_family_chats. Refs #247 * fix(coderd): close message_family_chat review gaps Addresses the second Codex review of #265: - Return hook dispatch failures as tool execution errors, as spawn_agent does, so the sender fails closed. - Refuse calls without a deterministic tool-call ID, which replay deduplication needs. - Resolve the family root with subagentRootChatID, so first-level children without a root ID reach their parent and siblings. - Index chat_family_messages.recipient_chat_id for the chat delete cascade. - Keep the agent-message envelope around a user_prompt_submit hook's prompt override. - Word the reply hint so it holds when the recipient lacks the tool. Refs #247 * fix(coderd/database/forkdb): keep the family list predicate indexable Refs #247 * fix(coderd/x/chatd): keep list_family_chats within the tool-result budget Stop listing once the entries reach 12 KiB, below chatloop's 16 KiB smallest tool-result budget, and mark the list truncated. Add the architecture TODO for list_family_chats. Refs #247 * fix(coderd): scope chat_family_messages to an organization Add organization_id (the sending chat's organization) to chatd.chat_family_messages, filter the rate-limit, replay and prune queries by it, and lead the sender index with it. Refs #247 * docs(coderd/x/chatd): describe family messages in ARCHITECTURE.md Replace the fork-family-messages TODO with the behavior of message_family_chat and chatd.chat_family_messages after the organization_id change. * chore(coderd/database/forkdb): regenerate family message queries for organization_id * fix(coderd): lead the family message index with sender_chat_id The ON DELETE CASCADE from chats looks up rows by sender_chat_id alone, which an index leading with organization_id cannot serve.
Part of #247 (PR 1 of 4: server tool; next are
list_family_chats, the tool card and the recipient header).Adds the
fork-family-messagesexperiment and themessage_family_chatchat tool. A chat sends a text message by chat ID to any other chat with the same root: its parent, a sibling or another descendant. Delivery works likemessage_agent: an idle recipient starts a turn, a busy recipient gets the message before its next model call (steer), and no turn is interrupted. The message arrives as a user message in an<agent-message from_chat_id="..." from_title="...">envelope that names the sender and says it comes from an agent, not from the user.chatd.chat_family_messagesrow (new chatdmig node) in the send transaction throughforkAdmit. A sender may send at most 60 messages in the rolling hour, and the tool runs its calls serially so parallel calls in one step cannot pass the limit together.message_agent, a message to a finished child counts against the family live-subagent limit.Known limit: a parent blocked inside
wait_agentgets a family message only afterwait_agentreturns.The
coderd/x/chatd/ARCHITECTURE.mdchange is one TODO for the author to describe the feature.