Skip to content

fix: show Codex subagent activity without streaming child output#3465

Merged
richardsolomou merged 7 commits into
mainfrom
posthog-code/fix-codex-subagent-thread-isolation
Jul 15, 2026
Merged

fix: show Codex subagent activity without streaming child output#3465
richardsolomou merged 7 commits into
mainfrom
posthog-code/fix-codex-subagent-thread-isolation

Conversation

@richardsolomou

@richardsolomou richardsolomou commented Jul 15, 2026

Copy link
Copy Markdown
Member

Problem

Codex app-server multiplexes parent and subagent notifications over one connection. Treating child-thread events as parent state interleaves delegated output into the conversation, pollutes parent usage and compaction state, and can mark the parent turn complete while work is still running. Simply dropping every subagent-related event would also hide useful delegation status.

Why: The conversation should behave like Claude: show compact parent-level delegation activity, let the parent model consume final results, and keep child transcripts out of the user-visible thread.

Changes

  • Gate output, buffering, usage, compaction, and completion notifications by threadId while preserving child MCP tracking for approvals.
  • Map actual spawn calls into dedicated subagent rows while keeping orchestration operations distinct and preserving Codex's terminal tool status.
  • Render collaboration actions consistently, label grouped Codex spawn calls as subagents, and count only actual spawn calls.
  • Cover parent activity plus child output, usage, compaction, and cloud completion isolation in focused tests.

The pinned Codex implementation returns final subagent messages to the parent through wait_agent, so genuine parent-context growth from those results remains unchanged. Child notification streams no longer affect parent context indicators or lifecycle state.

Cloud tasks run the published @posthog/agent from the sandbox image rather than the package checked out in the task workspace. Cloud validation therefore requires this agent change to merge, publish, and trigger the sandbox image rebuild. Existing logs produced by older agents cannot be repaired safely during replay because normalized ACP updates no longer identify the originating Codex thread.

Screenshots are not included because the behavior depends on live multi-agent event routing and is covered by adapter, mapping, and conversation-grouping tests.

How did you test this?

  • Ran 116 focused Codex app-server adapter and mapping tests, including cloud task completion isolation.
  • Ran 11 focused conversation-grouping, subagent-label, and tool-routing UI tests.
  • Ran pnpm --filter @posthog/agent typecheck.
  • Rebuilt the UI dependency graph and ran pnpm --filter @posthog/ui typecheck.
  • Ran Biome checks on all changed files and git diff --check.

The full agent suite was also attempted, but unrelated tests that create temporary Git commits cannot run in this environment because unsigned git commit is intentionally blocked.

Automatic notifications

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

Created with PostHog Code

Keep child-thread output, usage, compaction, and completion notifications from mutating the parent ACP session.

Generated-By: PostHog Code
Task-Id: 971044c5-e622-4f07-b1b5-dca9b06d040c
@trunk-io

trunk-io Bot commented Jul 15, 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 15, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 12ec84a.

Keep compact collaboration rows and accurate status while child-thread output and lifecycle notifications remain isolated from the parent session.

Generated-By: PostHog Code
Task-Id: 971044c5-e622-4f07-b1b5-dca9b06d040c
@richardsolomou richardsolomou changed the title fix: isolate Codex subagent thread notifications fix: show Codex subagent activity without streaming child output Jul 15, 2026
Exercise the cloud task completion signal and document why child notifications must be filtered before ACP log persistence.

Generated-By: PostHog Code
Task-Id: 971044c5-e622-4f07-b1b5-dca9b06d040c
Read canonical tool metadata in the grouped conversation header so Codex spawn batches no longer fall back to the generic Other label.

Generated-By: PostHog Code
Task-Id: 971044c5-e622-4f07-b1b5-dca9b06d040c
@richardsolomou richardsolomou marked this pull request as ready for review July 15, 2026 11:04
@greptile-apps

greptile-apps Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "Label Codex collaboration groups as suba..." | Re-trigger Greptile

Comment thread packages/agent/src/adapters/codex-app-server/mapping.ts Outdated
Comment thread packages/agent/src/adapters/codex-app-server/mapping.ts Outdated
Comment thread packages/agent/src/adapters/codex-app-server/mapping.ts
@richardsolomou richardsolomou requested a review from a team July 15, 2026 11:08
Preserve terminal tool-call status, discard child output before buffering, and reserve the subagent UI for actual spawn operations. Add regressions for structured output, command buffering, active labels, and orchestration rendering.

Generated-By: PostHog Code
Task-Id: 971044c5-e622-4f07-b1b5-dca9b06d040c
@richardsolomou richardsolomou added the Create Release This will trigger a new release label Jul 15, 2026
Remove the duplicate bippy package key introduced by the Storybook lockfile update so frozen installs can parse the lockfile.

Generated-By: PostHog Code
Task-Id: 971044c5-e622-4f07-b1b5-dca9b06d040c
@richardsolomou richardsolomou enabled auto-merge (squash) July 15, 2026 11:24
@richardsolomou richardsolomou merged commit 6fe8625 into main Jul 15, 2026
30 checks passed
@richardsolomou richardsolomou deleted the posthog-code/fix-codex-subagent-thread-isolation branch July 15, 2026 11:31
@github-actions

Copy link
Copy Markdown

Could not verify team-posthog-code membership (GitHub API error). Auto-release is limited to Team PostHog Code members, so this will ship with the next scheduled release instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Create Release This will trigger a new release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants