Skip to content

feat(coderd): add the list_family_chats tool behind fork-family-messages - #266

Merged
ibetitsmike merged 17 commits into
mainfrom
mike/chat-family-messages-2-list
Nov 13, 2026
Merged

ibetitsmike merged 17 commits into
mainfrom
mike/chat-family-messages-2-list

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Xum created this PR on behalf of @ibetitsmike.

Part of #247 (PR 2 of 4, stacked on #265).

Adds the list_family_chats chat tool behind fork-family-messages, so a chat can find the chat IDs that message_family_chat takes. 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, sibling or other). At most 100 chats are listed, with truncated: true when the family has more.

  • One new forkdb query, ListChatFamilyMembers, authorized as a read of the root chat.
  • list_family_chats joins message_family_chat in the custom agent Task alias, and the message_family_chat description points to it.

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
@ibetitsmike
ibetitsmike added this pull request to stack #267 November 13, 2026 01:52
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T12:10:53.423342Z 9ef2d69 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum posted this comment on behalf of @ibetitsmike.

@codex review

@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: 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".

Comment thread coderd/x/chatd/fork_family_messages.go Resolved
Comment thread coderd/x/chatd/fork_family_messages.go Resolved
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
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum posted this comment on behalf of @ibetitsmike.

@codex review (head now merges #265 fixes)

@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: 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".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum posted this comment on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 69734101d2

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

…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
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum posted this comment on behalf of @ibetitsmike.

@codex review

@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: 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".

Comment thread coderd/x/chatd/ARCHITECTURE.md Resolved
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum posted this comment on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

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

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
Base automatically changed from mike/chat-family-messages-1-tool to main November 13, 2026 11:29
…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
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum commented on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: cef7510173

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

…ages-2-list

# Conflicts:
#	coderd/x/chatd/ARCHITECTURE.md
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum commented on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 9ef2d69346

ℹ️ 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
ibetitsmike merged commit 30a2533 into main Nov 13, 2026
9 checks passed
@ibetitsmike
ibetitsmike deleted the mike/chat-family-messages-2-list branch November 13, 2026 12:31
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum merged this PR on behalf of @ibetitsmike.

Merged as 30a2533cde with a squash. These checks passed on head 9ef2d69346:

  • fork-ci run 43422627245 green (9 of 9 checks)
  • Codex: no major issues on 9ef2d69346
  • 0 unresolved review threads
  • branch up to date with main (044995538c)
  • paired dogfood UAT round 3 PASS on 9ef2d69346: list_family_chats relations match the DB tree, listing and then messaging a grandchild works, archived chats drop out of the list, a root archive cascades and refuses later sends, and both tools are absent with experiments off

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