Skip to content

OpenCode Desktop - Subagent spawning via client.session.prompt() fails with "JSON Parse error: Unexpected EOF" #12571

@13640535881

Description

@13640535881

Description

Original Report
Source: code-yeongyu/oh-my-openagent#1527

Triage Conclusion by @code-yeongyu (oh-my-opencode author):

This is an OpenCode Desktop app issue, NOT an oh-my-opencode plugin issue.

Bug Description
When plugins attempt to spawn subagents through client.session.prompt(), OpenCode Desktop throws JSON Parse error: Unexpected EOF from within the SDK call. This affects all subagent types and prevents core plugin functionality from working.

Error:

JSON Parse error: Unexpected EOF
at (:0)
at parse (unknown)
at processTicksAndRejections (native:7:39)
Steps to Reproduce
Install oh-my-opencode plugin (v3.2.3+) on OpenCode Desktop
Configure any subagent (e.g., Momus):
{
"agents": {
"momus": {
"model": "openai/gpt-5.2",
"variant": "medium"
}
}
}
Invoke the subagent through plugin's delegate_task function
Error occurs immediately when client.session.prompt() is called
Expected Behavior
Subagent processes should spawn successfully and execute tasks, as they do in OpenCode CLI version.

Actual Behavior
The call to client.session.prompt() throws JSON Parse error: Unexpected EOF. The plugin correctly catches and handles this error, but the root cause is in OpenCode Desktop's internal response parsing.

Key Evidence from Plugin Code Review:

Plugin code does NOT use JSON.parse() - it directly accesses properties from client.session.messages()
Error is thrown INSIDE OpenCode SDK's client.session.prompt() call
Plugin has test coverage for this error (src/tools/delegate-task/tools.test.ts:1112)
Environment Information
Affected Versions:

OpenCode Desktop: 1.1.51 (and likely other Desktop versions)
OpenCode CLI: NOT affected (works fine per user reports)
oh-my-opencode: 3.2.3
Operating Systems:

macOS (confirmed)
Windows 11 (likely affected)
Doctor Output:

Installation
✓ OpenCode Installation → 1.1.51
✓ Plugin Registration → Registered (pinned: latest)

Configuration
✓ Configuration Validity → Valid JSON config
✓ Model Resolution → 10 agents, 8 categories (18 overrides), 2433 available

All systems operational with warnings.
Root Cause Analysis
Evidence Points:

Desktop vs CLI Difference: Multiple users report OpenCode CLI works fine - only Desktop throws this error
All Subagents Affected: Not specific to any agent - ANY subagent spawned via delegate_task fails on Desktop
Error Location: The error is thrown by OpenCode Desktop's internal SDK when parsing the response from client.session.prompt(), NOT in plugin code
Plugin Error Handling: The plugin correctly catches and handles this error, but cannot prevent it from occurring in OpenCode's SDK
Test Coverage Exists: Plugin has comprehensive tests for this scenario
Related Issues
In oh-my-opencode:

#1527 - Momus agent JSON Parse error (macOS, Desktop 1.1.51)
#683 - Librarian agent JSON Parse error (closed, same root cause)
In OpenCode:

#9950 - "[Desktop] - Error when attempting to launch multiple subagents"
#6573 - "Sessions hang indefinitely when Task tool spawns subagents"
Impact
Severity: High

Affected Functionality:

All subagent-based features in plugins
Multi-agent workflows
Background task execution
Parallel agent delegation
User Impact: All Desktop users using oh-my-opencode (29K+ GitHub stars)

Workaround
Use OpenCode CLI instead of Desktop until this bug is fixed.

Suggested Investigation Points
Desktop vs CLI IPC: What's different about subprocess communication between Desktop and CLI?
Response Parsing: Why does Desktop's client.session.prompt() receive malformed/empty responses?
Subprocess Lifecycle: Is the subagent process failing to start or communicate back?

Plugins

oh-my-opencode@3.2.3

OpenCode version

1.1.51/1.1.53

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

windows10/windows11/macOS

Terminal

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingwebRelates to opencode on web / desktop

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