Skip to content

remember keyword trigger creates invalid synthetic part IDs (id must start with prt) #28

@sirsir23333

Description

@sirsir23333

Description

When opencode-supermemory detects a memory keyword like remember, it injects a synthetic text part into the message. The injected part uses an id like supermemory-nudge-..., which does not satisfy OpenCode's part ID schema requirement that id must start with prt.

This causes message creation to fail with:

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

I also found the same problem in the injected context part on first-message context injection: it uses supermemory-context-..., which also does not start with prt.

Reproduction

Environment:

  • OpenCode 1.2.25
  • opencode-supermemory cached install 2.0.4

Steps:

  1. Enable the plugin in OpenCode config
  2. Start OpenCode
  3. Send a prompt containing remember, for example:
remember this preference: detailed progress updates

Actual

OpenCode fails while creating the user message with schema validation:

schema validation failure stack trace:
at createUserMessage ...
ZodError: Invalid string: must start with "prt"

Expected

The plugin should inject valid synthetic parts and the prompt should continue normally, allowing the agent to call the supermemory tool.

Root Cause

In src/index.ts, the plugin constructs synthetic Part objects with invalid IDs:

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

These should use the prt prefix expected by OpenCode.

Minimal Fix

- id: `supermemory-nudge-${Date.now()}`,
+ id: `prt_supermemory_nudge_${Date.now()}`,

- id: `supermemory-context-${Date.now()}`,
+ id: `prt_supermemory_context_${Date.now()}`,

Verification

After applying the patch locally, this succeeds:

opencode run "remember this preference: detailed progress updates"

and the plugin correctly triggers:

supermemory {"mode":"add","scope":"user","type":"preference",...}

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