Skip to content

shell: detached Windows process leaves parent session stuck running #43910

Closed

Description

@pascalandr

Description

On OpenCode V2 (opencode2) on Windows, a TUI session remained permanently running after a shell tool launched a long-lived GUI process with PowerShell Start-Process. The direct PowerShell process had exited, but the tool remained running, preventing the parent session from consuming completed subagent notifications and queued user input.

This was server state, not only stale TUI rendering:

GET /api/session/active
parent session: running
both child sessions: absent (idle)

parent tool state: running
tool: shell
direct pwsh process: no longer present

GET /api/session/{parent}/inbox
2 synthetic subagent completion messages
2 queued user messages

Both child sessions already contained final assistant messages with finish: stop. Sending POST /interrupt to either child correctly behaved as an idle no-op, despite the TUI presenting the child as still in progress.

The workaround was:

POST /api/session/{parent}/background

It immediately changed the outer shell tool state to completed, emptied the inbox, and allowed the parent to resume. The detached GUI process remained alive and responsive, as intended.

Plugins: opencode-ponytail, opencode-gemini-auth@latest, ponytail-v2.mjs; local integration plugins for After Effects, Blender, Microsoft 365, Resolve, and Unreal.

OpenCode version: 0.0.0-beta-17793 (build commit 4d22d4e75fb949db5a6302cc605e9af87ea671bf)

Steps to reproduce

The same failure has occurred twice. These are the exact observed steps; a controlled reproduction has not yet been run, so the frequency is currently intermittent.

  1. In a parent TUI session on Windows, start two subagents.
  2. Run a PowerShell shell tool that uses Start-Process -PassThru with redirected stdout/stderr to launch a long-lived GUI executable, then checks that the GUI is alive and listening.
  3. Allow the direct PowerShell process to exit while the detached GUI remains running.
  4. Allow both subagents to finish and submit additional user messages to the parent.
  5. Observe that both child sessions have final answers and are absent from /api/session/active, while the parent and its shell tool remain running and completion/user messages accumulate in the parent inbox.
  6. Call POST /api/session/{parent}/background; observe that the tool completes and the parent immediately consumes its inbox.

Relevant observed transition:

{
  "before": {
    "toolState": "running",
    "runningToolProcessPresent": false,
    "parentInboxItems": 4
  },
  "afterBackground": {
    "toolState": "completed",
    "toolResult": "The command was moved to the background.",
    "metadataStatus": "running",
    "parentInboxItems": 0
  }
}

Expected: once the direct shell process exits, the tool should complete or transition to background observation without retaining foreground ownership of the parent session. Completed subagents and queued input should then be consumed normally.

Actual: foreground ownership remained attached to the stale shell tool for about 27 minutes, until the explicit /background request.

Screenshot and/or share link

Unavailable: the affected session is private. API state was captured above.

Operating System

Windows 11, build 10.0.26200.9168, x64

Terminal

TUI with TERM=xterm-256color; terminal application unavailable from the environment. Shell: PowerShell 7.6.5 (ComSpec=C:\WINDOWS\system32\cmd.exe).

Activity

  1. github-actions commented on Aug 21, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If your issue is specifically about the parent session remaining stuck even after the direct shell process exits (rather than a timeout/pipe issue), it may be a distinct bug — please clarify if any of the above match your situation.

  2. pascalandr commented on Aug 21, 2026

    @pascalandr
    Author

    Thanks. #37838 matches the trigger and primary shell hang, so this is likely the same process/pipe bug persisting in V2 rather than a distinct root cause.

    This report adds V2-specific downstream behavior and recovery observed on 0.0.0-beta-17793:

    • The direct pwsh process was gone and the detached GUI remained healthy, but the outer shell tool and parent session still reported running.
    • Both child sessions had terminal assistant messages and were absent from /api/session/active.
    • The parent inbox accumulated two synthetic subagent completion messages and two queued user messages without consuming them.
    • POST /api/session/{parent}/background immediately settled the outer tool, preserved the detached GUI process, drained the inbox, and resumed the parent.

    The failure has occurred twice. Please treat this as a V2 confirmation/duplicate of #37838 if appropriate; the additional value here is the V2 inbox/subagent impact and the non-destructive /background recovery path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions