supermemoryai/supermemory · error · Error

containerTag is required — provide a non-empty string to ide

Error message

containerTag is required — provide a non-empty string to identify the user/container

What it means

The OpenAI middleware's withSupermemory requires options.containerTag because memories are scoped per user/container on Supermemory's side. An empty/missing containerTag means the middleware cannot attribute conversations to a user.

Source

Thrown at packages/tools/src/openai/index.ts:71

 * // Use with Responses API - memories injected into instructions
 * const response = await openaiWithSupermemory.responses.create({
 *   model: "gpt-4o",
 *   instructions: "You are a helpful coding assistant",
 *   input: "What's my favorite programming language?"
 * })
 * ```
 *
 * @throws {Error} When neither `options.apiKey` nor `process.env.SUPERMEMORY_API_KEY` are set
 * @throws {Error} When supermemory API request fails
 */
export function withSupermemory(
	openaiClient: OpenAI,
	options: OpenAIMiddlewareOptions,
) {
	validateApiKey(options.apiKey)

	if (!options.containerTag) {
		throw new Error(
			"containerTag is required — provide a non-empty string to identify the user/container",
		)
	}

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

	const { containerTag } = options
	const verbose = options.verbose ?? false
	const mode = options.mode ?? "profile"
	const addMemory = options.addMemory ?? "always"

	const openaiWithSupermemory = createOpenAIMiddleware(
		openaiClient,
		containerTag,

View on GitHub (pinned to d436792e77)

Solutions

  1. Provide a non-empty containerTag identifying the user/tenant, e.g. 'user-<id>' or 'org-<id>'
  2. Derive containerTag from your auth session so it is never empty
  3. Add a startup assertion validating all required options

Example fix

// before
withSupermemory(openai, { customId: 'chat-1', apiKey })

// after
withSupermemory(openai, {
  containerTag: `user-${session.userId}`,
  customId: 'chat-1',
  apiKey,
})
Defensive patterns

Strategy: validation

Validate before calling

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

Prevention

When it happens

Trigger: Calling withSupermemory(openai, { customId, apiKey }) without containerTag, or passing containerTag: '' / undefined.

Common situations: Copy-pasting a minimal example that omitted containerTag; dynamically computing containerTag from user data that is sometimes empty.

Related errors


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