Skip to content

Part IDs in chat.message hook missing required 'prt' prefix #29

@IvoryKir

Description

@IvoryKir

Bug

OpenCode now validates message part IDs with a Zod schema requiring them to start with "prt". The chat.message hook creates parts with IDs like supermemory-context-{timestamp} and supermemory-nudge-{timestamp}, which fail validation.

Error

ZodError: [
  {
    "origin": "string",
    "code": "invalid_format",
    "format": "starts_with",
    "prefix": "prt",
    "path": ["id"],
    "message": "Invalid string: must start with \"prt\""
  }
]

  at createUserMessage (/$bunfs/root/src/cli/cmd/tui/worker.js:108:35)

Reproduction

  1. Install opencode-supermemory@2.0.4
  2. Send the first message in a new session
  3. Error fires on every first message (when context injection runs)

Root Cause

In dist/index.js, the chat.message hook creates parts with non-compliant IDs:

  • Line ~14548: id: \supermemory-nudge-${Date.now()}``
  • Line ~14582: id: \supermemory-context-${Date.now()}``

Meanwhile, generatePartId() (line ~14180) already generates correct prt_-prefixed IDs but is only used in injectHookMessage.

Fix

Use the prt_ prefix for all part IDs in the chat.message hook, e.g.:

id: `prt_supermemory-nudge-${Date.now()}`
id: `prt_supermemory-context-${Date.now()}`

Or reuse the existing generatePartId() function.

Environment

  • opencode-supermemory: 2.0.4
  • OpenCode: latest (bunfs-based CLI)

Metadata

Metadata

Assignees

No one assigned

    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