Skip to content

[Bug] TUI worker terminated when clicking subagent task during parallel multi-task execution #27434

@magicJie

Description

@magicJie

[Bug] TUI worker terminated when clicking subagent task during parallel multi-task execution

Description

When using oh-my-openagent plugin with parallel multi-task execution, clicking on a subagent task to view its details causes the TUI to display "Worker is terminated" and all running parallel subagent tasks are aborted simultaneously.

This appears to be a TUI worker lifecycle management issue when handling concurrent subagent sessions. The error message "Worker has been terminated" is found in the opencode binary itself (confirmed via strings analysis), indicating an internal worker thread crash/termination.

Key Evidence from Logs

At timestamp 2026-05-14T01:37:05, when clicking a subagent task, the following cascade occurs:

  1. LSP client initialization fails (likely a side effect of worker disruption):
ERROR service=lsp.client serverID=remark-language-server error=Cannot call write after a stream was destroyed initialize error
ERROR service=lsp error=LSPInitializeError Caused by: Cannot call write after a stream was destroyed Failed to initialize LSP client remark-language-server
  1. All 5 parallel subagent sessions are simultaneously cancelled:
INFO  service=session.prompt session.id=ses_1dbdece80ffeOH4FokfxNd0B7V logSpan.http.span.247=0ms cancel
INFO  service=session.prompt session.id=ses_1dbdec707ffe1mykGQLg1rhL5T logSpan.http.span.248=1ms cancel
INFO  service=session.prompt session.id=ses_1dbdec018ffe9FBz0wyPKuHuEJ logSpan.http.span.249=0ms cancel
INFO  service=session.prompt session.id=ses_1dbdeb8e3ffeCqOd6a8ofQP2Ni logSpan.http.span.250=1ms cancel
INFO  service=session.prompt session.id=ses_1dbdeb11bffed4f1JYrbejeP14 logSpan.http.span.251=0ms cancel
  1. Multiple "Aborted process" errors on one of the subagent sessions:
ERROR service=session.processor session.id=ses_1dbdece80ffeOH4FokfxNd0B7V messageID=msg_e242154ea001HbPOoPdt0NmmLO error=Aborted process
ERROR service=session.processor session.id=ses_1dbdece80ffeOH4FokfxNd0B7V messageID=msg_e242154ea001HbPOoPdt0NmmLO error=Aborted process
ERROR service=session.processor session.id=ses_1dbdece80ffeOH4FokfxNd0B7V messageID=msg_e242154ea001HbPOoPdt0NmmLO error=Aborted process
ERROR service=session.processor session.id=ses_1dbdece80ffeOH4FokfxNd0B7V messageID=msg_e242154ea001HbPOoPdt0NmmLO error=Aborted process
ERROR service=session.processor session.id=ses_1dbdece80ffeOH4FokfxNd0B7V messageID=msg_e242154ea001HbPOoPdt0NmmLO error=Aborted process
  1. Sessions receive abort requests:
INFO  service=default http.method=POST http.url=/session/ses_1dbdece80ffeOH4FokfxNd0B7V/abort http.status=200
INFO  service=default http.method=POST http.url=/session/ses_1dbdec707ffe1mykGQLg1rhL5T/abort http.status=200
INFO  service=default http.method=POST http.url=/session/ses_1dbdec018ffe9FBz0wyPKuHuEJ/abort http.status=200

Root Cause Hypothesis

Based on log analysis and related issues, the problem appears to be in the TUI worker thread management (/$bunfs/root/src/cli/cmd/tui/worker.js):

  1. When navigating to a subagent session view, the TUI attempts to load that session's content in a worker thread
  2. During parallel multi-task execution, this worker creation/switch triggers a race condition or resource conflict
  3. The worker is unexpectedly terminated, causing a cascade that aborts all related subagent sessions
  4. Cleanup code is skipped when validateSession throws (as noted in terminal stuck after passing non-existent session ID to opencode -s #23981)

Steps to Reproduce

  1. Start opencode TUI with oh-my-openagent plugin installed
  2. Initiate a task that spawns multiple subagents in parallel (e.g., using task() with run_in_background=true or concurrent delegate_task calls)
  3. Wait for 3-5 subagents to be running simultaneously
  4. Click on one of the running subagent tasks in the TUI to view its session details
  5. Observe that:
    • TUI shows "Worker is terminated" error
    • All parallel subagent tasks are aborted
    • Main session may also become unresponsive

Expected Behavior

  • Clicking a subagent task should navigate to that session's view without affecting other running tasks
  • Parallel subagent tasks should continue running independently
  • Worker threads should handle session navigation gracefully without termination

Actual Behavior

  • TUI displays "Worker is terminated" error
  • All parallel subagent sessions are simultaneously cancelled and aborted
  • Work in progress is lost
  • User must restart the main task

Related Issues

Environment

  • OpenCode version: 1.14.49
  • Plugin: oh-my-openagent (latest)
  • OS: Linux (Ubuntu 24.04 / Debian-based)
  • Terminal: GNOME Terminal / Tilix
  • Shell: bash
  • Installation: npm via nvm (Node.js v24.12.0)

Additional Context

Binary Analysis

The error message "Worker has been terminated" is present in the opencode binary:

$ strings /path/to/opencode-ai/bin/.opencode | grep "Worker has been terminated"
Worker has been terminated

Log File

Full log available at: ~/.local/share/opencode/log/2026-05-14T013613.log

Workaround

Currently, the only workaround is to avoid clicking on subagent tasks while parallel tasks are running. Users must wait for all parallel tasks to complete before viewing individual subagent results, or check progress via background_output tool instead of the TUI.

Impact

This bug makes parallel multi-agent workflows unreliable in the TUI, forcing users to either:

  • Use sequential task execution (slower)
  • Avoid viewing task details during execution (poor UX)
  • Risk losing all in-flight work if accidentally clicking a task

Labels suggestion: bug, tui, worker, subagent, parallel-execution

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions