Skip to content

🎦 feat: Open Background Subagent Conversations in the Panel - #18197

Merged
danny-avila merged 7 commits into
devfrom
danny-avila/child-thread-pane
Nov 17, 2026
Merged

danny-avila merged 7 commits into
devfrom
danny-avila/child-thread-pane

Conversation

@danny-avila

@danny-avila danny-avila commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Opening a background subagent in the panel shows a transcript the panel assembles itself: a durable thread view projected into turns, with live content from an activity feed that keeps the last 100 events for five minutes. Whether the reader sees the child's latest output depends on when they opened the panel relative to that window, which is the "sometimes it has the latest events, sometimes it does not" behavior. Switching chats does not have this problem, because a chat attaches to its generation job and replays it.

Since #18169 a background child has a generation job of its own, keyed by its thread id, and #18187 added parent-scoped routes that read a child thread's messages and tool calls. Nothing in the client used either. This PR is that entry point: the panel opens a background child's thread as a conversation. It reads the thread's messages through the parent, attaches to the child's generation job the way a chat reattaches to its own, and draws the result with main chat's message list. A reader who opens the panel late sees what one who watched from the start sees.

Last in a stack, on #18196. This is the frontend entry point the review of #18187 asked for. It includes the change that was #18217 (guidance still waiting on the child, with its Withdraw), folded in so the conversation body never ships without it.

Verified in Chromium against a server started from this branch (the mock e2e lane: in-memory Mongo, fake model), including the case this work is for: a child that has produced more history than the activity feed keeps, opened late while it is still running.

How it works

SubagentThreadPanel (selection: a background child with a durable thread)
  host.useThreadChat(parent, threadId, { live: task is running })        # app: SubagentsHostContext
    useFollowChat                                                        # 18192
      getStatus(threadId)                         GET /api/agents/chat/status/:threadId
      loadMessages                                GET /api/convos/:parent/subagents/:thread/messages   (18187)
      resumeStream                                GET /api/agents/chat/stream/:threadId?resume=true    (18169's job)
  FollowedChildThread
    FollowedThread → MessagesView                                        # 18193, rows read-only (18196)
    tool call expanded → host.useThreadToolContent
                                                  GET /api/convos/:parent/subagents/:thread/messages/:id/parts/:i  (18187)

The panel's shell is unchanged: header, actor picker, the composer that steers the child, continue-as-chat. Only the body changes, and only for a background child. Foreground children (no thread of their own) and event threads (a per-task timeline) keep the durable view.

States the body can be in:

State What the reader sees
Messages loading, nothing to show yet A Loading status
Thread loaded, nothing running The stored conversation
A generation is running The conversation, streaming, with steers sent to the child placed where they were injected (#18195)
The run ends The stored result, read again
Messages cannot be read (a server without the route) The durable view, as before
Task running but no generation to attach to (subagentActivity.generationJobs: false) The durable view, as before
The followed stream drops and cannot be reattached The durable view, with its own retrying activity stream
A stored reply came without its content parts The durable view, whose projection is the only place that history lives

The first two fallbacks keep the panel working against an older API replica and with the feature's off switch. The third is what happens after useFollowChat (#18192) has run out its reconnect schedule. The fourth covers children whose result row holds only text: run without a generation job, with generationContentBytes: 0, over the row's budget, or written before rows stored content. It is judged only on stored rows (the first read, or the read at a run's end), never on a reply still being streamed.

The durable view is kept once chosen for a thread, so the transcript does not swap back when the run it was drawing ends. A thread that has not fallen back stays the conversation when its run ends before the task view catches up.

While the thread is followed the activity feed's stream stays closed: one stream per thread.

Two additions to useFollowChat support this: enabled, so the panel can call the hook for every selection, isFollowing, which is true from the start of an attachment until its run has ended and been read, and isUnattached, which is false until an attachment has been tried and true only when it found no generation or lost its stream for good. The panel falls back on isUnattached, so an attachment that has not started yet is not taken for one that found nothing. It also reads the stored messages again when the caller's live turns false, which covers a run that ended without a stream.

FollowedThread now supplies its own messages host over the page's: a row's useGetMessages reads the followed list, there is no queued turn of the reader's, and reading the thread marks no conversation of theirs seen.

Guidance the child has not taken yet

The durable view shows guidance that was sent to the child but not taken yet, dimmed, after the transcript, with the control that withdraws it. The conversation body keeps that. Main chat's message list has a slot for exactly this position, renderPendingSteers: what is waiting on the conversation's run, after the last row. FollowedThread leaves it empty by default; the panel fills it.

SubagentThreadPanel
  activity.controls                  # the task's receipts, from its durable view, plus one just submitted
  FollowedChildThread
    renderPendingSteers  ──>  SubagentControlHistory(controls, content = every part the thread shows)
                                waiting    -> the app's steer bubble, dimmed, + Withdraw
                                refused    -> the bubble + why
                                applied and already a part of the reply  -> not drawn (it is in the reply)
    Withdraw  ──>  submitControl('cancel_message', controlId)   # the panel's existing command

SubagentControlHistory is the list the durable view already renders; it is exported and reused, not copied, so the two bodies decide what counts as "already shown" with one rule: a receipt whose steer part is in the content is left out. The durable view's receipt can still say accepted for a moment after the stream has delivered the applied steer, and the reply's part wins. The list sits in main chat's row column (getMessageRowWidthClass), so it lines up with the turns above it.

Main chat's own PendingSteers component is not used: it reads main chat's steer chips and cancels through main chat's steer routes, and a child's guidance is a different record (a control receipt) withdrawn through the subagent control route. Sharing the slot and the bubble is the part that is the same.

Type of change

  • Feature
  • Tests / tooling / CI

Testing

Tested environments/configuration:

  • Chromium via Playwright, e2e/playwright.config.mock.ts, server and client built from this branch, in-memory Mongo, fake model, Linux (WSL2).
  • subagentActivity.generationJobs at its default (on).

Automated tests:

  • e2e/specs/mock/subagent-activity.spec.ts, all four cases pass locally on this head:

    • late open and cold reload "restore over-capacity history while running and complete once": every retained tool call appears once and in order while the child is still running, its full output opens through the parent-scoped part route, a steer sent to the child lands between the text before and after it, the run goes live, completes once, and restores after a reload. These pass through the new conversation body (checked with a DOM probe, not assumed).
    • detached subagent activity: rewritten for the new mechanism. It used to require exactly one request to the activity feed; it now requires the thread's messages to be read through the parent, at most one generation stream per child with none added after the run ends, and no request to the activity feed at all.
    • steerPlacement now finds its conversation root in either body.
    • New case: a steer the child took before the panel was opened is drawn between the work before it and the work after it. It passes in both bodies, so it pins the behavior without reproducing the misplaced steer seen on the demo, which needs a child that keeps working well past the steer while the panel is closed.
    • expandHistory no longer waits on a fold that closed between being counted and being clicked. On the Redis lane the late-open and cold-reload cases failed about one run in eight with the new body, and the cause was this helper, not the pane: sampling the page through a failing window showed all 113 rows present and in order from 0.25 s after the live call was released, with no fold collapsed, while the helper sat in a click on the live call's "running" card, which is replaced by the call's own row when the call ends about 0.1 s later. The conversation body draws the live row in about 0.17 s, early enough to land the helper's first pass inside that window. With the click bounded, both cases pass 26 of 26 on Redis locally.
  • The same parity test also passes with the messages read blocked at the network, which is the mixed-version fallback: the panel mounts the durable view and stays on it through the end of the run (again checked with the DOM probe).

  • client/src/Providers/__tests__/SubagentsHostFollow.spec.tsx (5), packages/chat/src/components/subagents/__tests__/panel.spec.tsx (9 new), followed.spec.tsx (6), follow.spec.tsx (3 new); each panel rule was removed in turn to confirm its test fails.

  • packages/chat: npx jest src/components/subagents src/components/pane src/components/messages src/react/__tests__/follow.spec.tsx (752 tests), npx tsc --noEmit. client: the two host specs, hosts.test.tsx, the Subagents data-provider tests, Presentation.test.tsx (52 tests). npm run static-checks -- --against origin/dev. CI's client typecheck passes on this PR.

  • Guidance waiting on the child:

    • subagent-activity.spec.ts, case "guidance the child has not taken yet waits after the last row and can be withdrawn": with a child held before its next tool boundary, a steer sent to it appears after everything the child has done, with one Withdraw; clicking it posts cancel_message to the control route and the button goes away; the child then finishes without that guidance in its reply. It passed on the memory lane and 4 of 4 on Redis, and fails with the change removed and the client rebuilt ("waiting guidance: expected 1, received 0").
    • followed.spec.tsx (6 more): waiting guidance after the last row and its withdrawal; no receipt for guidance the reply already shows; no Withdraw while the task cannot be controlled; the reason for refused guidance; the "earlier control activity" notice; nothing added when no guidance was sent. panel.spec.tsx (1 more): the panel hands the conversation the task's waiting receipts, and Withdraw sends cancel_message with the task and control ids.

Screenshots / recordings

A background child with 100+ tool calls, opened late. "Before" is the durable view, which is what dev draws; it is produced on this build by blocking the messages read, so both columns are one build, one fixture, one viewport (1440x900).

Before (durable view) After (the thread as a conversation)
Running, light Before, running, light After, running, light
Finished, light Before, finished, light After, finished, light
Running, dark Before, running, dark After, running, dark
Finished, dark Before, finished, dark After, finished, dark

The two are meant to look alike: the durable view already drew its rows with the package's message row and content renderers, so what changes is where the content comes from, not how it is drawn. The visible difference is on the left, in the parent's card (see the first risk below).

Guidance waiting on a running child, in the conversation body:

Light Dark
Waiting guidance, light Waiting guidance, dark

Risk / compatibility

  • The parent's inline card loses its live preview while the panel is open. In the captures, the card in main chat reads "Ran agent" with three preview lines before and "Agent activity" after. Those lines were fed by the activity feed the panel used to open; a followed thread does not open it. The card behaves as it does when no panel is open. Feeding the card from the followed chat is possible and not in this PR.
  • Side gutter. Main chat's rows take their horizontal gutter from the viewport's width, so in this panel they would sit 8px from the edge; the panel adds the difference. Worth knowing for the next surface that embeds the list.
  • Presentation of the brief. The durable view draws a child's first turn as a briefing from the parent agent. In main chat's list it is the thread's user message, so it is drawn as a user turn. That is a visible change and a product call to make with the build in front of us.
  • What the conversation body does not show. History paging by turn and per-turn "load more" are gone for a followed thread, because the whole thread's messages are loaded. An applied steer appears in the reply where it was injected. Guidance still waiting on the child is drawn after the last row, with its Withdraw (see below).
  • Mixed versions. A client with this change against a server without 🐨 feat: Read Subagent Messages Through Their Parent Conversation #18187 falls back to the durable view, as the table says. A server with 🐨 feat: Read Subagent Messages Through Their Parent Conversation #18187 and an older client is unaffected.
  • Off switch. endpoints.agents.subagentActivity.generationJobs: false keeps running children on the durable view; finished threads still open as conversations, which needs only the read routes.

@danny-avila
danny-avila added this pull request to stack #18259 November 17, 2026 14:36
@danny-avila
danny-avila force-pushed the danny-avila/child-thread-pane branch 2 times, most recently from 71eef07 to 097a068 Compare November 17, 2026 15:05
@lia-by-librechat lia-by-librechat Bot changed the title 🧵 feat: Open a Background Subagent's Thread as a Conversation in the Panel 🎦 feat: Open Background Subagent Conversations in the Panel Nov 17, 2026
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 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-17T17:44:26.792220Z b2fcc9a 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: 097a068bf4

ℹ️ 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 +315 to +317
const unfollowable =
followed != null &&
(followed.isLoadError || (followLive && !followed.isLoading && !followed.isFollowing));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Wait for attachment resolution before latching the durable fallback

If the messages finish loading before the task transitions from dispatched to running, this condition treats the first render with followLive: true as proof that no generation exists. However, useFollowChat only starts attaching in its effect, so isFollowing is still false during that render. The panel's effect consequently latches followMode to durable, and the subsequent successful attachment cannot change it. The reader remains on the old transcript while both the generation stream and activity stream run. Distinguish an attachment that has not started yet from a confirmed absence before permanently selecting the fallback.

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. Fixed in e6c5e80688. The panel no longer infers "nothing to follow" from !isFollowing. useFollowChat reports isUnattached, which is false until an attachment has actually been tried and true only when it found no generation or lost its stream for good; the durable fallback is chosen on that. Pinned by does not take an attachment that has not started yet for one that found nothing (panel) and says a run the caller knows of has no stream only once an attachment found none (hook); the panel case fails with the old condition restored.

Comment on lines +1737 to +1741
{follows && followed != null ? (
<FollowedChildThread
threadId={threadId}
followed={followed}
agentId={taskView?.agentId ?? foregroundAgentId}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve durable history when stored message content is omitted

For completed children created with generationJobs: false, generationContentBytes: 0, or content exceeding the configured retention budget, SubagentThreadTaskStore.generationContent() and persistResult() deliberately omit the message's content while retaining its transcript/activity projection. The messages route returns those ordinary message rows without reconstructing the projection, so the read succeeds and this branch replaces the durable transcript with only the final text, losing the previously available tool history and intermediate output. A streamed oversized run also loses its displayed history when useFollowChat rereads the stored rows at completion. Preserve the durable view for these records or reconstruct their retained history before rendering them as conversations.

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. Fixed in e6c5e80. When the stored rows are what is on screen (first read, or the read at a run's end) and a reply came without its content parts, the panel keeps the durable view, whose projection is the only place that history lives. That covers children run without a generation job, with generationContentBytes: 0, over the row budget, and rows written before content was stored; a streamed oversized run hands over to the durable view when its stored row is read. A reply still being streamed is not judged by the parts it has so far. Pinned by keeps the durable view for a finished thread whose stored reply lacks its parts, draws a finished thread whose stored reply holds its parts as a conversation and does not judge a reply still being streamed by the parts it has so far; removing the check, or applying it mid-stream, fails one of them.

Comment on lines 336 to +338
const contentStream = panelStore.useActivityStream(
selection,
!durableTerminal || eventTaskRunning,
!follows && (!durableTerminal || eventTaskRunning),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Recover the live transcript after a generation stream disconnects

After a network interruption on an already-followed child, createSSETransport reports the disconnect without retrying it (its automatic retry only handles token refresh), and Chat.resumeStream() records the failure and resolves. useFollowChat then rereads stored messages but never reattaches while live remains true. Because the panel has latched the followed mode, this condition also keeps the previously retrying activity stream disabled. The panel therefore stops receiving output for the remainder of the run and can lose the in-progress reply when the stored rows replace it, with no retry control exposed. Reconnect the generation stream or restore the activity fallback when the followed connection drops.

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. Fixed in two places. In #18192 (2d5c947) the hook reattaches a dropped stream on main chat's reconnect schedule and keeps what it showed instead of reading stored rows over it. Here (e6c5e80), if that schedule runs out the hook reports isUnattached and the panel hands the run back to the durable view, which reopens its own retrying activity stream; the durable choice now wins over an earlier followed one. Pinned by hands a run back to the durable view when its followed stream is lost for good (panel, asserts the activity stream is enabled again) and says the stream is gone once a dropped one could not be attached again (hook).

@danny-avila
danny-avila force-pushed the danny-avila/child-thread-pane branch 2 times, most recently from 000d128 to e6c5e80 Compare November 17, 2026 15:34
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Head e6c5e80688.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: e6c5e80688

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

@danny-avila
danny-avila force-pushed the danny-avila/child-thread-pane branch from e6c5e80 to ba56efc Compare November 17, 2026 15:38
@danny-avila
danny-avila force-pushed the danny-avila/child-thread-pane branch from ba56efc to 5d8b118 Compare November 17, 2026 15:42
@danny-avila
danny-avila force-pushed the danny-avila/child-thread-pane branch from 5d8b118 to 70e2f2e Compare November 17, 2026 15:48
@danny-avila
danny-avila force-pushed the danny-avila/child-thread-pane branch 2 times, most recently from 1c71c9b to 984931a Compare November 17, 2026 16:10
@danny-avila
danny-avila marked this pull request as ready for review November 17, 2026 16:11
@danny-avila
danny-avila force-pushed the danny-avila/child-thread-pane branch from 984931a to efa6b9e Compare November 17, 2026 16:15
@danny-avila
danny-avila force-pushed the danny-avila/child-thread-pane branch 4 times, most recently from d440c2f to bd39f29 Compare November 17, 2026 17:07
@danny-avila
danny-avila force-pushed the danny-avila/child-thread-pane branch from bd39f29 to 71ba063 Compare November 17, 2026 17:22
Base automatically changed from danny-avila/read-only-contract to dev November 17, 2026 17:36
@danny-avila
danny-avila force-pushed the danny-avila/child-thread-pane branch from 71ba063 to 5457d5d Compare November 17, 2026 17:36
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Head 5457d5d (rebased onto dev after #18196 merged).

@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: 5457d5d465

ℹ️ 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 +1750 to +1753
{follows && followed != null ? (
<FollowedChildThread
threadId={threadId}
followed={followed}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep pending control receipts visible in followed threads

When a user queues guidance or submits a steer that remains accepted but unapplied, this branch replaces the durable transcript containing SubagentControlHistory, which renders the pending receipt and its Withdraw button (subagents/transcript.tsx:199–213). The followed conversation supplies neither replacement: FollowedThread disables pending-steer rendering, and the panel footer only displays failed receipts. Consequently, guidance disappears after submission until it is applied, and users can no longer withdraw it while the child is busy. Preserve the control-receipt history and cancellation action alongside the followed messages.

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 for this PR on its own. The fix was the next PR in the stack, #18217; it is now folded into this one (b2fcc9a is this PR's head), so the conversation body never ships without it. Guidance the child has not taken yet is drawn after the last row through the list's renderPendingSteers slot, using the same SubagentControlHistory the durable view renders, with Withdraw wired to the panel's cancel_message command; refused or failed guidance shows there with its reason, and guidance the reply already shows is not drawn twice. Pinned by six cases in followed.spec.tsx, one in panel.spec.tsx, and the browser case "guidance the child has not taken yet waits after the last row and can be withdrawn", which fails with the change removed and the client rebuilt.

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Head b2fcc9a (now includes the pending guidance and Withdraw from #18217).

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: b2fcc9a17e

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

@danny-avila
danny-avila merged commit 90304e3 into dev Nov 17, 2026
127 of 128 checks passed
@danny-avila
danny-avila deleted the danny-avila/child-thread-pane branch November 17, 2026 17:57
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