Skip to content

Support a --continue flag to persist context in a new session #1207

Closed

Description

@mcncl

Problem

Due to issues like #725, where limits aren't clear and no messaging is provided, it's easy to assume that OpenCode has just stopped working, so moving to another tool such as Amp or Claude Code is the assumed solution. However, those tools then inform you that limits have been reached. At that point though, context for OpenCode has been lost, so I need to interact with the tool to get it back up to speed with where we were.

Suggestion

Given we have a /share command, I would assume that there is some context stored for the current conversation. Would it be possible to therefore support a --continue flag when running opencode so that the previous conversation can continue and context is not lost? I would assume there are some logs or session information in the locally stored DB?

I appreciate that's a few assumptions, but I'd like to continue to use OpenCode and not have to quit out to check that usage limits are the issue, losing my progress and conversation.

Else, can we add information on usage limits to the conversation window?

Activity

  1. self-assigned this
    on Jul 22, 2025
  2. thdxr commented on Jul 22, 2025

    @thdxr
    Member

    maybe im not following but can't you open the session list and get back to the old session?

  3. mcncl commented on Jul 31, 2025

    @mcncl
    Author

    @thdxr wow. 😬Apologies for wasting your time even opening this. This is clearly me being dumb; I just assumed it would be a flag or sub command on the opencode command.

    I'll close this and just thank you for providing such a great tool.

  4. davidchase commented on Sep 4, 2025

    @davidchase

    maybe im not following but can't you open the session list and get back to the old session?

    @thdxr I actually have this issue I was in a session and now the session list is empty and cannot continue my old session, are they perhaps stored somewhere?

  5. rekram1-node commented on Sep 4, 2025

    @rekram1-node
    Collaborator

    @davidchase I think you migrations may have failed, I can help you debug.

    What version of opencode are you on, what do you see if you run:

    cat ~/.local/share/opencode/storage/migration
    
  6. davidchase commented on Sep 4, 2025

    @davidchase

    That would be awesome @rekram1-node !

    ➜ ~ opencode --version
    0.6.4

    ➜ ~ cat ~/.local/share/opencode/storage/migration
    1

  7. rekram1-node commented on Sep 4, 2025

    @rekram1-node
    Collaborator

    @davidchase delete that migration file I just had you cat, then start opencode

    it will run the migrations for say 10 seconds to a minute or so (no visual indication atm)

    once it is done the tui will boot

  8. rekram1-node commented on Sep 4, 2025

    @rekram1-node
    Collaborator

    once that happens first:
    check if you have any sessions listed

    if not:
    show me the latest log file

    it would be in ~/.local/share/opencode/log/

  9. davidchase commented on Sep 4, 2025

    @davidchase

    will the migration delete the session i have started since ive lost the previous one? i dont want to lose the new one too

  10. rekram1-node commented on Sep 4, 2025

    @rekram1-node
    Collaborator

    it shouldn’t but I can double check if you want

  11. davidchase commented on Sep 4, 2025

    @davidchase

    ok i exported the session that i had started just in case, then deleted that migration you had me 'cat' and then started opencode and i have only my single new session there and not old one from before

  12. rekram1-node commented on Sep 4, 2025

    @rekram1-node
    Collaborator

    @davidchase can you show me the latest log file

  13. davidchase commented on Sep 4, 2025

    @davidchase

    sure the log from today is

    ➜  log cat 2025-09-04T140923.log
    INFO  2025-09-04T14:09:23 +50ms service=default version=0.6.4 args=[] opencode
    INFO  2025-09-04T14:09:23 +1ms service=project directory=/Users/davidcasa/chiron fromDirectory
    INFO  2025-09-04T14:09:23 +10ms service=config path=/Users/davidcasa/.config/opencode/config.json loading
    INFO  2025-09-04T14:09:23 +0ms service=config path=/Users/davidcasa/.config/opencode/opencode.json loading
    INFO  2025-09-04T14:09:23 +0ms service=config path=/Users/davidcasa/.config/opencode/opencode.jsonc loading
    INFO  2025-09-04T14:09:23 +2ms service=plugin [email protected] loading plugin
    INFO  2025-09-04T14:09:23 +1ms service=plugin [email protected] loading plugin
    INFO  2025-09-04T14:09:23 +11ms service=bus type=* subscribing
    INFO  2025-09-04T14:09:23 +0ms service=bus type=session.updated subscribing
    INFO  2025-09-04T14:09:23 +0ms service=bus type=message.updated subscribing
    INFO  2025-09-04T14:09:23 +0ms service=bus type=message.part.updated subscribing
    INFO  2025-09-04T14:09:23 +0ms service=format init
    INFO  2025-09-04T14:09:23 +0ms service=bus type=file.edited subscribing
    INFO  2025-09-04T14:09:23 +1ms service=lsp serverIds=typescript, vue, eslint, gopls, ruby-lsp, pyright, elixir-ls, zls, csharp, rust, clangd enabled LSP servers
    INFO  2025-09-04T14:09:23 +1ms service=models.dev file={} refreshing
    INFO  2025-09-04T14:09:23 +3ms service=provider init
    INFO  2025-09-04T14:09:23 +0ms service=provider providerID=opencode found
    INFO  2025-09-04T14:09:23 +0ms service=provider providerID=anthropic found
    INFO  2025-09-04T14:09:23 +2ms service=default cmd=["/Users/davidcasa/.cache/opencode/tui/tui-tdf4tf8r."] tui
    INFO  2025-09-04T14:09:23 +18ms service=server method=GET path=/agent request
    INFO  2025-09-04T14:09:23 +0ms service=project directory=/Users/davidcasa/chiron fromDirectory
    INFO  2025-09-04T14:09:23 +1ms service=server duration=1 response
    INFO  2025-09-04T14:09:23 +0ms service=server method=GET path=/path request
    INFO  2025-09-04T14:09:23 +0ms service=project directory=/Users/davidcasa/chiron fromDirectory
    INFO  2025-09-04T14:09:23 +0ms service=server duration=0 response
    INFO  2025-09-04T14:09:23 +0ms service=server method=GET path=/project/current request
    INFO  2025-09-04T14:09:24 +1ms service=project directory=/Users/davidcasa/chiron fromDirectory
    INFO  2025-09-04T14:09:24 +0ms service=server duration=0 response
    INFO  2025-09-04T14:09:24 +1ms service=server method=GET path=/config request
    INFO  2025-09-04T14:09:24 +0ms service=project directory=/Users/davidcasa/chiron fromDirectory
    INFO  2025-09-04T14:09:24 +0ms service=server duration=0 response
    INFO  2025-09-04T14:09:24 +0ms service=project directory=/Users/davidcasa/chiron fromDirectory
    INFO  2025-09-04T14:09:24 +8ms service=server method=GET path=/command request
    INFO  2025-09-04T14:09:24 +0ms service=project directory=/Users/davidcasa/chiron fromDirectory
    INFO  2025-09-04T14:09:24 +0ms service=server duration=0 response
    INFO  2025-09-04T14:09:24 +0ms service=project directory=/Users/davidcasa/chiron fromDirectory
    INFO  2025-09-04T14:09:24 +1ms service=server method=GET path=/file/status request
    INFO  2025-09-04T14:09:24 +0ms service=project directory=/Users/davidcasa/chiron fromDirectory
    INFO  2025-09-04T14:09:24 +0ms service=server duration=0 response
    INFO  2025-09-04T14:09:24 +0ms service=server method=GET path=/event request
    INFO  2025-09-04T14:09:24 +0ms service=project directory=/Users/davidcasa/chiron fromDirectory
    INFO  2025-09-04T14:09:24 +0ms service=server event connected
    INFO  2025-09-04T14:09:24 +2ms service=bus type=* subscribing
    INFO  2025-09-04T14:09:24 +0ms service=server duration=2 response
    INFO  2025-09-04T14:09:24 +1ms service=server method=GET path=/config/providers request
    INFO  2025-09-04T14:09:24 +0ms service=project directory=/Users/davidcasa/chiron fromDirectory
    INFO  2025-09-04T14:09:24 +0ms service=server duration=0 response
    INFO  2025-09-04T14:09:24 +0ms service=server method=GET path=/tui/control/next request
    INFO  2025-09-04T14:09:24 +0ms service=project directory=/Users/davidcasa/chiron fromDirectory
    INFO  2025-09-04T14:09:24 +0ms service=project directory=/Users/davidcasa/chiron fromDirectory
    INFO  2025-09-04T14:09:24 +1ms service=tui commands={"agent_cycle":{},"agent_cycle_reverse":{},"agent_list":{},"app_exit":{},"app_help":{},"editor_open":{},"input_clear":{},"input_newline":{},"input_paste":{},"input_submit":{},"messages_copy":{},"messages_first":{},"messages_half_page_down":{},"messages_half_page_up":{},"messages_last":{},"messages_page_down":{},"messages_page_up":{},"messages_redo":{},"messages_undo":{},"model_cycle_recent":{},"model_cycle_recent_reverse":{},"model_list":{},"project_init":{},"session_child_cycle":{},"session_child_cycle_reverse":{},"session_compact":{},"session_export":{},"session_interrupt":{},"session_list":{},"session_new":{},"session_share":{},"session_timeline":{},"session_unshare":{},"theme_list":{},"thinking_blocks":{},"tool_details":{}} Loaded commands
    INFO  2025-09-04T14:09:24 +0ms service=project directory=/Users/davidcasa/chiron fromDirectory
    INFO  2025-09-04T14:09:24 +7ms service=project directory=/Users/davidcasa/chiron fromDirectory
    INFO  2025-09-04T14:09:24 +9ms service=project directory=/Users/davidcasa/chiron fromDirectory
    INFO  2025-09-04T14:09:24 +0ms service=project directory=/Users/davidcasa/chiron fromDirectory
    INFO  2025-09-04T14:09:24 +6ms service=project directory=/Users/davidcasa/chiron fromDirectory
    INFO  2025-09-04T14:09:24 +1ms service=project directory=/Users/davidcasa/chiron fromDirectory
    INFO  2025-09-04T14:09:26 +2386ms service=server method=GET path=/session request
    INFO  2025-09-04T14:09:26 +0ms service=project directory=/Users/davidcasa/chiron fromDirectory
    INFO  2025-09-04T14:09:26 +2ms service=server duration=2 response
  14. davidchase commented on Sep 4, 2025

    @davidchase

    let me know if i should add logs from yesterday since i noticed the issue of missing session then, it seems i have more logs from yesterday with larger sizes

  15. rekram1-node commented on Sep 4, 2025

    @rekram1-node
    Collaborator

    I suppose it doesn't hurt, mostly what I need is the logs immediately after deleting the migration and then rerunning opencode

  16. davidchase commented on Sep 4, 2025

    @davidchase

    the logs i shared above are from today after deleting that migration file

  17. rekram1-node commented on Sep 4, 2025

    @rekram1-node
    Collaborator

    That's very strange then, looks like no errors… did you run it in the same dir that previously had the session you were looking for?

  18. davidchase commented on Sep 4, 2025

    @davidchase

    yes i working in ~/chiron that had the original session that was lost and now started a new session same directory

  19. rekram1-node commented on Sep 4, 2025

    @rekram1-node
    Collaborator

    Hmm I'm not really sure then maybe some failure is happening silently I will check

  20. davidchase commented on Sep 4, 2025

    @davidchase

    @rekram1-node here is the log i think around when the session went missing because i was getting errors that were popping up and after that i noticed my session was gone this one has error logs along with info

    2025-08-29T131955.log

  21. rekram1-node commented on Sep 4, 2025

    @rekram1-node
    Collaborator

    Hmm still no errors related to what I'd expect

  22. davidchase commented on Sep 4, 2025

    @davidchase

    so probably no way to recover it?

  23. rekram1-node commented on Sep 4, 2025

    @rekram1-node
    Collaborator

    you can try looking around in ~/.local/share/opencode/storage/ but recovering likely requires a bit of work

  24. davidchase commented on Sep 4, 2025

    @davidchase

    thanks for the tips btw much appreciate you looking into this... one last question any way to try to prevent session loss in the future? should i just export daily the sessions?

  25. rekram1-node commented on Sep 4, 2025

    @rekram1-node
    Collaborator

    no problem, it is hard to say because I don't know what caused loss here, you could've changed the dir name, accidentally deleted, a whole host of things.

    I haven't had any sessions randomly disappear but if you are super worried about sessions then maybe making a /share link would be useful.

    I think super long sessions are generally an anti pattern so I always split them up per task rather than 1 giant one

  26. acornforth commented on Nov 10, 2025

    @acornforth

    @rekram1-node I have also had the issue of sessions disappearing from the /sessions list.

    I can see that there are still a number of sessions stored in json files in ~/.local/share/opencode/storage/sessions, and a bunch of corresponding messages, but they are not listed when i use the command in tui.

    my migration file just says '2' and i've observed this in version 1.0.45, and not resolved by updating to 1.0.55

    I also tried the steps you mentioned above, deleting the migration file and re-running the tui, but no change to the empty session list.

    attempting to load the session directly using the -s <session_id> flag yield the following error:

    INFO  2025-11-10T13:09:13 +69ms service=config path=/home/acorn/.config/opencode/config.json loading
    INFO  2025-11-10TERROR 2025-11-10T13:09:14 +339ms service=default e=undefined is not an object (evaluating 'scroll.scrollTo') exception
    rvice=config path=/home/acorn/.config/opencode/opencode.jsonc loading
    INFO  2025-11-10T13:09:13 +23ms service=server method=GET path=/config/providers request
    INFO  2025-11-10T13:09:13 +0ms service=server status=started method=GET path=/config/providers request
    

    and attempting to opencode import the session from the file name, fails with a different error, but i assume this is because "exported" sessions have a different format? :

    ERROR 2025-11-10T13:10:55 +8ms service=default name=TypeError message=undefined is not an object (evaluating 'exportData.info.id') stack=TypeError: undefined is not an object (evaluating 'exportData.info.id')
        at <anonymous> (src/cli/cmd/import.ts:84:71)
        at processTicksAndRejections (native:7:39) fatal
    

    I've searched the issues and i can't see any currently open or active ticket tracking this. Should i create one?

    I hope this extra information is useful for debugging, please let me know if you discover a way i can restore these sessions 🤞🏼

  27. rekram1-node commented on Nov 10, 2025

    @rekram1-node
    Collaborator

    @acornforth hm the import should still work id think

    I have heard someone else have this issue tooo

    maybe there is a bug if a message is created in a certain state then it breaks the session making it seem “deleted”

  28. manascb1344 commented on Jan 18, 2026

    @manascb1344

    maybe im not following but can't you open the session list and get back to the old session?

    IN the case where i moved the folder to a new path, i notice that there are no previous sessions
    Is there a way to fix this
    I tried exporting session to md file from opencode tui, it generated an md file then i tried opencode import, however it only works with json or opencode.ai urls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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