A conversation context between you and an OpenCode agent.
A session is a single, continuous conversation with an OpenCode agent. It tracks every message, tool call, and file change from the moment you start talking until you close or switch away. Think of it as a chat thread with memory.
When you launch OpenCode or start a new conversation, a session is created with a unique ID. That session accumulates the full history: your prompts, the agent's responses, every tool invocation (file reads, bash commands, searches), and all output.
Sessions are stored locally on disk. They are not uploaded anywhere. This is a privacy-by-design choice — your conversation data stays on your machine.
You can resume a specific session later using its ID, or let OpenCode continue the most recent one automatically.
A session contains:
Sessions can also have child sessions created by subagents. These are nested conversations that a subagent runs independently, then reports results back to the parent.
Sessions are stored locally. The exact location depends on your OS and OpenCode configuration, but they persist in the OpenCode data directory.
Key commands for working with sessions:
# Continue the most recent session
opencode --continue
# Resume a specific session by ID
opencode --session <session-id>
# Share the current session (creates a shareable link)
/share
You do not create sessions manually. They are created automatically:
--continue to resume, or start freshIf you want to explicitly start a new session while one is active, start a fresh OpenCode instance without the --continue flag.
A typical session lifecycle:
# Start a new session
opencode
# You and the agent discuss a bug fix, edit files, run tests.
# The session tracks everything.
# Exit OpenCode
# Come back later, resume the same session
opencode --continue
# The agent remembers your previous conversation and file changes.
Navigating child sessions (if subagents are used):
# Enter a child session
Leader + Down
# Cycle between child sessions
Right / Left
# Return to parent session
Up
/share command creates a shareable link, but the underlying data remains on your machine until you explicitly share it.
session.compacted event fires, and a hook can customize this behavior.