anomalyco / anomalyco/opencode
tui: agent keeps running while user is trapped in false location-unavailable modal
@simonklee is already working on this.
Since Aug 19, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Summary
An OpenCode agent invoked opencode2 service restart from its shell tool twice without user permission while an active TUI session and background code-review subagent were running. The user did not request or execute either restart.
The first restart completed and the agent continued working. The agent then invoked a second restart. After that second service replacement, the user's TUI controls were replaced with a non-dismissible session location unavailable, choose another directory to continue dialog, although the session directory and worktree still existed.
The agent and server continued executing tool calls after the second restart, but the user could not message or otherwise control the agent. Their only effective action was interrupting subagents. The agent did not issue another restart while the user was blocked. The original background reviewer was subsequently reported as Subagent cancelled. While the user remained blocked, the agent launched a replacement foreground reviewer; the user interrupted that replacement to stop the continuing work. The user then had to close the terminal to recover.
This report separates three facts:
- Trigger: the OpenCode agent autonomously issued two service-restart commands without user permission.
- Critical control failure after the second restart: agent execution continued while the user's control surface was blocked; interrupting subagents was the user's only available control.
- Recovery failure: the second service replacement left the TUI in a false, non-dismissible location-recovery modal.
Environment
- OpenCode:
opencode2 v0.0.0-beta-17639 - OS: Windows
10.0.26200.9168 - Terminal: Windows Terminal (
WT_SESSIONpresent),TERM=xterm-256color - Shell: PowerShell 7.6.5
- Install/channel: V2 beta, shared managed background service
- Active plugins: none configured in
~/.config/opencode/opencode.json*; no local plugin directories present - Session start directory:
C:\Users\temaz\opencode - Active worktree:
C:\Users\temaz\opencode\harmonica-web-app-pro-har-1559
Evidence and timeline
The conversation transcript shows that a background code-review subagent was active before MCP configuration work began. The assistant issued both restart commands as shell tool calls; there was no user restart request.
First agent-issued restart
2026-08-19T11:29:49.529Z role=server message="spawning process"
command="C:\Program Files\PowerShell\7\pwsh.EXE"
args=[..., "opencode2 service restart; opencode2 mcp list"]
cwd="C:\Users\temaz\opencode"
2026-08-19T11:29:51.693Z role=cli args=["service","restart"]
2026-08-19T11:29:52.232Z role=cli args=["serve","--service"]
The agent continued working after this first restart. At this point the user was not yet blocked by the dialog.
Second agent-issued restart
2026-08-19T11:31:08.892Z role=server message="spawning process"
command="C:\Program Files\PowerShell\7\pwsh.EXE"
args=[..., "opencode2 service restart"]
cwd="C:\Users\temaz\opencode"
2026-08-19T11:31:10.204Z role=cli args=["service","restart"]
2026-08-19T11:31:10.640Z role=cli args=["serve","--service"]
The location-unavailable dialog and loss of user control occurred after this second restart.
The replacement server continued executing the agent's tool calls while the user's TUI was blocked. Examples include:
2026-08-19T11:31:29.358Z role=server command="opencode2 mcp list"
2026-08-19T11:31:56.556Z role=server command="git fetch origin master; git merge --ff-only origin/master"
2026-08-19T11:32:17.637Z role=server command="git add docs/mcp-servers.md; ...; git push origin master"
No third restart was issued during the blocked period. When the agent later tried to reconcile the original reviewer, OpenCode returned Subagent cancelled. The agent then launched a replacement foreground reviewer while the user remained blocked; the user interrupted that replacement, which also returned Subagent cancelled. Two reviewers were therefore interrupted, but only the original was active across the restart.
The user clarified that agent work continued after the second restart, but the TUI dialog prevented them from sending any message or using normal controls. Their only available intervention was interrupting subagents. Closing and reopening the terminal eventually restored access.
After recovery, the same worktree was still present and the replacement service was healthy:
Test-Path C:\Users\temaz\opencode\harmonica-web-app-pro-har-1559
True
opencode2 api get /api/health
{"healthy":true,"version":"0.0.0-beta-17639","pid":23872}
Reproduction
- Open a TUI session in a valid workspace.
- Start a background subagent.
- Have the agent invoke
opencode2 service restartthrough a shell tool while work is active. - Repeat the restart after the first service replacement has reconnected.
- Observe whether server-side session execution resumes while the user-facing TUI instead enters the location-unavailable modal.
Expected behavior
- OpenCode should require explicit user approval before an agent can restart the service that owns its session and subagents.
- Agent execution must not continue when the user's control surface has failed to reconnect or is blocked by a recovery modal.
- If a restart occurs, the TUI should reconnect to the existing valid location before session execution resumes.
- If location recovery fails, the dialog should be dismissible and expose a reliable stop/cancel control.
- Active subagent interruption should be explicit and recoverable rather than silently surfaced later as cancellation.
Actual behavior
- The agent was permitted to restart its own service twice without user approval.
- After the second restart, agent execution continued while the user-facing TUI was blocked.
- The agent did not issue another restart during the blocked period.
- The user could not send a message or access normal controls.
- Interrupting subagents was the user's only effective intervention.
- The original code-review subagent was subsequently reported as cancelled.
- The agent launched a replacement reviewer while the user remained blocked; the user interrupted it to stop the continuing work.
- The TUI displayed a false
session location unavailablediagnosis. - The only dialog action was Choose folder; the dialog could not be dismissed.
- The valid directory could not be recovered through the modal.
- The user had to interrupt agents and close/reopen the terminal.
- Relaunching restored the same session and directory.
Impact
After the second service restart, OpenCode entered an unsafe split-brain state: autonomous agent execution continued while the user had lost the ability to observe, redirect, or stop it through normal session controls. The recovery UI falsely claimed the location was unavailable and offered no safe cancellation path.
Related issues
- #36585 tracks pending forms becoming unanswerable after managed-service restart.
- #36348 discusses restart semantics for foreground and background shells.
- #36185 covers active-location cache lifecycle and reconnect behavior.
This issue is narrower: unauthorized agent-issued restarts, continued execution after the second restart without a working user control surface, loss of active subagent state, false location invalidation, and the non-dismissible recovery modal.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.