Repository navigation
Description
Description
Calling context.session.update({ sessionID, title: "" }) from a plugin clears the session's title. The same call over HTTP generates a new title instead.
The HTTP route treats an empty title as a request to generate one. The TUI relies on this to regenerate titles (data.tsx):
opencode/packages/server/src/handlers/session.ts
Lines 229 to 238 in df6fb9a
| if (ctx.payload.title !== undefined) { | |
| if (ctx.payload.title) { | |
| yield* session | |
| .rename({ sessionID: ctx.params.sessionID, title: ctx.payload.title }) | |
| .pipe(Effect.catchTag("Session.NotFoundError", missingSession)) | |
| } else { | |
| const title = yield* SessionTitle.Service | |
| yield* title.generate(ctx.params.sessionID) | |
| } | |
| } |
The plugin host passes the title straight to rename, so an empty title is saved as is:
opencode/packages/core/src/plugin/host.ts
Lines 574 to 581 in df6fb9a
| update: Effect.fn(function* (input) { | |
| yield* sessions.get(input.sessionID) | |
| if (input.title !== undefined) yield* sessions.rename({ sessionID: input.sessionID, title: input.title }) | |
| if (input.metadata !== undefined) | |
| yield* sessions.setMetadata({ sessionID: input.sessionID, metadata: input.metadata }) | |
| if (input.permissions !== undefined) | |
| yield* sessions.setPermissions({ sessionID: input.sessionID, permissions: input.permissions }) | |
| }), |
The plugin session.update takes the same input as the HTTP route (adapter.ts), so I'd expect it to behave the same way. No other plugin call runs the title generator.
A possible fix is to move the empty-title check into Session.Service so the route and the plugin host share it. I have a branch with that change and can open a PR.
Plugins
a local plugin
OpenCode version
2.1.2
Steps to reproduce
- In a plugin, call
await context.session.update({ sessionID, title: "" })for a session that already has a title. - Check the session's title.
The title is now "". Through the HTTP route (PATCH /api/session/:id with { "title": "" }), the same input generates a new title.
Screenshot
No response
Operating System
No response
Terminal
No response
Activity
opencode-agent commentedon Oct 23, 2026
Thanks for the detailed report, @jeremysamuel13. I reproduced this on 2.1.2, and it still happens on the latest
dev(df6fb9a).What I did, with a local plugin in
.opencode/plugins/andopencode serve:PATCH /api/session/<A>with{"title":""}returned 204 and did not clear the title. It took the title-generation path; without model credentials the old title stayed.await context.session.update({ sessionID: B, title: "" })set the title to"", andGET /api/session/<B>returns"title":""too.The cause is what you described. The HTTP handler in
packages/server/src/handlers/session.tssends an empty title to the title generator, but the plugin host'supdateinpackages/core/src/plugin/host.tspasses it straight torename. The script below reproduces it and creates the plugin itself.Related, but not the same problem: #51468 (plugin
session.updatedropping metadata) and #58176 / #58504 (automatic title generation).Reproduction script (repro.sh)
Run it:
bash repro.sh