Description
A turn was aborted mid-stream (the TUI had frozen after an OS suspend/resume, so I aborted). OpenCode persisted the aborted assistant message with error: MessageAbortedError and only step-start / reasoning / patch parts — no text, no tool call.
From then on, every subsequent prompt replays this message in the history as an assistant message with empty content. Moonshot (via OpenRouter) rejects the whole request:
[Moonshot AI] Invalid request: the message at position 29 with role 'assistant' must not be empty (400)
It snowballs: each failed retry persists another empty assistant message with error: APIError, so the failing position advances (29 → 30 → …) and the session is permanently unusable. I had to manually delete the artifact messages from opencode.db to recover the session.
Expected behavior: an aborted/errored assistant turn with no serializable content should either not be persisted, or be filtered out when building the model messages (the assistant-side equivalent of the guard requested in #31046 for empty text parts).
Steps to reproduce
- Session with a strict provider (openrouter / moonshotai/kimi-k3)
- Abort a turn while the model is still in reasoning, before any text or tool part is emitted
- Send any new message → 400 "must not be empty"; each retry fails the same way and appends a new empty artifact message
Environment
- OpenCode version: 1.18.3
- OS: Linux
- Plugins: oh-my-opencode
Related
Description
A turn was aborted mid-stream (the TUI had frozen after an OS suspend/resume, so I aborted). OpenCode persisted the aborted assistant message with
error: MessageAbortedErrorand onlystep-start/reasoning/patchparts — no text, no tool call.From then on, every subsequent prompt replays this message in the history as an
assistantmessage with empty content. Moonshot (via OpenRouter) rejects the whole request:It snowballs: each failed retry persists another empty assistant message with
error: APIError, so the failing position advances (29 → 30 → …) and the session is permanently unusable. I had to manually delete the artifact messages fromopencode.dbto recover the session.Expected behavior: an aborted/errored assistant turn with no serializable content should either not be persisted, or be filtered out when building the model messages (the assistant-side equivalent of the guard requested in #31046 for empty text parts).
Steps to reproduce
Environment
Related