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
Cancelling agent mid-response bricks session with "content field is empty" error #16220
When an agent is cancelled while generating a response, OpenCode persists the assistant message with an empty text content block ("text": ""). On the next message in that session, this empty block is replayed to the model API which rejects it, permanently bricking the session.
Root cause (from manual DB inspection): The part table contains a row with {"type":"text","text":"","time":{"start":...}} belonging to a MessageAbortedError assistant message. This empty text block is sent as-is to the model API when the session history is replayed.
Workaround: Manually update the SQLite database at ~/.local/share/opencode/opencode.db:
-- Find the broken part
SELECT p.id, p.data
FROM part p
JOIN message m ON m.id = p.message_id
WHERE m.session_id = '<your-session-id>'
AND json_extract(p.data, '$.type') = 'text'
AND json_extract(p.data, '$.text') = '';
-- Fix it
UPDATE part SET data = json_set(data, '$.text', '[aborted]')
WHERE id = '<part-id>';
Plugins
No response
OpenCode version
1.2.16
Steps to reproduce
Start a session and prompt the agent with a task that involves tool use / a todo list
While the agent is actively generating a response, cancel it
Send any new message in the same session
Expected behavior: OpenCode should either:
Strip or not persist empty content blocks from aborted messages, or
Filter out empty content blocks when replaying session history to the model API
Actual behavior: Every subsequent message in the session fails immediately with:
The content field in the Message object at messages.N is empty.
Add a ContentBlock object to the content field and try again.
The session becomes permanently unrecoverable from the UI. There is no way to unarchive or repair the session through the UI or CLI (opencode export also fails for archived sessions).
This issue might be a duplicate of an existing issue. Please check:
Anthropic provider: empty tool_result content crashes with 'content field is empty' API error #15371: Also reports the same content field is empty API error from the Anthropic provider, though triggered by empty tool_result content from tools rather than aborted assistant messages. The root cause and affected code paths differ, but the symptom and error message are the same — worth reviewing to see if a unified fix covers both cases.
Activity
github-actions commentedon Mar 5, 2026
This issue might be a duplicate of an existing issue. Please check:
content field is emptyAPI error from the Anthropic provider, though triggered by emptytool_resultcontent from tools rather than aborted assistant messages. The root cause and affected code paths differ, but the symptom and error message are the same — worth reviewing to see if a unified fix covers both cases.ddemarteleire commentedon Mar 6, 2026
Duplicate of #15371