anomalyco / anomalyco/opencode

opencode-session-corruption

Open
#38,436 1 comment 0 reactions 1 assignee View on GitHub

@kitlangton is already working on this.

Since Jul 23, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
Avg merge
7h 2m
Merged PRs (30d)
384

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.