Skip to content
This repository was archived by the owner on Aug 6, 2026. It is now read-only.

feat: show Codex subagent activity in conversations - #3449

Closed
MattPua wants to merge 3 commits into
mainfrom
posthog-code/render-codex-subagents
Closed

feat: show Codex subagent activity in conversations#3449
MattPua wants to merge 3 commits into
mainfrom
posthog-code/render-codex-subagents

Conversation

@MattPua

@MattPua MattPua commented Jul 14, 2026

Copy link
Copy Markdown
Member

Problem

Codex delegated-agent activity is emitted on child thread IDs, but the adapter only surfaced main-thread notifications. As a result, users could not see the subagent's streamed messages or tool calls under the spawn action. The spawn row also appeared finished as soon as creation completed, even while the child was still running, and wait/resume/close actions incorrectly inflated the displayed subagent count.

Changes

  • Route supported child-thread notifications to their parent spawn tool call using canonical PostHog metadata.
  • Map Codex collaboration calls into dedicated subagent rows and keep them active while a child is running.
  • Nest child messages and tool calls under the correct subagent row.
  • Count only actual spawn calls as subagents, while still rendering other collaboration actions consistently.

Screenshots not included because this change corrects streamed runtime state that is covered by focused adapter and conversation-builder tests.

How did you test this?

  • Ran 172 targeted Vitest tests across agent, shared, and UI packages.
  • Ran pnpm --filter @posthog/agent typecheck.
  • Ran pnpm --filter @posthog/ui typecheck.
  • Ran Biome checks and git diff --check.
  • Commit hooks ran the full repository typecheck successfully.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog Code

Generated-By: PostHog Code

Task-Id: 76a928b2-1000-4c64-aae1-98bd85c2fa4b
@trunk-io

trunk-io Bot commented Jul 14, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 39d0b4d.

@MattPua
MattPua marked this pull request as ready for review July 14, 2026 20:50
@greptile-apps

greptile-apps Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "feat: render Codex subagent activity" | Re-trigger Greptile

Comment on lines 304 to 305
status: mapStatus(item.status),
...(tool.rawInput !== undefined ? { rawInput: tool.rawInput } : {}),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Replay Marks Running Spawns Complete

When a session is rebuilt from history while a spawned child is still pendingInit or running, this path uses the raw collab item status instead of the live mapToolStatus override. A completed spawn with an active child is replayed as finished, so the UI can show the subagent row as done even though the child is still running.

Suggested change
status: mapStatus(item.status),
...(tool.rawInput !== undefined ? { rawInput: tool.rawInput } : {}),
status: mapToolStatus(item),
...(tool.rawInput !== undefined ? { rawInput: tool.rawInput } : {}),

childItems &&
childItems.length > 0
) {
if (isSubagentTool(toolName)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Childless Collaboration Rows Lose Details

When send_input, resume_agent, wait_agent, or close_agent has no nested child items, this branch still renders it with SubagentToolView. That view only shows child content, so these ordinary collaboration actions lose their own input/output details and become header-only Subagent · ... rows instead of the normal tool row.

this.mcp.release(params);
}

if (!isMainThread) return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Child Token Usage Is Dropped

When Codex emits thread/tokenUsage/updated for a spawned child thread, this early return skips the usage ingestion and usage extension notification path below. A turn that delegates work to a subagent can then underreport token usage and cost because only the parent thread's usage reaches the tracker.

Generated-By: PostHog Code
Task-Id: 971044c5-e622-4f07-b1b5-dca9b06d040c
@richardsolomou richardsolomou changed the title feat: show Codex subagent activity in conversations fix: isolate Codex subagent output in conversations Jul 15, 2026
@richardsolomou

richardsolomou commented Jul 15, 2026

Copy link
Copy Markdown
Member

@MattPua i started working on this as well, then Sol saw that you had an open PR for it too, and it went nuts and just pushed changes to yours, sorry about that - reverted

Restore the original implementation and leave the thread-isolation fix to its separate pull request.

Generated-By: PostHog Code
Task-Id: 971044c5-e622-4f07-b1b5-dca9b06d040c
@richardsolomou richardsolomou changed the title fix: isolate Codex subagent output in conversations feat: show Codex subagent activity in conversations Jul 15, 2026
@MattPua MattPua closed this Jul 15, 2026
@MattPua
MattPua deleted the posthog-code/render-codex-subagents branch July 15, 2026 13:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants