anomalyco / anomalyco/opencode

New session first prompt crashes with UnknownError (createUserMessage) when using a plugin-defined agent; built-in agents and resumed sessions work

Open
#47,158 2 comments 0 reactions 1 assignee View on GitHub

@jlongster is already working on this.

Since Sep 3, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

Creating a new session and sending the first message with a plugin-defined agent (here: orchestrator, registered by oh-my-opencode-slim) crashes with a generic UnknownError inside SessionPrompt.createUserMessage, ~0.2s after the session row is created — before any provider call. The session is created but stays at 0 messages / 0 parts.

The same agent works fine in resumed/existing sessions, and built-in agents (build, plan) work for new sessions. It fails regardless of the model (both a plugin-registered combo model and a fixed, statically-registered model like GLM-5.3), which points at the agent resolution, not the model.

This looks like the same root cause as #12860: at new-session creation createUserMessage does const agent = await Agent.get(input.agent ?? ...) and then reads agent.model; for a plugin-defined agent Agent.get(...) appears to return undefined at that point, so the property access throws and is wrapped as Die(UnknownError). The agent is selectable in the UI and streams correctly in existing sessions, so it is registered for listing/streaming but not resolvable during new-session createUserMessage.

Environment
  • OpenCode: 1.18.25 and 1.18.27 (reproduced on both; swapping the binary did not help)
  • OS: Windows 10 (10.0.19044)
  • Clients: OpenChamber (embedded CLI) and the TUI — same failure
  • Agent source: oh-my-opencode-slim defines orchestrator; provider opencode-omniroute-live is registered by the OmniRoute plugin (dynamic model/combos)
Steps to reproduce
  1. Have a plugin (e.g. oh-my-opencode-slim) register a custom agent orchestrator.
  2. Create a new session (any directory / worktree).
  3. Select agent orchestrator (model can be a combo or a fixed valid model).
  4. Send the first message.
Actual behavior

prompt_async fails almost immediately:

level=ERROR message="prompt_async failed" sessionID=ses_... cause="Cause([Die(UnknownError: UnknownError)])"

Stack (UI): SessionPrompt.createUserMessageSessionPrompt.prompt. DB shows the session row with 0 messages and 0 parts.

Works (for contrast)
  • New session with built-in build / plan agent.
  • Resumed/existing session using orchestrator (streams normally, modelID=orchestrator in logs).
  • New session with orchestrator + explicit valid model → still fails (agent, not model).
Expected behavior

A new session with a plugin-defined agent should resolve the agent and prompt normally, or return a typed error (e.g. AgentNotFoundError) instead of a swallowed UnknownError.

Related
  • #12860 (same createUserMessage stack, agent.model on undefined)
  • #40998 (POST /session/{id}/message crashes with UnknownError when agent is in the body)
  • #20250 (prompt_async UnknownError race)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.