anomalyco / anomalyco/opencode
New session first prompt crashes with UnknownError (createUserMessage) when using a plugin-defined agent; built-in agents and resumed sessions work
@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-slimdefinesorchestrator; provideropencode-omniroute-liveis registered by the OmniRoute plugin (dynamic model/combos)
Steps to reproduce
- Have a plugin (e.g. oh-my-opencode-slim) register a custom agent
orchestrator. - Create a new session (any directory / worktree).
- Select agent
orchestrator(model can be a combo or a fixed valid model). - 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.createUserMessage → SessionPrompt.prompt. DB shows the session row with 0 messages and 0 parts.
Works (for contrast)
- New session with built-in
build/planagent. - Resumed/existing session using
orchestrator(streams normally,modelID=orchestratorin 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
createUserMessagestack,agent.modelon undefined) - #40998 (
POST /session/{id}/messagecrashes with UnknownError whenagentis in the body) - #20250 (
prompt_asyncUnknownError race)
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.