sub agent causing improper turn end

Resolved 💬 3 comments Opened Mar 26, 2026 by iharc-jordan Closed Mar 27, 2026
💡 Likely answer: A maintainer (etraut-openai, contributor) responded on this thread — see the highlighted reply below.

What version of Codex CLI is running?

117

What subscription do you have?

pro

Which model were you using?

5.4

What platform is your computer?

windows (wsl)

What terminal emulator and version are you using (if applicable)?

wsl

What issue are you seeing?

When multi-agent v2 is enabled, a sub-agent completion causes the main session to end its turn. This is despite the end turn flag being false in the reply from the sub agent.

What steps can reproduce the bug?

Conduct a session with ma v2 enabled and have sub agents spawn.

What is the expected behavior?

Sub agent completions should not trigger an end of turn for the main agent.

Additional information

_No response_

View original on GitHub ↗

3 Comments

etraut-openai contributor · 5 months ago

Can you provide /feedback and post your thread ID here?

github-actions[bot] contributor · 5 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #14318

Powered by Codex Action

raye-deng · 5 months ago

This is a subtle but important lifecycle bug. When a sub-agent signals completion, the parent should have the autonomy to decide whether that constitutes a turn boundary — not have the decision forced on it by the transport layer.

The underlying issue is a signal semantics confusion: the sub-agent'\''s "end turn" flag is being interpreted by the orchestrator as "end parent turn" rather than "sub-task complete, return control." These are fundamentally different events.

We see a structurally similar problem in multi-session AI code generation: when an AI agent generates code across multiple sessions, each session treats its output as final. The cross-session boundary causes:

  1. Context handoff failures — Session 2 doesn'\''t know the implicit assumptions Session 1 made about module boundaries or naming conventions.
  2. Partial state propagation — Session 1 modified 4 files but only 3 made it into the context Session 2 received. The missing file causes a type mismatch.
  3. False completion signals — Each session reports success independently, but the combined output is inconsistent.

The fix here should decouple the two signal paths: sub-agent completion (data plane) from turn management (control plane). The parent orchestrator should be the sole authority on turn boundaries.

In a CI context, we handle the multi-session inconsistency problem by running cross-file reference validation at merge time — checking that all imports, type references, and function signatures are consistent across the full changeset, not just within each individual session'\''s output.

npx @opencodereview/cli scan . --sla L1 if you want to try catching these cross-session inconsistencies in your own pipeline.