Repository navigation
Description
Summary
The V2 plugin context is documented as being "essentially an OpenCode server
client", but ctx.session exposes only get, context, create, update,
move, prompt, … — there is no way to list or search sessions. Any
plugin that wants to give the agent memory of previous sessions is forced to
reach into undocumented internals (the service registration file plus the local
HTTP API), which is fragile across releases.
Please expose session listing (and ideally server-side full-text search) in the
plugin context, matching what the HTTP API already provides.
Environment
- opencode version: 2.0.30
- OS: Windows 10 (10.0.19045), win32 x64
- Terminal: xterm-256color
- Shell: cmd.exe
- Install/channel: latest
- Active plugins: one local V2 plugin at
~/.config/opencode/plugins/session-manager.js
Use case
An agent that can recall past work ("what did we do yesterday in this project?")
needs to:
- List recent sessions, optionally scoped to a directory.
- Read and search message content across sessions.
Today neither is reachable from a V2 plugin through the plugin API.
Current behavior
ctx.session has no list and no search method. Over HTTP, GET /api/session
exists, but its ?search= parameter only matches session titles, not message
content.
Plugins end up doing something like this, reading a file that is described as
internal state:
// ~/.local/state/opencode/service.json (or $XDG_STATE_HOME/opencode/service.json)
const info = JSON.parse(readFileSync(registrationFile(), "utf8"));
const res = await fetch(new URL("/api/session", info.url), {
headers: { Authorization: "Basic " + btoa("opencode:" + info.password) },
});This works, but it depends on the registration file shape and the HTTP auth
scheme, neither of which is part of the plugin contract.
Proposed API (sketch)
// ctx.session
list(input?: SessionListInput): Promise<SessionListOutput> // e.g. GET /api/session
// optional but very useful:
search(input: { query: string /* ... */ }): Promise<SessionSearchOutput>Even just list would remove the need for the workaround above.
Additional context
- Several community "agent memory / session" plugins currently fail to load on
V2 because they were written against the V1 plugin API (for example
opencode-session-manager,opencode-session-recall,opencode-session-tools).
The V2 loader rejects them with:
Plugin must export a default definition with an id and an effect or setup function. - Exposing session listing/search would let a whole class of such plugins be
written against the public plugin API instead of private internals.
Activity
opencode-agent commentedon Oct 16, 2026
Thanks for the clear write-up and the concrete API sketch!
I think this is a duplicate of #44155, which asks for the same thing: listing sessions from the plugin API, matching what the HTTP API already offers. There's also an open PR, #52681, that adds
session.listto both the Promise and Effect plugin contexts, with the same filters and cursor pagination asGET /api/session. That would cover the workaround you describe. Server-side full-text search over message content is tracked separately in #54863.Possible duplicates and closely related issues, ordered by likelihood:
listpart here.ctx.session.listto the plugin contexts.searchpart.ctx.message.list) to plugins.The bot will close this issue as a duplicate in 1 day unless you reply explaining how your request is different.
opencode-agent commentedon Oct 17, 2026
We haven't heard back, so I'm closing this as a duplicate of #44155, which asks for session listing in the plugin API. Please follow these instead:
ctx.session.listwith the same filters and pagination asGET /api/session.If your request needs something those don't cover, please reply here and we can reopen it. Thanks again for the detailed write-up!