Description
Bug: opencode run and TUI both crash with "Unexpected server error" on every prompt — SystemPrompt.environment throws TypeError: undefined is not an object (evaluating 'a.name')
Summary
Every single prompt attempt fails immediately with a generic UnknownError / "Unexpected server error" wrapper. The actual underlying crash (visible in the debug log) happens inside SystemPrompt.environment, before any request reaches the model provider. This reproduces on a completely clean $HOME and working directory, across multiple models, and in both run and the interactive TUI — so it is not caused by user config, agents, skills, or project files.
Environment
- OpenCode version: 1.18.30
- OS: Linux (Ubuntu-based, conda env)
- Providers tested: OpenCode Zen —
mimo-v2.5-free, big-pickle
- Auth: fresh login via
opencode auth login, valid key confirmed in auth.json
Error shown to user
Error: {
"name": "UnknownError",
"data": {
"message": "Unexpected server error. Check server logs for details.",
"ref": "err_<unique>"
}
}
Actual error from debug log
TypeError: undefined is not an object (evaluating 'a.name')
at resolve (/$bunfs/root/chunk-13bwg24f.js:2:1659)
at a (/$bunfs/root/chunk-13bwg24f.js:2:936)
at map (native:1:11)
at <anonymous> (/$bunfs/root/chunk-13bwg24f.js:2:1626)
at a (/$bunfs/root/chunk-13bwg24f.js:2:1166)
at map (native:1:11)
at <anonymous> (/$bunfs/root/chunk-13bwg24f.js:2:1626)
at a (/$bunfs/root/chunk-13bwg24f.js:2:1166)
at map (native:1:11)
at <anonymous> (/$bunfs/root/chunk-13bwg24f.js:2:1390)
at SystemPrompt.environment (/$bunfs/root/chunk-f0kkasg7.js:50:13096)
at SystemPrompt.environment (definition) (/$bunfs/root/chunk-f0kkasg7.js:4:14254)
at SessionPrompt.run (/$bunfs/root/chunk-f0kkasg7.js:50:14576)
at SessionPrompt.run (definition) (/$bunfs/root/chunk-f0kkasg7.js:50:10099)
at SessionRunState.ensureRunning (/$bunfs/root/chunk-f0kkasg7.js:50:14545)
at SessionRunState.ensureRunning (definition) (/$bunfs/root/chunk-f0kkasg7.js:2:6720)
at SessionPrompt.loop (/$bunfs/root/chunk-f0kkasg7.js:50:9849)
at SessionPrompt.loop (definition) (/$bunfs/root/chunk-f0kkasg7.js:50:14481)
at SessionPrompt.prompt (/$bunfs/root/chunk-tdg6vc0f.js:6:11695)
at SessionPrompt.prompt (definition) (/$bunfs/root/chunk-f0kkasg7.js:50:9462)
The crash occurs on a nested .map() chain (three levels deep) inside SystemPrompt.environment, consuming an entry that is missing a .name field.
Steps to reproduce
opencode --pure run --model opencode/big-pickle "Reply with exactly: OK"
Fails every time, with a new ref each run, identical stack trace.
Isolation steps already performed (all still reproduce the crash)
- Removed all custom
opencode.json / opencode.jsonc files (previously contained a stale llama.cpp local provider — removing this did NOT fix it).
- Removed
AGENT.md / custom instructions from ~/.config/opencode/.
- Ran with
OPENCODE_DISABLE_EXTERNAL_SKILLS=1 — no change.
- Ran with a completely empty
$HOME:
HOME=/tmp/opencode-clean-home opencode --pure run --model opencode/big-pickle "Reply with exactly: OK"
— still crashes identically.
- Ran with both a clean
$HOME and a clean working directory (no git repo, no .opencode/, no project files):
mkdir -p /tmp/opencode-clean-home /tmp/opencode-clean-cwd
cd /tmp/opencode-clean-cwd
HOME=/tmp/opencode-clean-home opencode --pure run --model opencode/big-pickle "Reply with exactly: OK"
— still crashes identically.
- Tested in the interactive TUI (not just
run) — same "Failed to send prompt / Unexpected server error" message.
- Tested two different models (
mimo-v2.5-free, big-pickle) — same crash both times.
- Confirmed via raw
curl that the API/auth layer itself is reachable and functioning (separate MissingSessionID response confirmed for direct curl without a client-managed session, as expected) — so this is not an auth or network issue.
Expected behavior
opencode run "<prompt>" should successfully build the system prompt and return a model response, as it presumably does for most users on this version.
Suspected root cause
Per the public source (packages/opencode/src/session/system.ts, SystemPrompt.environment), this function assembles environment context including skill, reference, and MCP guidance. Since the crash reproduces with zero project files, zero custom skills, zero custom agents, and a totally empty $HOME, the malformed entry causing the missing .name is most likely coming from a built-in/bundled list (e.g. default skills, default MCP guidance, or default project-reference handling) rather than anything user-supplied.
Additional log context
A second, unrelated error also appears in the same run for the background session-title generation step (uses gpt-5.4-nano), reporting "No payment method" — this is a separate, expected billing-related issue on a sub-feature and not connected to the main crash, included here only for completeness:
error.error="AI_APICallError: No payment method. Add a payment method here: https://opencode.ai/workspace/.../billing"
Impact
This makes opencode completely unusable for any prompt, on any model, from any directory, on this version — a 100% reproduction rate, not an edge case.
Plugins
No response
OpenCode version
1.18.30
Steps to reproduce
No response
Screenshot and/or share link
Operating System
Ubuntu 26
Terminal
Terminal
Description
Bug:
opencode runand TUI both crash with "Unexpected server error" on every prompt —SystemPrompt.environmentthrowsTypeError: undefined is not an object (evaluating 'a.name')Summary
Every single prompt attempt fails immediately with a generic
UnknownError/ "Unexpected server error" wrapper. The actual underlying crash (visible in the debug log) happens insideSystemPrompt.environment, before any request reaches the model provider. This reproduces on a completely clean$HOMEand working directory, across multiple models, and in bothrunand the interactive TUI — so it is not caused by user config, agents, skills, or project files.Environment
mimo-v2.5-free,big-pickleopencode auth login, valid key confirmed inauth.jsonError shown to user
Actual error from debug log
The crash occurs on a nested
.map()chain (three levels deep) insideSystemPrompt.environment, consuming an entry that is missing a.namefield.Steps to reproduce
opencode --pure run --model opencode/big-pickle "Reply with exactly: OK"Fails every time, with a new
refeach run, identical stack trace.Isolation steps already performed (all still reproduce the crash)
opencode.json/opencode.jsoncfiles (previously contained a stalellama.cpplocal provider — removing this did NOT fix it).AGENT.md/ custom instructions from~/.config/opencode/.OPENCODE_DISABLE_EXTERNAL_SKILLS=1— no change.$HOME:HOME=/tmp/opencode-clean-home opencode --pure run --model opencode/big-pickle "Reply with exactly: OK"$HOMEand a clean working directory (no git repo, no.opencode/, no project files):run) — same "Failed to send prompt / Unexpected server error" message.mimo-v2.5-free,big-pickle) — same crash both times.curlthat the API/auth layer itself is reachable and functioning (separateMissingSessionIDresponse confirmed for direct curl without a client-managed session, as expected) — so this is not an auth or network issue.Expected behavior
opencode run "<prompt>"should successfully build the system prompt and return a model response, as it presumably does for most users on this version.Suspected root cause
Per the public source (
packages/opencode/src/session/system.ts,SystemPrompt.environment), this function assembles environment context including skill, reference, and MCP guidance. Since the crash reproduces with zero project files, zero custom skills, zero custom agents, and a totally empty$HOME, the malformed entry causing the missing.nameis most likely coming from a built-in/bundled list (e.g. default skills, default MCP guidance, or default project-reference handling) rather than anything user-supplied.Additional log context
A second, unrelated error also appears in the same run for the background session-title generation step (uses
gpt-5.4-nano), reporting "No payment method" — this is a separate, expected billing-related issue on a sub-feature and not connected to the main crash, included here only for completeness:Impact
This makes
opencodecompletely unusable for any prompt, on any model, from any directory, on this version — a 100% reproduction rate, not an edge case.Plugins
No response
OpenCode version
1.18.30
Steps to reproduce
No response
Screenshot and/or share link
Operating System
Ubuntu 26
Terminal
Terminal