Skip to content

feat: embed every nested subagent descendant under its root chat - #99

Merged
ibetitsmike merged 2 commits into
mainfrom
mike/nested-subagents-8-tree-api
Nov 10, 2026
Merged

ibetitsmike merged 2 commits into
mainfrom
mike/nested-subagents-8-tree-api

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

Xum opened this PR on behalf of @ibetitsmike.

Part of #8 (W2 nested subagents, item 5: agent tree for depth above 1, PRD R3.5, and the depth-2 hook payload test, R3.7). The sidebar half is #104. Merge #104 first: without it, the current sidebar would list a coordinator's workers as siblings of the coordinator.

With fork-nested-subagents on, the chat list and the single-chat GET of a root chat embed every descendant of that root, not only its direct children. With the experiment off, both responses are unchanged.

Why. A subagent can spawn its own subagents behind the experiment, but listChats and getChat embed GetChildChatsByParentIDs(roots), which returns direct children only. Workers of a coordinator never reach the client, so the sidebar cannot show or open them.

Change.

  • forkEmbeddedChildChats (new coderd/fork_chat_tree.go) runs upstream's GetChildChatsByParentIDs once with the experiment off. With it on, it repeats the same query level by level until a level is empty, with a seen set and a depth cap of 64 against a corrupt hierarchy. No new SQL: authorization filtering, has_unread and the archive filter still come from the upstream query, so a descendant the caller cannot read also hides its subtree. The two handlers in exp_chats.go change by one call each.
  • db2sdk.ChatRowsWithChildren groups embedded rows by root_chat_id (falling back to parent_chat_id). A direct child's root is its parent, so depth-1 output is identical. The JSON shape does not change: a root's children stays one flat list, and each entry's parent_chat_id gives its place in the tree. Child chats still embed nothing.
  • The Chat.Children doc comment says this, and the generated TypeScript type and API docs follow (the docs diff is table re-padding around that one row).
Validation
  • New TestForkChatsEmbedDescendants (real Postgres in Colima) inserts a root, child and grandchild. Enabled: the list and the root GET each embed both descendants, the grandchild with parent_chat_id = child and root_chat_id = root; the child's own GET embeds nothing; after archiving the root, the root GET and the archived:true list still embed both. Disabled: only the child is embedded. Negative control: forcing the experiment-off path fails Enabled and keeps Disabled green.
  • New TestNestedSubagentHookPayload (R3.7) spawns root, child and grandchild through the real spawn path with agent-lifecycle-hooks and fork-nested-subagents on, and asserts that the grandchild's user_prompt_submit payload names the child as parent and the root as root.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum commented on behalf of @ibetitsmike.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 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-10T04:08:28.091172Z 83e25a4 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.

@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: b888ff02a4

ℹ️ 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/database/db2sdk/db2sdk.go Resolved
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum commented on behalf of @ibetitsmike.

@ibetitsmike ibetitsmike reopened this Nov 10, 2026
…-8-tree-api

# Conflicts:
#	docs/reference/api/chats.md
@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: b888ff02a4

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

@codex review

Xum commented on behalf of @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 83e25a479e

ℹ️ 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 (4b124f4c46) and run fork-ci on it. The head is unchanged.

@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 (4b124f4c46), 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 26c1e02 into main Nov 10, 2026
20 of 27 checks passed
@ibetitsmike
ibetitsmike deleted the mike/nested-subagents-8-tree-api branch November 10, 2026 05:37
@ibetitsmike

Copy link
Copy Markdown
Owner Author

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

Merge evidence for head 83e25a479eeb207087727b0cef0f39f9478f7e8e:

  • fork-ci pull_request run 42761242278 passed; its build job checked out Merge 83e25a479e into 4b124f4c46 (current main). All checks green. Run 42753545910 had also passed on this head.
  • Codex round 2 on this exact head: no major issues (comment 6758711570). The earlier P2 (alone, this change would show workers as siblings in today's sidebar) is handled by merge order: feat(site/src): render nested subagent descendants in the agent tree #104, the sidebar tree, merged first. 0 unresolved review threads. Merge state CLEAN.
  • UAT PASS on a dev build of a local merge of this head with feat(site/src): render nested subagent descendants in the agent tree #104 (f3fa021), using a 3-level family (root > coordinator > worker) plus a direct worker. Driven with Playwright, the sidebar showed root, coordinator and worker links 1/1/1 when fully expanded, 1/1/0 with the coordinator collapsed, and 1/0/0 with the root collapsed. Archiving the root from its menu emptied the active view (0/0/0), and the API showed all 3 chats archived. The archived view expanded to 1/1/1. Unarchiving restored all 3, and the active view expanded back to 1/1/1. Clicking the worker opened its chat.

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