Skip to content

🐨 feat: Read Subagent Messages Through Their Parent Conversation - #18187

Merged
danny-avila merged 1 commit into
devfrom
danny-avila/child-thread-read-routes
Nov 17, 2026
Merged

danny-avila merged 1 commit into
devfrom
danny-avila/child-thread-read-routes

Conversation

@danny-avila

Copy link
Copy Markdown
Collaborator

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/messages returns 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/:partIndex reads 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; getSubagentThreadMessages and getSubagentThreadToolCallPart in packages/data-provider are its entry points.

Builds on #18169.

How it works

GET /convos/:parent/subagents/:thread/messages
  createChildThreadMessagesHandler            # packages/api/src/agents/view.ts
    getMessages({ conversationId: thread, user }, CLIENT_MESSAGE_SELECT)   # started beside the check
    authorizeChildThread                      # parent ownership, lineage, tenant
    withoutEventInput                         # event threads only
    previewToolCalls                          # the conversation route's previewer

GET …/messages/:messageId/parts/:partIndex
  createChildThreadToolCallPartHandler
    createToolCallPartHandler({ validate: authorizeChildThread })   # the shared reader

The child-only fields (subagentTranscript, subagentActivityProjection, subagentTask, subagentContent, subagentTriggerProjection) are select: false in the schema, so the conversation projection already leaves them out.

Type of change

  • Feature

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.
  • Reran messages/parts.spec.ts, api/server/routes/__tests__/convos.spec.js and convos-duplicate-ratelimit.spec.js, the two specs that load the convos router.
  • npx tsc --noEmit in packages/api and packages/data-provider; npm run static-checks -- --against origin/dev.

Not covered: a request against a running server.

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review the latest head, final review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 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-15T13:58:28.868949Z 5072972 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: 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".

Comment on lines +1527 to +1531
export function getSubagentThreadMessages(
parentConversationId: string,
threadId: string,
options?: { toolPreviews?: boolean },
): Promise<s.TMessage[]> {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

  • getSubagentThreadMessages is called by the app's useThreadChat (client/src/Providers/SubagentsHostContext.tsx), with loading, failure and a fallback to the existing view when the read fails.
  • getSubagentThreadToolCallPart is called by useSubagentThreadToolCallPartQuery (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.
@danny-avila
danny-avila force-pushed the danny-avila/child-thread-read-routes branch from 5072972 to 068b05a Compare November 17, 2026 14:41
@danny-avila
danny-avila marked this pull request as ready for review November 17, 2026 14:42
@lia-by-librechat lia-by-librechat Bot changed the title 🚪 feat: Read a Subagent Child Thread's Messages Through Its Parent 🐨 feat: Read Subagent Messages Through Their Parent Conversation Nov 17, 2026
@danny-avila
danny-avila merged commit be42a7d into dev Nov 17, 2026
68 of 69 checks passed
@danny-avila
danny-avila deleted the danny-avila/child-thread-read-routes branch November 17, 2026 15:05
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