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
I ran the command /compact, it seemed stuck so I proceeded to quit the app and when I re-opened and try to list my sessions I found out all of them were gone 🥲
The common pattern is that the /compact command can get stuck or cause unexpected behavior that results in loss of session data. Several users have reported similar issues where /compact appears to hang and requires force quitting the app, sometimes leading to session loss.
Feel free to ignore if none of these address your specific case.
I used opencode for only one project, so all my sessions were related to that project.
The repository had many commits. I initially started my session in a specific branch, but later switched to another branch to work on something else. I forgot to switch back and continued chatting. The responses were not accurate, which made me realize I was in the wrong branch. After switching back, I encountered a context window error, even though the TUI showed about 60% of the context in use, which was unusual. I decided to run /compact, but it got stuck, so I quit. After that, all my sessions were gone.
@ddanielcruzz just wanna see the "damage" so to speak can you run a few commands and see if data is still there for me?
id=$(git rev-list --max-parents=0 --all)
ls ~/.local/share/opencode/storage/session/${id}# if this is empty then run next ls command and show output if possible
ls ~/.local/share/opencode/storage/session
git rev-list --max-parents=0 --all
^^ Run this in your project, it will give the project id, that can then be used to list sessions^^
Hi @rekram1-node the latest data if from 2 days ago, so sadly my data is gone.
I encountered another issue where I closed a session as I added a new local MCP, once I re-opened I couldn't find the session in the list.
Running the commands you shared I have two directories, is that normal?.
I'm using git town to keep branches in sync as well as worktrees to have multiple instances of opencode in different branches. Not sure if it's related
id=$(git rev-list --max-parents=0 --all)
ls ~/.local/share/opencode/storage/session/${id}# output
/.local/share/opencode/storage/session/7b9ebd75da850e8f2ce0013a13d973314c3c26c1\n97d5b7390b6695f5f8189e90aac11e97c707b93f\n15175d963f0ed863af3d3c0f6287ef8ab81db034\na8e844dad56388522ddbaa68a3285570d5cef7b3": No such file or directory (os error 2)
ls ~/.local/share/opencode/storage/session
# outputs two direcotries
I'm having a similar problem, but not related to compaction. I did compact, without interruption. I was able to continue, with no problem. Then I exited and restarted, and no sessions. started with dev (v.0.14.x?) yesterday, had this problem, updated to v.0.15.0 today, no joy. However a "new" session that I started is showing up as available. The old session ses_625e82ae4ffeJuaY06cCPYUQ3X.json was gone from the previous project subdirectory:
./session/4b0ea68d7af9a6031a7ffda7ad66e0cb83315750
and was in ./session/global
there is a known issue that if you have a git repo without any commits, have sessions (they will be in global storage) then once you make commits you kinda “lose them” since the repo has commits and is no longer tracked in global
we ofc should handle this but does that sound like what may have happened for you?
there is a known issue that if you have a git repo without any commits, have sessions (they will be in global storage) then once you make commits you kinda “lose them” since the repo has commits and is no longer tracked in global
we ofc should handle this but does that sound like what may have happened for you?
#3123 fixed my problem.
My first commit in the repo I was working in: Date: Mon Oct 13 16:44:45 2025 +1300
Problem occurred after that, so I started working on a fix for it with first commit in opencode branch Date: Mon Oct 13 18:17:05 2025 +1300
So, no, I don't think it had to do with a git repo without commits. It looks like a straight forward migration/backward compatibility issue. Not that at 0.x you owe anyone backward compatibility, but... for me, if I couldn't fix this quickly, I would have given up on opencode, which would have been a shame because it is exactly the kind of tool I have been looking for and really want to use (across a variety of LLMs, and support for Cerebras was a huge bonus, the qwen-code fork that supported Cerebras was not playing well with newer commits to qwen-code). Huge gratitude to the maintainers and contributors of opencode.
I used a Gemini in gemini-cli to help me find and fix (#3123) and it threw in the "--continue" type behaviour as an automatic thing (which works for me, I have what is perhaps a different approach than some/many) but isn't really appropriate given that --continue is an option) so you probably want to remove that particular part of it.
I'm using a Claude Sonnet 4.5 (the session that got lost), and I'm really happy with how opencode works compared to Claude Code (and the stability/lack of unasked for automatic updates), and look forward to using it for gemini and qwen (without the sticky release issues or visible tearing when trying to avoid that issue).
@rekram1-node I think multiple causes can trigger this bug. I got it again yesterday, in a repo with commits. What happened was that the agent started a dev server process and got stuck, my messages to tell it to stop got queued and trying to exit was not working. I kept hitting ctrl + c until it exited, after reopening opencode the session I just exited was gone.
I did some changes that should fix this, one of them lands in next release
Wow, cool! Will this also fix disappearing subagent sessions (in the first place when being called by another subagent), or is this another issue? I often have the issue that I cannot find the window anymore (with ctrl-x left/right) after switching window (by accident or to search some text in the previous window), and the bot said it's related to "a bug with session handling for subagents" but I'm not sure whether this is correct or not (I learned not to trust them too much in such cases 😂).
Sorry, haven't seen this. I guess that this can be reproduced by undoing all commits, or by running into certain bugs when calling subagents, but I don't know if there are certain steps to consistently reproduce this. I experienced this several times and I observed certain patterns, but I am afraid I don't know enough about the reason why this happens to provide a reproducible workflow for consistent testing.
In my case, I had more than 30 sessions yesterday and today, I have only 5 in opencode...
I saw that a fix was proposed in #3123 but this was closed and not merged apparently.
Seems related to #14818 but also closed...
Any update about this loss of sessions please ?
This is related to the recent update v1.2.22 from Mar 8, 2026. I came back from vacation and noticed that all my sessiosn were gone. Upon looking in the ~/.local/share/opencode folder, I noticed a large database file opencode.db (~900MB) and a "small one" (~600kB). Seems like the migration didn't happen on my end, so I had to delete the new files and rename my old ones to match the new schema.
In the end, this fixed my problem:
also happen to me. in my case, i have 15+ session on a project. then today, its only show 5 session on the same project, the sessions almost gone. hope we can fix this in the future.
Activity
github-actions commentedon Oct 6, 2025
This issue might be a duplicate of existing issues. Please check:
The common pattern is that the /compact command can get stuck or cause unexpected behavior that results in loss of session data. Several users have reported similar issues where /compact appears to hang and requires force quitting the app, sometimes leading to session loss.
Feel free to ignore if none of these address your specific case.
rekram1-node commentedon Oct 6, 2025
@ddanielcruzz all your sessions, everywhere?
rekram1-node commentedon Oct 6, 2025
is there any chance this was in a project that didnt have any commits yet and then you did an initial commit?
ddanielcruzz commentedon Oct 6, 2025
Hey @rekram1-node
I used
opencodefor only one project, so all my sessions were related to that project.The repository had many commits. I initially started my session in a specific branch, but later switched to another branch to work on something else. I forgot to switch back and continued chatting. The responses were not accurate, which made me realize I was in the wrong branch. After switching back, I encountered a context window error, even though the TUI showed about 60% of the context in use, which was unusual. I decided to run
/compact, but it got stuck, so I quit. After that, all my sessions were gone.rekram1-node commentedon Oct 6, 2025
@ddanielcruzz just wanna see the "damage" so to speak can you run a few commands and see if data is still there for me?
git rev-list --max-parents=0 --all^^ Run this in your project, it will give the project id, that can then be used to list sessions^^
ddanielcruzz commentedon Oct 8, 2025
Hi @rekram1-node the latest data if from 2 days ago, so sadly my data is gone.
I encountered another issue where I closed a session as I added a new local MCP, once I re-opened I couldn't find the session in the list.
Running the commands you shared I have two directories, is that normal?.
I'm using git town to keep branches in sync as well as
worktreesto have multiple instances ofopencodein different branches. Not sure if it's relatedrekram1-node commentedon Oct 9, 2025
when u say running the commands shared which command and what was output?
ddanielcruzz commentedon Oct 9, 2025
Running
ls ~/.local/share/opencode/storage/sessiongives me two directoriesrekram1-node commentedon Oct 9, 2025
what if u use the id one?
ddanielcruzz commentedon Oct 9, 2025
Running these two
sjswerdloff commentedon Oct 13, 2025
I'm having a similar problem, but not related to compaction. I did compact, without interruption. I was able to continue, with no problem. Then I exited and restarted, and no sessions. started with dev (v.0.14.x?) yesterday, had this problem, updated to v.0.15.0 today, no joy. However a "new" session that I started is showing up as available. The old session ses_625e82ae4ffeJuaY06cCPYUQ3X.json was gone from the previous project subdirectory:
./session/4b0ea68d7af9a6031a7ffda7ad66e0cb83315750
and was in ./session/global
rekram1-node commentedon Oct 13, 2025
there is a known issue that if you have a git repo without any commits, have sessions (they will be in global storage) then once you make commits you kinda “lose them” since the repo has commits and is no longer tracked in global
we ofc should handle this but does that sound like what may have happened for you?
sjswerdloff commentedon Oct 14, 2025
#3123 fixed my problem.
My first commit in the repo I was working in: Date: Mon Oct 13 16:44:45 2025 +1300
Problem occurred after that, so I started working on a fix for it with first commit in opencode branch Date: Mon Oct 13 18:17:05 2025 +1300
So, no, I don't think it had to do with a git repo without commits. It looks like a straight forward migration/backward compatibility issue. Not that at 0.x you owe anyone backward compatibility, but... for me, if I couldn't fix this quickly, I would have given up on opencode, which would have been a shame because it is exactly the kind of tool I have been looking for and really want to use (across a variety of LLMs, and support for Cerebras was a huge bonus, the qwen-code fork that supported Cerebras was not playing well with newer commits to qwen-code). Huge gratitude to the maintainers and contributors of opencode.
I used a Gemini in gemini-cli to help me find and fix (#3123) and it threw in the "--continue" type behaviour as an automatic thing (which works for me, I have what is perhaps a different approach than some/many) but isn't really appropriate given that --continue is an option) so you probably want to remove that particular part of it.
I'm using a Claude Sonnet 4.5 (the session that got lost), and I'm really happy with how opencode works compared to Claude Code (and the stability/lack of unasked for automatic updates), and look forward to using it for gemini and qwen (without the sticky release issues or visible tearing when trying to avoid that issue).
ddanielcruzz commentedon Oct 16, 2025
@rekram1-node I think multiple causes can trigger this bug. I got it again yesterday, in a repo with commits. What happened was that the agent started a dev server process and got stuck, my messages to tell it to stop got queued and trying to exit was not working. I kept hitting ctrl + c until it exited, after reopening opencode the session I just exited was gone.
9 remaining items
rekram1-node commentedon Dec 8, 2025
I did some changes that should fix this, one of them lands in next release
redtux commentedon Dec 8, 2025
Wow, cool! Will this also fix disappearing subagent sessions (in the first place when being called by another subagent), or is this another issue? I often have the issue that I cannot find the window anymore (with ctrl-x left/right) after switching window (by accident or to search some text in the previous window), and the bot said it's related to "a bug with session handling for subagents" but I'm not sure whether this is correct or not (I learned not to trust them too much in such cases 😂).
rekram1-node commentedon Dec 13, 2025
im unfamiliar with this bug can u reliably reproduce it?
redtux commentedon Dec 16, 2025
Sorry, haven't seen this. I guess that this can be reproduced by undoing all commits, or by running into certain bugs when calling subagents, but I don't know if there are certain steps to consistently reproduce this. I experienced this several times and I observed certain patterns, but I am afraid I don't know enough about the reason why this happens to provide a reproducible workflow for consistent testing.
yogeek commentedon Feb 24, 2026
In my case, I had more than 30 sessions yesterday and today, I have only 5 in opencode...
I saw that a fix was proposed in #3123 but this was closed and not merged apparently.
Seems related to #14818 but also closed...
Any update about this loss of sessions please ?
somtooo commentedon Feb 24, 2026
hey i can say this is the bug - #3123. If i open opencode in home folder i have way more sessions than if its open in another folder
somtooo commentedon Feb 24, 2026
#3123 - this fixes it please re open
redtux commentedon Mar 2, 2026
I asked so three months ago in PR #3123. Let's hope we have more luck this time 🤞
tmdgjs2592 commentedon Mar 30, 2026
Is there any update on this problem? Opencode 1.3.8 still has this issue.
arunoruto commentedon Apr 1, 2026
This is related to the recent update v1.2.22 from Mar 8, 2026. I came back from vacation and noticed that all my sessiosn were gone. Upon looking in the
~/.local/share/opencodefolder, I noticed a large database fileopencode.db(~900MB) and a "small one" (~600kB). Seems like the migration didn't happen on my end, so I had to delete the new files and rename my old ones to match the new schema.In the end, this fixed my problem:
I didn't mind losing my new data, since it was just one session.
redtux commentedon May 23, 2026
Hi @rekram1-node , wouldn't it be good to have a repair script at least to restore the lost sessions?
wynadiis23 commentedon May 28, 2026
also happen to me. in my case, i have 15+ session on a project. then today, its only show 5 session on the same project, the sessions almost gone. hope we can fix this in the future.
uros-5 commentedon Aug 9, 2026
Same issue. It does not appear in
/sessionmenu. But this helped me: