Skip to content

v2: plugin ctx.session.update drops metadata, title is saved #51468

Closed

Description

@sudokvn

Description

When a plugin calls ctx.session.update with title and metadata, the title is saved but metadata is silently dropped. The call does not return an error. The same update through opencode api session.update saves metadata for the same session.

Possible cause, not confirmed: plugin API calls go through adaptApiMethod in @opencode/plugin, which re-decodes the input against the endpoint schemas before calling the server. metadata may get lost there.

Plugins

Only the minimal probe plugin below, placed project-local.

OpenCode version

2.0.18 (also seen on 2.0.15 in an earlier test)

Steps to reproduce

  1. In an empty folder, create .opencode/plugins/probe.ts:

    export default {
      id: "probe",
      async setup(ctx: any) {
        (async () => {
          for await (const e of ctx.event.subscribe()) {
            if (e.type === "session.execution.succeeded") {
              await ctx.session.update({
                sessionID: e.data.sessionID,
                title: "probe-updated",
                metadata: { probe: { ok: true } },
              });
            }
          }
        })();
      },
    };
  2. From that folder, run opencode run --standalone --print-logs "Reply with just: ok".

  3. Check the session: sqlite3 -readonly ~/.local/share/opencode/opencode.db "select title, metadata from session_v2 where id='<id>'". The title is probe-updated, metadata is empty.

  4. Control: opencode api --standalone session.update --param sessionID=<id> -d '{"metadata":{"probe":{"ok":true}}}'. Now metadata is saved.

Expected: step 2 saves metadata the same way step 4 does.

Operating System

macOS 27.0

Terminal

Ghostty 1.3.1 (stable, macOS, Metal renderer)


Issue created and tested with the help of AI (Claude Opus 5.5), edited and corrected by me.

Activity

  1. neriousy commented on Oct 20, 2026

    @neriousy
    Member

    Thanks for reporting this! Plugin calls to ctx.session.update now save metadata alongside the title, fixed in 2.0.22. Update with opencode upgrade or npm i -g @opencode/cli@latest (desktop: update the app). Please comment or reopen if it still happens on that version.

  2. sudokvn commented on Oct 21, 2026

    @sudokvn
    Author

    I tested on 2.1.2 and it's fixed: the session update now saves both the title and the metadata. Thanks!

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