Skip to content

Isolate Codex Session notifications by thread - #1740

Open
scottt732 wants to merge 1 commit into
kelos-dev:mainfrom
scottt732:fix/codex-child-notifications
Open

scottt732 wants to merge 1 commit into
kelos-dev:mainfrom
scottt732:fix/codex-child-notifications

Conversation

@scottt732

@scottt732 scottt732 commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind bug

What this PR does / why we need it:

Codex app-server publishes notifications for native subagent threads as well as the Session's root thread. Kelos currently applies every notification to the root interaction: a child error or completion can terminate the Session request while the root agent continues working, and child output or usage can be attributed to the parent.

Filter thread-scoped notifications to the provider's root thread before changing interaction state or emitting events. Preserve notifications without thread scope, including account-wide rate limits. Synchronize initial thread-ID publication with the notification reader.

Which issue(s) this PR is related to:

N/A

Special notes for your reviewer:

Reproduced with a persistent Codex Session spawning native analysts: one child failed while the root kept working, but the Session client received failure and disconnected. The regression test feeds child startup, text, error and completion notifications and then verifies the parent still emits output and completes normally.

Validation: go test ./internal/sessionruntime -run TestCodex -count=1 -race -timeout=90s passed. The new regression failed before the fix. Broader coverage is delegated to CI.

Does this PR introduce a user-facing change?

Native Codex subagent notifications no longer prematurely finish the parent Session turn or appear as parent output.

Summary by cubic

Filters Codex Session notifications by thread so child subagent events no longer affect the parent session. Previously, a child error or completion could prematurely finish the parent turn or be attributed as parent output.

  • Adds thread-scope filtering to the notification handler.
  • Locks thread ID writes so the handler never compares against a stale ID.
  • Adds a regression test verifying child notifications are ignored.

Written for commit baf75a1. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread internal/sessionruntime/codex.go Outdated
Codex app-server publishes notifications for native subagent threads as
well as the Session's root thread. Kelos applied every notification to
the root interaction, so a child error or completion could terminate the
Session request while the root agent kept working, and child output or
usage could be attributed to the parent.

Filter thread-scoped notifications to the provider's root thread before
changing interaction state or emitting events. Notifications without a
thread scope, including account-wide rate limits, are preserved, and
initial thread-ID publication is synchronized with the notification
reader so the handler never compares against a stale ID.

The regression test feeds child startup, text, error and completion
notifications and verifies the parent still emits output and completes
normally.

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>

This branch is waiting to be deployed

1 waiting deployment
ok-to-test — baf75a17 Waiting Sep 17, 2026 by scottt732 via fork-e2e / e2e-with-environment #1750
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant