Getting a json parse error on the prompt history and/or token error #2826

Closed
opened 2026-02-16 17:37:24 -05:00 by yindo · 7 comments
Owner

Originally created by @ubuntupunk on GitHub (Nov 13, 2025).

Originally assigned to: @rekram1-node on GitHub.

Description

After a sudden shutdown, getting a json parse error for the prompt history, have tried removing and reinstalling, deleting the local and global config files, but no luck.

OpenCode version

1.0.62

Steps to reproduce

Run Opencode

Syntax error ' token unknown, see attachment

Screenshot and/or share link

Image

Operating System

Ubuntu 24.04

Terminal

Gnome Terminal

Originally created by @ubuntupunk on GitHub (Nov 13, 2025). Originally assigned to: @rekram1-node on GitHub. ### Description After a sudden shutdown, getting a json parse error for the prompt history, have tried removing and reinstalling, deleting the local and global config files, but no luck. ### OpenCode version 1.0.62 ### Steps to reproduce Run Opencode Syntax error ' token unknown, see attachment ### Screenshot and/or share link <img width="1375" height="726" alt="Image" src="https://github.com/user-attachments/assets/72bf624c-295a-4a2e-a754-cd09e440829b" /> ### Operating System Ubuntu 24.04 ### Terminal Gnome Terminal
yindo added the opentuibug labels 2026-02-16 17:37:24 -05:00
yindo closed this issue 2026-02-16 17:37:24 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Nov 13, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #4254: Fatal error with JSON/syntax parsing - same "undefined is not an object (evaluating 'lines().length')" error type
  • #4178: Similar fatal error pattern after startup/config issues
  • #4246: Configuration errors preventing OpenCode from starting properly
  • #4145: Crash on bad user config with similar undefined object evaluation errors
  • #4179: OpenCode fails to launch with hanging behavior

Feel free to ignore if none of these address your specific case with prompt history JSON parse errors.

@github-actions[bot] commented on GitHub (Nov 13, 2025): This issue might be a duplicate of existing issues. Please check: - #4254: Fatal error with JSON/syntax parsing - same "undefined is not an object (evaluating 'lines().length')" error type - #4178: Similar fatal error pattern after startup/config issues - #4246: Configuration errors preventing OpenCode from starting properly - #4145: Crash on bad user config with similar undefined object evaluation errors - #4179: OpenCode fails to launch with hanging behavior Feel free to ignore if none of these address your specific case with prompt history JSON parse errors.
Author
Owner

@ubuntupunk commented on GitHub (Nov 13, 2025):

Here is the fix:
rm -rf ~/.local/state/opencode

Had to grep my entire home directory to find opencode is setting state under this directory.

@ubuntupunk commented on GitHub (Nov 13, 2025): Here is the fix: ` rm -rf ~/.local/state/opencode` Had to grep my entire home directory to find opencode is setting state under this directory.
Author
Owner

@rekram1-node commented on GitHub (Nov 13, 2025):

Hm I wonder what happened

@rekram1-node commented on GitHub (Nov 13, 2025): Hm I wonder what happened
Author
Owner

@ubuntupunk commented on GitHub (Nov 14, 2025):

Seems like a corrupted state management file caused by an unscheduled shutdown. There should be a check on the file to avoid this, before instantiating the state history?

@ubuntupunk commented on GitHub (Nov 14, 2025): Seems like a corrupted state management file caused by an unscheduled shutdown. There should be a check on the file to avoid this, before instantiating the state history?
Author
Owner

@rekram1-node commented on GitHub (Nov 14, 2025):

yeah I think the tui state prolly got corrupted

@rekram1-node commented on GitHub (Nov 14, 2025): yeah I think the tui state prolly got corrupted
Author
Owner

@marklise commented on GitHub (Nov 14, 2025):

@rekram1-node, I had the same situation as @ubuntupunk. In my case, the history got corrupted as the partition that opencode stores ~/.local/state/opencode/prompt-history.jsonl temporarily ran out of space. From that point forward, opencode just kept writing json into that history file so it was never going to fix itself. I simply deleted the offending json line, wrote the file, restarted and retained my prompt history and everything is back to normal.

@marklise commented on GitHub (Nov 14, 2025): @rekram1-node, I had the same situation as @ubuntupunk. In my case, the history got corrupted as the partition that opencode stores `~/.local/state/opencode/prompt-history.jsonl` temporarily ran out of space. From that point forward, opencode just kept writing json into that history file so it was never going to fix itself. I simply deleted the offending json line, wrote the file, restarted and retained my prompt history and everything is back to normal.
Author
Owner

@rekram1-node commented on GitHub (Nov 16, 2025):

next release should fix both of ur issues, for whatever reason we werent capping out # of entries to that file, now it wont grow forever lol

also introduced better error handling

@rekram1-node commented on GitHub (Nov 16, 2025): next release should fix both of ur issues, for whatever reason we werent capping out # of entries to that file, now it wont grow forever lol also introduced better error handling
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2826