Repository navigation
feat(coderd): add the list_family_chats tool behind fork-family-messages - #266
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
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
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
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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 948728d5ff
ℹ️ 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
…-messages-2-list # Conflicts: # coderd/x/chatd/fork_family_messages.go # coderd/x/chatd/fork_family_messages_internal_test.go
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 402124fda2
ℹ️ 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. Keep them coming! 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". |
…dget 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
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ac16d27044
ℹ️ 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. 🎉 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.
The ON DELETE CASCADE from chats looks up rows by sender_chat_id alone, which an index leading with organization_id cannot serve.
…ages-1-tool # Conflicts: # docs/reference/api/schemas.md
…-messages-2-list # Conflicts: # coderd/database/forkdb/queries/chat_family_messages.sql # coderd/x/chatd/ARCHITECTURE.md # coderd/x/chatd/fork_family_messages_internal_test.go
…ages-2-list # Conflicts: # coderd/database/dbauthz/fork_forkdb_test.go # coderd/database/forkdb/chat_family_messages.sql.go # coderd/database/forkdb/queries/chat_family_messages.sql # coderd/x/chatd/ARCHITECTURE.md # coderd/x/chatd/fork_agent_tool_policy.go # coderd/x/chatd/fork_family_messages.go # coderd/x/chatd/fork_family_messages_internal_test.go
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! 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-2-list # Conflicts: # coderd/x/chatd/ARCHITECTURE.md
@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". |
Merged as
|
Part of #247 (PR 2 of 4, stacked on #265).
Adds the
list_family_chatschat tool behindfork-family-messages, so a chat can find the chat IDs thatmessage_family_chattakes. It lists the family's unarchived chats, root first and then by creation time, with each chat's ID, title, status, parent and its relation to the caller (self,parent,root,child,siblingorother). At most 100 chats are listed, withtruncated: truewhen the family has more.ListChatFamilyMembers, authorized as a read of the root chat.list_family_chatsjoinsmessage_family_chatin the custom agentTaskalias, and themessage_family_chatdescription points to it.