You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: Kimi/Moonshot provider crashes with 'undefined is not an object (evaluating $.annotations)' since v1.14.23 #26156
Since v1.14.23, using Kimi/Moonshot AI models (via moonshotai-cn provider, OpenAI-compatible protocol) causes all sessions to immediately crash with:
undefined is not an object (evaluating '$.annotations')
Followed by:
JSON Parse error: Unexpected EOF
Versions (binary search confirmed)
1.14.22 ✅ works
1.14.23 ❌ broken (first broken version)
1.14.24 ~ 1.14.40 ❌ all broken
Root Cause Analysis
Bisected the commits between v1.14.22 and v1.14.23. The AI SDK version is unchanged ([email protected]) between both releases — the regression is in OpenCode's own code.
The most likely cause is PR #24005 (refactor(session): migrate session domain to Effect Schema), which migrated session/message schemas from zod to Effect Schema. Effect Schema's deserialization is stricter than zod — when Kimi/Moonshot's streaming response is missing a field (minified as $.annotations), zod silently ignores it but Effect Schema throws a TypeError.
Other PRs merged between v1.14.22 and v1.14.23 that touch related code:
The $.annotations is a minified variable name in the compiled binary, so the exact source location cannot be pinpointed externally. The error occurs immediately when the first streaming chunk arrives from the provider.
Reproduction
Configure moonshotai-cn provider with a valid Moonshot API key
Reproducing the same class of bug on OpenAI direct provider with openai/gpt-5.5 in OpenCode v1.14.48 (headless opencode run mode under the aidevops framework). Variable name in the TypeError is different (J.type vs $.annotations) because the minified binary names differ per build, but the failure shape and timing are identical to this issue, supporting the Effect Schema migration root-cause hypothesis in #24005.
Error
ERROR service=llm providerID=openai modelID=gpt-5.5 session.id=ses_1e717b7f0ffeH5ltHMkwPumHPg
small=false agent=Build+ mode=primary error={"error":{}} stream error
ERROR service=session.processor session.id=ses_1e717b7f0ffeH5ltHMkwPumHPg
messageID=msg_e18e8ab0200110H3hpwjgZIy25
error=undefined is not an object (evaluating 'J.type')
stack=TypeError: undefined is not an object (evaluating 'J.type')
at fetch (/$bunfs/root/chunk-n2wbvcp2.js:488:2526)
at processTicksAndRejections (native:7:39)
Wrapped stream error is {"error":{}} (empty inner) — same empty-Error wrapping pattern as #26129 / #21979.
Crash sequence (from session ndjson)
The crash fires immediately after a successful step-finish event with reason: "tool-calls":
{"type":"step_finish","timestamp":1778534361830,"sessionID":"ses_1e717b7f0ffeH5ltHMkwPumHPg",
"part":{"reason":"tool-calls","type":"step-finish",
"tokens":{"total":29538,"input":755,"output":111,"reasoning":0,
"cache":{"write":0,"read":28672}}}}
{"type":"error","timestamp":1778534362048,"sessionID":"ses_1e717b7f0ffeH5ltHMkwPumHPg",
"error":{"name":"UnknownError",
"data":{"message":"undefined is not an object (evaluating 'J.type')"}}}
218 ms between events — consistent with the next streaming part arriving from the provider and failing Effect Schema deserialization. The minified J.type access strongly suggests the schema is unwrapping a streaming part object expecting .type to discriminate the union, and receiving undefined instead (likely an empty/null streaming delta after tool_calls).
Reproduction
Headless config: OpenAI direct provider, OAuth via aidevops account pool, gpt-5.5 model, tool-calling enabled (Build+ agent with TodoWrite, Bash, Edit, etc.). Crashes after 1–5 tool-call cycles. Observed 3/4 times in the last 24h on Ultimate-Multisite/ultimate-multisite headless workers; the 4th attempt succeeded on resume via next_action: "resume_session_with_completion_contract", suggesting the malformed chunk is transient/intermittent rather than deterministic for a given prompt.
Same reasoning model class as #26107 (Free Models Thinking/Reasoning crashes) — possibly the empty/null delta corresponds to a reasoning step boundary in gpt-5.5's response stream.
Side-signal (possibly unrelated)
The sandbox boot also emits 4× schema rejections before the model crash:
This is the OAuth refresh path emitting a pending placeholder Auth object that the Effect Schema rejects. The session continues past this and only crashes later during streaming, so it may be cosmetic — but it confirms Effect Schema is now actively rejecting payloads that earlier schemas accepted.
Environment
OpenCode v1.14.48 (Linux x86_64, Bun runtime)
OpenAI direct provider (not Copilot/Zen/openai-compatible — direct OAuth)
Model: openai/gpt-5.5
Mode: opencode run (headless, non-TUI)
Agent: Build+ with tool-calling
Same model on anthropic/claude-sonnet-4-6 direct provider: 5/5 success in same window, so the bug is isolated to the OpenAI streaming chunk parser, not the harness.
Happy to provide full session ndjson, stderr captures, or run version bisection if useful.
aidevops.sh v3.15.31 plugin for OpenCode v1.14.48 with claude-opus-4-7 spent 1h 7m and 74,137 tokens on this with the user in an interactive session.
New session created → first prompt_async request → immediate crash
UI shows "UnknownError" banner; every retry creates a new session.error event
Switching model to other OpenAI/OpenRouter models (gpt-5, etc.) does not help
Confirmed by downgrading to v1.14.22: fully resolved, same config and same UI works on first try
Log excerpt
```
ERROR service=server sessionID=ses_xxxxx
error=undefined is not an object (evaluating '$.annotations') prompt_async failed
```
Stack frames identical to OP (`chunk-kprvzcvq.js:1107`, `~effect/Effect/successCont`, `runLoop`).
So the breakage is not specific to Moonshot/`@ai-sdk/openai-compatible` — the built-in `openrouter` provider hits the exact same path. Anthropic direct (Claude Sonnet 4.6) works fine, matching the earlier comment.
Happy to provide full session.error payload from `~/.local/share/opencode/log/` if useful.
Activity
LURENYUANSHI commentedon May 7, 2026
And # 23244 pr
superdav42 commentedon May 11, 2026
Reproducing the same class of bug on OpenAI direct provider with
openai/gpt-5.5in OpenCode v1.14.48 (headlessopencode runmode under the aidevops framework). Variable name in the TypeError is different (J.typevs$.annotations) because the minified binary names differ per build, but the failure shape and timing are identical to this issue, supporting the Effect Schema migration root-cause hypothesis in #24005.Error
Wrapped stream error is
{"error":{}}(empty inner) — same empty-Error wrapping pattern as #26129 / #21979.Crash sequence (from session ndjson)
The crash fires immediately after a successful
step-finishevent withreason: "tool-calls":{"type":"step_finish","timestamp":1778534361830,"sessionID":"ses_1e717b7f0ffeH5ltHMkwPumHPg", "part":{"reason":"tool-calls","type":"step-finish", "tokens":{"total":29538,"input":755,"output":111,"reasoning":0, "cache":{"write":0,"read":28672}}}} {"type":"error","timestamp":1778534362048,"sessionID":"ses_1e717b7f0ffeH5ltHMkwPumHPg", "error":{"name":"UnknownError", "data":{"message":"undefined is not an object (evaluating 'J.type')"}}}218 ms between events — consistent with the next streaming part arriving from the provider and failing Effect Schema deserialization. The minified
J.typeaccess strongly suggests the schema is unwrapping a streaming part object expecting.typeto discriminate the union, and receivingundefinedinstead (likely an empty/null streaming delta aftertool_calls).Reproduction
Headless config: OpenAI direct provider, OAuth via aidevops account pool, gpt-5.5 model, tool-calling enabled (Build+ agent with TodoWrite, Bash, Edit, etc.). Crashes after 1–5 tool-call cycles. Observed 3/4 times in the last 24h on
Ultimate-Multisite/ultimate-multisiteheadless workers; the 4th attempt succeeded on resume vianext_action: "resume_session_with_completion_contract", suggesting the malformed chunk is transient/intermittent rather than deterministic for a given prompt.Same reasoning model class as #26107 (Free Models Thinking/Reasoning crashes) — possibly the empty/null delta corresponds to a reasoning step boundary in gpt-5.5's response stream.
Side-signal (possibly unrelated)
The sandbox boot also emits 4× schema rejections before the model crash:
This is the OAuth refresh path emitting a
pendingplaceholder Auth object that the Effect Schema rejects. The session continues past this and only crashes later during streaming, so it may be cosmetic — but it confirms Effect Schema is now actively rejecting payloads that earlier schemas accepted.Environment
openai/gpt-5.5opencode run(headless, non-TUI)anthropic/claude-sonnet-4-6direct provider: 5/5 success in same window, so the bug is isolated to the OpenAI streaming chunk parser, not the harness.Happy to provide full session ndjson, stderr captures, or run version bisection if useful.
aidevops.sh v3.15.31 plugin for OpenCode v1.14.48 with claude-opus-4-7 spent 1h 7m and 74,137 tokens on this with the user in an interactive session.
alex-pathcourse commentedon May 12, 2026
hjhxtt commentedon May 13, 2026
Confirming this also affects OpenRouter + GPT-5.5 Pro on macOS
Same crash on a fresh session, immediately after first message.
Environment
v1.14.28npm i -g opencode-aiopenrouter(built-in)openrouter/openai/gpt-5.5-prochrome-devtools,memory,pencilBehavior
prompt_asyncrequest → immediate crashsession.erroreventv1.14.22: fully resolved, same config and same UI works on first tryLog excerpt
```
ERROR service=server sessionID=ses_xxxxx
error=undefined is not an object (evaluating '$.annotations') prompt_async failed
```
Stack frames identical to OP (`chunk-kprvzcvq.js:1107`, `~effect/Effect/successCont`, `runLoop`).
So the breakage is not specific to Moonshot/`@ai-sdk/openai-compatible` — the built-in `openrouter` provider hits the exact same path. Anthropic direct (Claude Sonnet 4.6) works fine, matching the earlier comment.
Happy to provide full session.error payload from `~/.local/share/opencode/log/` if useful.
github-actions commentedon Jul 13, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.