User turns can continue in completed subagent thread after parent spawned it, leaving subagent role active

Resolved 💬 5 comments Opened Apr 20, 2026 by atelierdesdonnees Closed Apr 21, 2026
💡 Likely answer: A maintainer (jif-oai, contributor) responded on this thread — see the highlighted reply below.

What version of Codex CLI is running?

codex-cli 0.121.0

What subscription do you have?

Pro

Which model were you using?

GPT-5.4

What platform is your computer?

Darwin 25.4.0 arm64 arm

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

iTerm2

What issue are you seeing?

After a parent thread spawned an odoo-architect subagent, later user turns were appended to the child subagent thread instead of the original parent thread. From the user's perspective, the conversation looked like the same ongoing task, but the active thread was the subagent and retained the subagent role/persona.

This caused the assistant to behave as the odoo-architect child after the original architecture review was complete, including following the child agent's KB/review instructions in later unrelated turns.

What steps can reproduce the bug?

  1. Start a normal Codex TUI thread.
  2. Spawn a role-specific subagent with spawn_agent, e.g. an architecture reviewer.
  3. Wait for the subagent to complete.
  4. Continue the broader task in what appears to be the same UI/session.
  5. Observe that later user turns can be appended to the child subagent thread, with the child agent_role still active.

What is the expected behavior?

After the parent receives a completed subagent result, normal user turns should continue in the parent thread unless the user explicitly switches/resumes the child thread.

A completed child subagent should not remain the active conversation target for unrelated future user turns.

The UI/history should make it clear when the active thread is a subagent, and resume last / recent-thread selection should not silently continue in a completed child thread when the user expects the
parent.

Additional information

Local evidence

Parent session:

  • source: cli
  • no agent_role
  • spawned child via spawn_agent(agent_type="odoo-architect")
  • received the child result via wait_agent
  • parent stopped updating after the branch split work

Child session:

  • session_meta.source.subagent.thread_spawn.parent_thread_id points to the parent thread
  • agent_role=odoo-architect
  • agent_nickname=Lovelace
  • the child rollout continued receiving normal user messages for several hours after the architecture review completed
  • state_5.sqlite.thread_spawn_edges still had the parent -> child row with status=open
  • threads table showed the child unarchived and recently updated

The concrete result was that user messages like "where are we now?" and later implementation/smoke-test instructions were recorded in the child subagent thread, not the parent.

Related issues

This appears related to, but not identical to:

  • #17487: resume/replay can surface stale assistant final message from subagent history
  • #13119: TUI state not persisting correctly across subagent thread switching
  • #16226: hook events lack subagent/main-session discriminator

View original on GitHub ↗

5 Comments

jif-oai contributor · 4 months ago

Hi,

I'm not sure to understand your repro here. Are you switching agent at any time through /agent? If not, how do you even see the sub-agent?

atelierdesdonnees · 4 months ago

It's hard to explain: at one point I'm taking with my codex assistant, and at a later point it does what only a subagent is supposed to be doing, so I call it out. It then answers that it is the subagent. Indeed, it has no memory of the conversation with the original codex session. Very confusing.

jif-oai contributor · 4 months ago

Can you share a session or a recording with me? If a recording, you can send it to jif@openai.com

atelierdesdonnees · 4 months ago

I sent you an email with the material, tell me if you need more...

jif-oai contributor · 4 months ago

After deep inspection this seems like a bad UX. There is no evidence of a bug in the core code. We will make sure the UX gets clearer