-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Description
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:
createUserMessage()inprompt.tsprocesses parts and assigns validprt_*IDs via theassign()functionPlugin.trigger("chat.message", ...)passes thepartsarray by reference to plugin hooks- The
opencode-supermemoryplugin pushes new parts withsupermemory-nudge-*/supermemory-context-*IDs into the array (dist/index.js lines 14548, 14582) Session.updatePart(part)validates viafn(MessageV2.Part, ...)which runsPartID.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@latestopencode-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()}toprt_smnudge_${Date.now()} - Line 14582: change
supermemory-context-${Date.now()}toprt_smctx_${Date.now()}
OpenCode version
1.2.27 - 1.3.0
Steps to reproduce
- Install
opencode-supermemoryplugin - Send any message in the TUI or CLI
- The schema validation error is thrown
Screenshot and/or share link
No response
Operating System
Fedora 43
Terminal
Fish