Skip to content

Fix missing replies after native Codex subagents finish - #130311

Merged
pash-openai merged 2 commits into
mainfrom
pash/fix-native-subagent-completion
Aug 26, 2026
Merged

pash-openai merged 2 commits into
mainfrom
pash/fix-native-subagent-completion

Conversation

@pash-openai

Copy link
Copy Markdown
Contributor

Codex already delivers native subagent results to a running parent. OpenClaw was independently steering the same completion into that turn. If the parent had just written its answer, the extra notification could prompt a NO_REPLY that replaced the answer before it reached the user.

This keeps completion input with Codex while the parent is working. The monitor records native delivery receipts for the current parent turn and its known children, while continuing to track task status. Any result that was not delivered natively still wakes the parent after its foreground run finishes. Detached recovery, delivery retries, and deliberate silence remain intact; the final-answer selector is unchanged.

The receipt uses the existing public Codex agent-message envelope and completion format. Synthetic regressions exercise both event orderings through the monitor and final-answer projector, as well as late completion, intentional silence, stale or unrelated receipts, and client shutdown.

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@pash-openai
pash-openai marked this pull request as ready for review August 26, 2026 19:17

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eb6033ca49

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

}
// Codex owns completion input while a parent turn is running. Wait until
// its reply is finalized before waking it for any still-undelivered child.
if (state.owners.size > 0 && state.turnIds.size > 0) {

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 Badge Fence completion delivery during turn startup

When a child completes after registerParent but before turn/started or bindTurn, owners is nonempty but turnIds is empty, so this condition falls through and immediately calls deliverAgentHarnessTaskCompletion. The monitor is registered before route activation in extensions/codex/src/app-server/run-attempt-route.ts:82-92, while the turn ID is not bound until extensions/codex/src/app-server/run-attempt-turn-start.ts:325-326; Codex can therefore also inject the native result into the starting turn, recreating the duplicate steer and missing-final-answer race. Treat an unbound active owner as startup-in-progress and let unregister drain the completion if startup fails.

AGENTS.md reference: AGENTS.md:L45-L47

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 572ae7c. Registration now fences synthetic completion delivery even before a turn ID exists. Releasing the final registration drains any completion that Codex has not consumed, including startup failure. The regression exercises an unbound parent and proves there is no delivery until release; the existing detached/recovery and subscription-ownership cases now explicitly model whether the parent is active or detached. All 227 focused monitor, notification, projector, task-runtime, shared-client, and retention tests pass.

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-08-26T19:20:57.168039Z eb6033c Draft marked ready
ℹ️ 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.

@pash-openai

Copy link
Copy Markdown
Contributor Author

The fix is ready on 572ae7c. Codex owns native child-result delivery while the parent is starting, running, and finalizing its reply; OpenClaw only announces results that remain undelivered after that registration is released. This removes the duplicate steer without changing last-answer selection or intentional NO_REPLY behavior.

The boundary regression fails on the original code and preserves the complete parent answer after the fix, in both native-first and terminal-first event order. It uses the real final-answer projector, not an assertion that the model should always answer. Coverage also includes startup before turn binding, detached completion, recovery and retry ownership, old/foreign/untrusted receipts, child subscription cleanup, and intentional silence. The pinned public Codex contract was inspected directly in core/src/context/inter_agent_completion_message.rs, core/src/session/handlers.rs, and protocol/src/protocol.rs.

All 227 focused tests pass with node scripts/run-vitest.mjs extensions/codex/src/app-server/native-subagent-monitor.test.ts extensions/codex/src/app-server/native-subagent-notification.test.ts extensions/codex/src/app-server/native-subagent-task-mirror.test.ts extensions/codex/src/app-server/event-projector.assistant.test.ts extensions/codex/src/app-server/shared-client.test.ts extensions/codex/src/app-server/run-attempt.native-hook-relay-retention.test.ts src/plugin-sdk/agent-harness-task-runtime.test.ts, using Node 24.19.0. Local broad checks encounter stale dependencies and sparse-checkout consumers; the clean exact-head CI run is authoritative for those checks. A public live-channel recording is unavailable because the reported deployment and conversation are private. Live release verification follows the requested backport workflow; no private transcript or runtime configuration is included here.

Production delta is +101 lines: explicit native delivery receipts and foreground-turn ownership cannot be expressed by the previous child-terminal-only state. Shared completion cleanup replaces the old duplicated success path. The rest is regression coverage and making existing background-delivery fixtures explicitly release the foreground owner. No schema, dependency, prompt, configuration, or model changes.

@pash-openai
pash-openai merged commit 8e9db5e into main Aug 26, 2026
113 checks passed
@pash-openai
pash-openai deleted the pash/fix-native-subagent-completion branch August 26, 2026 19:45
pash-openai added a commit that referenced this pull request Aug 26, 2026
* Fix missing replies after native Codex subagents finish (#130311)

* Fix missing replies after native Codex subagents finish

* Fence subagent completion during parent startup

(cherry picked from commit 8e9db5e)

* Keep test teardown compatible with the release lint rules

* Keep native completion receipts through child recovery (#130347)

(cherry picked from commit a021f79)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
)

* Fix missing replies after native Codex subagents finish

* Fence subagent completion during parent startup
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