supermemoryai/supermemory · error · Error

customId is required — provide a non-empty string to group m

Error message

customId is required — provide a non-empty string to group messages into a single document

What it means

wrapVercelLanguageModel requires options.customId, which groups all messages of a conversation into one Supermemory document. Without it the wrapper cannot attribute streamed LLM exchanges to a memory document.

Source

Thrown at packages/tools/src/vercel/index.ts:130

 * ```
 *
 * @throws {Error} When neither `options.apiKey` nor `process.env.SUPERMEMORY_API_KEY` are set
 * @throws {Error} When supermemory memory retrieval fails and `skipMemoryOnError` is `false`
 */
const wrapVercelLanguageModel = <T extends LanguageModel>(
	model: T,
	options: WrapVercelLanguageModelOptions,
): T => {
	const providedApiKey = options.apiKey ?? process.env.SUPERMEMORY_API_KEY

	if (!providedApiKey) {
		throw new Error(
			"SUPERMEMORY_API_KEY is not set — provide it via `options.apiKey` or set `process.env.SUPERMEMORY_API_KEY`",
		)
	}

	if (!options.customId) {
		throw new Error(
			"customId is required — provide a non-empty string to group messages into a single document",
		)
	}

	const ctx = createSupermemoryContext({
		containerTag: options.containerTag,
		apiKey: providedApiKey,
		customId: options.customId,
		verbose: options.verbose ?? false,
		mode: options.mode ?? "profile",
		addMemory: options.addMemory ?? "always",
		baseUrl: options.baseUrl,
		includeToolCalls: options.includeToolCalls ?? false,
		promptTemplate: options.promptTemplate,
		memoryRetrievalTimeoutMs: DEFAULT_MEMORY_RETRIEVAL_TIMEOUT_MS,
	})

	const skipMemoryOnError = options.skipMemoryOnError ?? true

View on GitHub (pinned to d436792e77)

Solutions

  1. Pass a stable customId per conversation (chat/session id)
  2. Generate crypto.randomUUID() when a conversation starts and reuse it for its lifetime
  3. Validate options once at module init so failures surface at boot, not mid-request

Example fix

// before
wrapVercelLanguageModel(model, { apiKey })

// after
wrapVercelLanguageModel(model, { apiKey, customId: chatId ?? crypto.randomUUID() })
Defensive patterns

Strategy: validation

Validate before calling

if (!options?.customId) throw new TypeError('customId required')

Prevention

When it happens

Trigger: Calling wrapVercelLanguageModel(model, { apiKey }) (or with containerTag only) with customId missing/empty.

Common situations: Adapting examples that predate the customId requirement; deriving customId from an optional chat id that is undefined on first message.

Related errors


AI-assisted analysis of supermemoryai/supermemory@d436792e77 (2026-08-28). Data as JSON: /api/errors/37eb74a9acb44fcc. Report an issue: GitHub.