Skip to content

Fix invalid synthetic part IDs#33

Open
walioo wants to merge 1 commit intosupermemoryai:mainfrom
walioo:codex/fix-supermemory-part-ids
Open

Fix invalid synthetic part IDs#33
walioo wants to merge 1 commit intosupermemoryai:mainfrom
walioo:codex/fix-supermemory-part-ids

Conversation

@walioo
Copy link

@walioo walioo commented Mar 19, 2026

Title: Fix synthetic chat.message part IDs to use valid prt_ format

Body:

Summary

This fixes a compatibility issue with recent OpenCode versions where the plugin injects synthetic chat.message parts with IDs like supermemory-nudge-* and supermemory-context-*.

OpenCode validates part IDs and expects them to start with prt_. Because of that, any prompt could fail before sending with:

ZodError: Invalid string: must start with "prt"

What changed

  • Exported generatePartId() from src/services/compaction.ts
  • Reused generatePartId() for the synthetic nudge part in src/index.ts
  • Reused generatePartId() for the synthetic context part in src/index.ts

Why this approach

The plugin already has a canonical helper for generating valid part IDs. Reusing that helper keeps ID generation consistent across hook-injected and storage-injected parts, and avoids duplicating format knowledge in multiple places.

Verification

  • bun run typecheck
  • bun run build

Repro

Before this patch, enabling opencode-supermemory could cause a prompt like "你好" to fail during message creation in OpenCode with a schema validation error on parts[].id.

After this patch, the same prompt succeeds and the plugin continues to inject memory context normally.

@gragragrab
Copy link

Checked and it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants