CLI agent defaults to detached launch (nohup/setsid) and does not reliably preserve foreground preference

Open 💬 2 comments Opened Feb 28, 2026 by ptflp

What version of Codex CLI is running?

0.106.0

What subscription do you have?

ChatGPT PRO plan

Which model were you using?

gpt-5.3-codex xhigh

What platform is your computer?

Linux x86_64 (Arch Linux)

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

Custom PTY-based terminal inside a desktop app (also reproduced from normal terminal sessions)

What issue are you seeing?

The agent often defaults to detached/background launch patterns (nohup, setsid, shell detach) even when foreground would be the reasonable default.

This happens without explicit user request for background execution.

When corrected ("run in foreground"), the agent may comply once, but later in the same session it can revert back to nohup/setsid behavior.

Observed impact:

  • process ownership/visibility becomes unclear
  • stale background processes accumulate
  • user intent is violated unless constantly re-stated

This is reproducible across Linux and macOS.

Hypothesis: the model appears to assume foreground process execution will block its ability to continue working. In our tool setup, foreground PTY sessions are non-blocking for the agent, so this assumption causes unnecessary detached launches.

What steps can reproduce the bug?

  1. Start Codex CLI in an interactive session.
  2. Ask the agent to run an app/process (without asking for background mode).
  3. Observe generated shell command: detached patterns are often chosen by default (nohup/setsid/& + redirection).
  4. Correct it by explicitly asking for foreground.
  5. Later in the same session, ask to run another process; behavior can regress to detached launch again.

In short: detached execution is treated as default, and foreground preference is not reliably retained.

What is the expected behavior?

Foreground should be the default for process execution unless the user explicitly asks for background mode.

If the user states a foreground preference, that preference should persist for the session (or until changed), rather than being forgotten.

If background fallback is considered, the agent should ask for confirmation first and explain why.

Additional information

This looks like an agent planning/policy issue (default heuristics + preference retention), not a shell capability limitation.

Request:

  • prefer foreground by default
  • treat explicit foreground preference as sticky session intent
  • avoid nohup/setsid unless explicitly requested
  • ask before detaching when ambiguous

Please improve model/tool usage so it understands that foreground processes do not necessarily block further agent actions in session-based PTY environments.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗