Repository navigation
🐨 feat: Read Subagent Messages Through Their Parent Conversation - #18187
Conversation
|
@codex review the latest head, final 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: 507297208c
ℹ️ 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".
| export function getSubagentThreadMessages( | ||
| parentConversationId: string, | ||
| threadId: string, | ||
| options?: { toolPreviews?: boolean }, | ||
| ): Promise<s.TMessage[]> { |
There was a problem hiding this comment.
Wire the child-message capability into a frontend entry point
For users opening a child thread, this change leaves the new message-loading capability unreachable: repository-wide searches for both new data-service functions and endpoint builders find only their definitions and endpoint tests. The existing frontend query in client/src/data-provider/Subagents/queries.ts:141 still calls getSubagentThread, so users continue receiving the bounded thread projection rather than the messages and expandable tool-call parts added here. Wire these readers into the child-thread UI, including loading and failure handling, before treating this feature as complete; the repository explicitly requires backend capabilities to ship with a frontend entry point.
AGENTS.md reference: AGENTS.md:L50-L53
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid: at this head the two readers have no caller. The entry point is the panel mount at the top of this stack, #18197 (34b37d8, 79e437c), which opens a background child's thread as a conversation in the subagent panel.
getSubagentThreadMessagesis called by the app'suseThreadChat(client/src/Providers/SubagentsHostContext.tsx), with loading, failure and a fallback to the existing view when the read fails.getSubagentThreadToolCallPartis called byuseSubagentThreadToolCallPartQuery(client/src/data-provider/Subagents/queries.ts) when a tool call in that thread is expanded.- Both are covered in
client/src/Providers/__tests__/SubagentsHostFollow.spec.tsx.
The PRs between this one and #18197 (#18188, #18190, #18192, #18193, #18194, #18195, #18196) are what the mount is built from. #18197 is verified in jsdom only and has not been seen in a browser yet, so this PR should merge with that stack rather than alone.
A subagent child thread is reachable only through the parent the requester owns: /api/messages/<threadId> answers 404 by design, and the durable thread view sends a bounded projection, not messages. A chat pane pointed at a child thread therefore had nothing to load. GET /api/convos/:parent/subagents/:thread/messages returns the thread's rows with the conversation route's projection and tool-call previews, after the thread view's parent, lineage and tenant check. An event thread's input is the raw payload of an external event, so its row is sent with empty text, as the thread view already does. A second route reads the full tool call behind a preview, reusing the conversation route's reader.
5072972 to
068b05a
Compare
Summary
A subagent child thread is reachable only through the parent conversation the requester owns.
GET /api/messages/<threadId>answers 404 by design, and the durable thread view (GET /api/convos/:parent/subagents/:thread) sends a bounded projection of activity and text, not messages. So a chat pane pointed at a child thread has nothing to load, even though #18169 made the thread's stream available through the ordinary status and stream routes.This PR adds the read side:
GET /api/convos/:parentConversationId/subagents/:threadId/messagesreturns the thread's rows exactly as the conversation messages route would: the same projection (CLIENT_MESSAGE_SELECT) and the same tool-call previews.GET /api/convos/:parentConversationId/subagents/:threadId/messages/:messageId/parts/:partIndexreads the full tool call behind a preview, through the conversation route's own reader.Both run the thread view's access check first: the requester owns the parent, the thread's lineage names that parent, and both are in the requester's tenant. Anything else answers 404.
An event-bound thread's input row is the raw payload of an external event. The thread view never sends it, and neither does this route: the row keeps its place in the thread with empty text and no attachments.
Nothing in the client calls these yet. They are the loader for the shared chat pane that follows;
getSubagentThreadMessagesandgetSubagentThreadToolCallPartinpackages/data-providerare its entry points.Builds on #18169.
How it works
The child-only fields (
subagentTranscript,subagentActivityProjection,subagentTask,subagentContent,subagentTriggerProjection) areselect: falsein the schema, so the conversation projection already leaves them out.Type of change
Testing
Automated tests:
packages/api/src/agents/view.spec.ts: the rows come back with the conversation projection and previews; an event thread's input is sent with empty text and without its payload; 404 with no rows when the parent is not the requester's, the thread is not under that parent, belongs to another parent, or is in another tenant; 404 without any read when the thread is its own parent; 500 without the error text when the read fails; the tool-call part is read from the thread once the check passes, and 404 with no part when it fails.packages/data-provider/specs/api-endpoints.spec.ts: both endpoint builders encode their ids, and the part endpoint carries the same identity query as the conversation one.messages/parts.spec.ts,api/server/routes/__tests__/convos.spec.jsandconvos-duplicate-ratelimit.spec.js, the two specs that load the convos router.npx tsc --noEmitinpackages/apiandpackages/data-provider;npm run static-checks -- --against origin/dev.Not covered: a request against a running server.