supermemoryai/supermemory · error · Error

Supermemory profile search failed: ${response.status} ${resp

Error message

Supermemory profile search failed: ${response.status} ${response.statusText}. ${errorText}

What it means

supermemoryProfileSearch in the OpenAI middleware throws when the POST to Supermemory's profile-search endpoint returns a non-OK HTTP status, embedding the status, status text, and response body in the message.

Source

Thrown at packages/tools/src/openai/middleware.ts:121

				containerTag: containerTag,
			})
		: JSON.stringify({
				containerTag: containerTag,
			})

	try {
		const response = await fetch(`${baseUrl}/v4/profile`, {
			method: "POST",
			headers: {
				"Content-Type": "application/json",
				Authorization: `Bearer ${apiKey}`,
			},
			body: payload,
		})

		if (!response.ok) {
			const errorText = await response.text().catch(() => "Unknown error")
			throw new Error(
				`Supermemory profile search failed: ${response.status} ${response.statusText}. ${errorText}`,
			)
		}

		return await response.json()
	} catch (error) {
		if (error instanceof Error) {
			throw error
		}
		throw new Error(`Supermemory API request failed: ${error}`)
	}
}

/**
 * Adds memory-enhanced system prompts to chat completion messages.
 *
 * Searches for relevant memories based on the specified mode and injects them
 * into the conversation. If a system prompt already exists, memories are appended

View on GitHub (pinned to d436792e77)

Solutions

  1. Read the embedded status code and errorText to classify the failure
  2. Verify SUPERMEMORY_API_KEY is valid and has the right scope
  3. Check for payload/filter schema changes in the Supermemory API changelog
  4. Add retry with backoff for 429/5xx and degrade gracefully to non-memory completion

Example fix

// before
const memories = await supermemoryProfileSearch(payload)

// after
let memories
try {
  memories = await supermemoryProfileSearch(payload)
} catch {
  memories = { results: [] } // degrade to no-memory completion
}
Defensive patterns

Strategy: fallback

Try / catch

let memories; try { memories = await supermemoryProfileSearch(payload) } catch (e) { logger.warn('memory search failed', e); memories = { results: [] } } // proceed without memories

Prevention

When it happens

Trigger: The middleware issuing a profile search before chat completion and receiving 401 (bad API key), 400 (bad payload/filter), 429 (rate limit), or 5xx from the Supermemory API.

Common situations: Expired or wrong-scoped API key; invalid filter payload in newer API versions; hitting rate limits under load; regional endpoint outage.

Related errors


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