OpenCode Agent Memory: Restore Context Between Sessions
Use OpenCode’s supported instruction files, saved sessions, and a reviewed handoff to continue work. Test a fresh session before trusting what it remembers.
Updated 5 min read
For agent memory in OpenCode, use supported instruction files for lasting guidance, resume a saved session when you need its conversation, and save a separate handoff for a fresh start. Check which information a new session actually reads before it edits anything. fenbs can hold the shared project record; OpenCode is not a supported fenbs integration, so use a supported assistant or transfer reviewed context manually.
Resuming a conversation and restoring current project knowledge are different jobs. You may want the old discussion, but tomorrow’s work still needs the current decision and remaining check. The agent memory overview explains that distinction more broadly.
How do you prepare OpenCode to continue work?
- Start in the intended project directory. Identify the current version of the files before relying on a previous session’s summary.
- Create or review the project’s
AGENTS.md. Write the actual working commands, conventions, and boundaries the next session should follow. - Save a short handoff with completed changes, checks actually run, unresolved questions, and the next step. Keep it separate from standing instructions.
- Use session recovery when you need the previous conversation. Use a fresh session when you want to test whether the saved instructions and handoff are sufficient.
- Ask the assistant to identify its sources and summarize the remaining work before editing. Correct the record if it misses a fact or reports an unrun check as complete.
OpenCode’s rules documentation (opens in a new tab) supports project instructions in AGENTS.md; /init can create or update that file. Review the generated guidance before treating it as agreed policy. Use a small, reversible task for your first continuity check rather than a production change.
Where should lasting instructions live?
Put shared project conventions in the project instruction file. OpenCode also supports global guidance in ~/.config/opencode/AGENTS.md and additional instruction sources through the instructions configuration setting. Its rules documentation explains file precedence and compatibility fallbacks, which matter if several tools have left instruction files in the same project.
Keep a personal preference separate from a team rule. “Answer concisely” can be personal guidance; “use this verification command for this package” belongs with the project. A decision awaiting approval should remain a question instead of becoming a permanent command through a generated summary.
For a hypothetical website task, the standing instruction could identify the shared form validation helper. The current handoff could say that the empty-input case still needs checking. Keeping those separate prevents tomorrow’s assistant from treating a temporary task state as a rule for all future work.
If another supported assistant needs the same project decisions, fenbs keeps the reviewed choices and current work together in its shared work record. OpenCode can receive a selected, reviewed summary manually.
How do you recover a conversation without confusing it with memory?
The OpenCode CLI reference (opens in a new tab) documents opencode --continue for continuing the last session and opencode --session for selecting a session by its ID. Use the intended session explicitly when several tasks are in progress, then check its opening state against the files you have now.
opencode --continue
Inside the terminal interface, /sessions lists and switches sessions, while /new starts a new one. /export exports the current conversation as Markdown. These are documented in the terminal interface guide (opens in a new tab). An export preserves a discussion you can inspect; it still needs review before you reuse parts as current instructions.
A continued session may include decisions that later changed, or reports from an earlier workspace state. Ask the assistant to compare the saved next step with the current task and relevant files. Our guide to memory versus context explains why retained text still has to enter the active conversation to affect an answer.
How can you verify a restart workflow?
Choose three facts you can inspect: a standing boundary, a completed change, and a check that remains unrun. Save them in the appropriate sources, end the session, and reopen the intended project. Then start a fresh conversation so the check does not simply repeat the discussion you just had.
Read the project instructions and saved handoff. Do not edit files. List the rule that applies, the completed change, and the outstanding check. Identify the source for each answer. Compare the handoff with the current files and flag any disagreement. Propose the next action.
Keep the answers out of the test prompt. If you tell the assistant which test remains unrun, you have supplied the memory yourself. A useful result identifies the saved evidence, preserves uncertainty, and proposes the next safe action. Correct missing facts at the source before repeating the check.
OpenCode’s configuration reference (opens in a new tab) also documents context compaction, which condenses a long session. Compaction is not a substitute for a reviewed record of decisions and progress. For transitions between people or apps, use the same source-checking habit described in the AI handoff guide.
What should you fix when the new session gets it wrong?
- Wrong project: reopen the intended directory and inspect the version before reusing session guidance.
- Missing instruction: inspect the recognized files and their precedence, rather than creating another copy with different wording.
- Stale progress: update the task state and next action, keeping completed edits separate from passed checks.
- Unclear approval: ask a person to resolve the choice; an assistant’s proposed approach is not evidence of a decision.
- Untrusted saved text: review its origin and remove instructions copied from material that should only have been treated as reference.
The agent memory security guide covers sensitive information and unsafe saved instructions. If your problem is a reusable procedure rather than a project fact, the separate agent memory skill guide owns that question.
Keep the shared handoff outside one coding session
Save reviewed decisions, tasks, and Where we left off in fenbs. Use a supported connected assistant to read and update that record, or manually move the relevant summary between fenbs and OpenCode. Check the transferred facts before continuing so the shared record remains accurate.
Create a free accountFree for one person · No credit card · Works with Claude, ChatGPT, Cursor and more
How to do this with fenbs
- Create a free account, add the project, and write the active task and its current next step. It is free for one person, no credit card.
- Record choices a person approved in Decisions and rules. Keep unresolved questions visible and save lessons only after reviewing what happened.
- Choose a supported assistant from Integrations, such as Cursor or Claude Code, to read and update fenbs. OpenCode is not on that supported list.
- Before using OpenCode, review and supply the relevant project context manually. After the session, review its progress summary and save the accurate result in fenbs yourself or through the supported assistant.
fenbs does not import OpenCode sessions. If you want only local instructions and conversation recovery, OpenCode’s files and session controls may cover your needs. Use fenbs when decisions and handoffs also need a shared home across people or supported AI apps; the AI memory hub covers other approaches.