Description
When a text file in the OpenCode workspace keeps growing while a session is running (in my case an MCP server continuously appending its full API request/response log into the workspace — two log files reached 292 MB and 407 MB), OpenCode tracks the change and embeds the file's diff into message.summary.diffs on user messages.
This is compounded by the event store: every message.updated event re-serializes the entire message payload — including the huge embedded diff — as a new row in the event table. The same message is updated hundreds of times during a session, so the same multi-hundred-MB payload is written over and over.
Results:
opencode.db grew to 32.9 GB (event table alone: 29.4 GB)
- OpenCode eventually crashed with OOM
- Resuming the session crashes again with OOM, so the problematic session is permanently unopenable
Analysis
Measured on the 32.9 GB database:
| table |
size |
event |
29,407 MB |
message |
1,121 MB |
part |
510 MB |
| WAL |
771 MB |
event holds 513k rows; 97.6% were written within ~8 hours.
- Largest single
event row: 362 MB (message.updated.1). Payload begins:
{"sessionID":"ses_A","info":{...,"role":"user","summary":{"diffs":[{"file":"/logs/api_20260820.jsonl","patch":"Index: ...
— the full unified diff of the 407 MB log file is embedded in the message.
- 717 events exceed 1 MB (25.5 GB total); 135 events exceed 10 MB.
- Session
ses_A: 250 message.updated events for the same message, averaging ~33 MB each → 8.4 GB of byte-identical payloads. Top 3 sessions account for ~24 GB.
Root-cause chain
- A tool (here: an MCP server) continuously appends to a log file inside the workspace.
- OpenCode diffs the file against its snapshot and embeds the uncapped diff into
message.summary.diffs.
- Every
message.updated event stores a full copy of the message JSON in the event table (no truncation / dedup).
- The message is updated hundreds of times → hundreds of full-size copies → tens of GB.
- On session resume, giant messages are deserialized → OOM.
Steps to reproduce
- Start OpenCode TUI, assign a long task to OpenCode to let it keep running.
- Create a text file named
test.txt in your OpenCode workspace.
- Start a program that appends 1 MB of text into that file every 1 or 2 seconds.
- Wait until OOM crash; restarting and resuming the session crashes again.
Diagnostics SQL:
SQL queries used
SELECT name, sum(pgsize)/1048576.0 AS mb FROM dbstat GROUP BY name ORDER BY mb DESC;
SELECT length(data)/1048576 AS mb, type, aggregate_id FROM event ORDER BY length(data) DESC LIMIT 10;
SELECT aggregate_id, count(*), sum(length(data))/1048576 AS mb FROM event GROUP BY aggregate_id ORDER BY mb DESC LIMIT 10;
Plugins
None
OpenCode version
1.18.18
Screenshot and/or share link
The problematic session cannot be opened anymore.
Operating System
Windows 11 (24 GB RAM)
Terminal
Powershell 7.8
Description
When a text file in the OpenCode workspace keeps growing while a session is running (in my case an MCP server continuously appending its full API request/response log into the workspace — two log files reached 292 MB and 407 MB), OpenCode tracks the change and embeds the file's diff into
message.summary.diffson user messages.This is compounded by the event store: every
message.updatedevent re-serializes the entire message payload — including the huge embedded diff — as a new row in theeventtable. The same message is updated hundreds of times during a session, so the same multi-hundred-MB payload is written over and over.Results:
opencode.dbgrew to 32.9 GB (eventtable alone: 29.4 GB)Analysis
Measured on the 32.9 GB database:
eventmessageparteventholds 513k rows; 97.6% were written within ~8 hours.eventrow: 362 MB (message.updated.1). Payload begins:{"sessionID":"ses_A","info":{...,"role":"user","summary":{"diffs":[{"file":"/logs/api_20260820.jsonl","patch":"Index: ...— the full unified diff of the 407 MB log file is embedded in the message.
ses_A: 250message.updatedevents for the same message, averaging ~33 MB each → 8.4 GB of byte-identical payloads. Top 3 sessions account for ~24 GB.Root-cause chain
message.summary.diffs.message.updatedevent stores a full copy of the message JSON in theeventtable (no truncation / dedup).Steps to reproduce
test.txtin your OpenCode workspace.Diagnostics SQL:
SQL queries used
Plugins
None
OpenCode version
1.18.18
Screenshot and/or share link
The problematic session cannot be opened anymore.
Operating System
Windows 11 (24 GB RAM)
Terminal
Powershell 7.8