Skip to content

opencode-session-corruption #38436

Description

@samuel-pro-ai

Description

A long-running session (~950 events, ~74 messages) with the build agent on deepseek-v4-pro suddenly entered a state where new messages are saved to the database but the AI response is never triggered. The input clears as normal, no error is shown, but no assistant message is ever created. Other sessions in the same OpenCode instance work fine.

The event stream shows a pattern of abort cycles before the session went silent:

message.updated.1        (user message created)
message.part.updated.1   (user text saved)
session.updated.1
message.updated.1        (assistant message created)
message.part.updated.1   (assistant step-start/reasoning)
message.updated.1        (assistant completed with MessageAbortedError)
session.updated.1
message.removed.1        (user message removed)
message.removed.1        (assistant message removed)
session.updated.1

After several such cycles, the session transitioned to a "write-only" state where user messages still create events, but no assistant message is ever created — not even an aborted one.

What did NOT fix it:

  • Manually deleting orphan user messages/parts/events from the DB
  • Updating event_sequence
  • Changing the session's model field
  • Closing and reopening OpenCode

What worked (both confirm it's client-side state, not data corruption):

  1. opencode --session <id> --fork — the forked session works normally
  2. Exporting all sessions from Linux and re-importing on Windows — the serialization/deserialization round-trip flushed the bad state

Plugins

none

OpenCode version

1.18.4

Steps to reproduce

Not reliably reproducible, but the progression appears to be:

  1. Run a long session with the build agent
  2. Have message abort/remove cycles occur (possibly from rapid message sending or provider interruptions)
  3. Continue sending messages — the session may enter the write-only state after several cycles

Screenshot and/or share link

No response

Operating System

Windows 11 (build 26200), Git Bash terminal

Terminal

Git Bash (MINGW64_NT-10.0-26200) inside Cursor IDE integrated terminal

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions