Skip to content

Schema validation error #18780

@CybLow

Description

@CybLow

Description

When sending a message in the TUI/CLI, OpenCode throws a schema validation error. This has been happening since v1.2.27 and persists in v1.3.0.

schema validation failure stack trace:
      at result6 (/$bunfs/root/src/index.js:107068:20)
      at createUserMessage (/$bunfs/root/src/index.js:252931:35)
schema validation issues: [
  {
    "origin": "string",
    "code": "invalid_format",
    "format": "starts_with",
    "prefix": "prt",
    "path": [
      "id"
    ],
    "message": "Invalid string: must start with \"prt\""
  }
]

Root Cause

The opencode-supermemory plugin generates part IDs with non-compliant prefixes (supermemory-nudge-* and supermemory-context-*) instead of the required prt prefix introduced in v1.2.25 (PR #16966).

The crash path:

  1. createUserMessage() in prompt.ts processes parts and assigns valid prt_* IDs via the assign() function
  2. Plugin.trigger("chat.message", ...) passes the parts array by reference to plugin hooks
  3. The opencode-supermemory plugin pushes new parts with supermemory-nudge-* / supermemory-context-* IDs into the array (dist/index.js lines 14548, 14582)
  4. Session.updatePart(part) validates via fn(MessageV2.Part, ...) which runs PartID.zod.parse() (z.string().startsWith("prt")) and throws

While this is a plugin-side bug, the core should protect itself against misbehaving plugins. After Plugin.trigger("chat.message") returns, there is no re-validation or re-assignment of part IDs for parts that plugins may have added or mutated.

Plugins

  • opencode-supermemory (primary culprit)
  • opencode-antigravity-auth@latest
  • opencode-anthropic-oauth

Suggested Fix

Core (defense in depth): After Plugin.trigger("chat.message") in createUserMessage(), sanitize part IDs:

for (const part of parts) {
  if (!part.id || typeof part.id !== "string" || !part.id.startsWith("prt")) {
    (part as any).id = PartID.ascending()
  }
}

Plugin side: There are already multiple open PRs on supermemoryai/opencode-supermemory to fix this.

Immediate workaround: Patch ~/.cache/opencode/node_modules/opencode-supermemory/dist/index.js:

  • Line 14548: change supermemory-nudge-${Date.now()} to prt_smnudge_${Date.now()}
  • Line 14582: change supermemory-context-${Date.now()} to prt_smctx_${Date.now()}

OpenCode version

1.2.27 - 1.3.0

Steps to reproduce

  1. Install opencode-supermemory plugin
  2. Send any message in the TUI or CLI
  3. The schema validation error is thrown

Screenshot and/or share link

No response

Operating System

Fedora 43

Terminal

Fish

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions