[superlog] Fix supermemory container tag format in storeAnalyticsSummary#476
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
The latest updates on your projects. Learn more about Unkey Deploy
|
Greptile SummaryThis PR fixes an active
Confidence Score: 3/5The write-side fix is correct and resolves the immediate 400 error, but the analytics summary feature remains end-to-end broken because stored summaries land in a container the AI never reads from. The two-line change correctly repairs the supermemory API call, but stored summaries go into a website_* container while every retrieval path exclusively queries user- and apikey-scoped containers. Additionally, the colon-format tags still used by primaryContainerTag on the live read path may be causing silent failures on all memory retrievals. packages/ai/src/lib/supermemory.ts — specifically the container tag used in storeAnalyticsSummary versus those queried by getMemoryContext and searchMemories, and the colon-format tags still produced by buildContainerTags and primaryContainerTag. Important Files Changed
Sequence DiagramsequenceDiagram
participant Insights as apps/insights generation.ts
participant Store as storeAnalyticsSummary
participant SM as Supermemory API
participant Agent as AI Agent
participant Read as getMemoryContext / searchMemories
Note over Insights,SM: Write path (after this fix)
Insights->>Store: summary, site.id
Store->>SM: client.add containerTag website_siteId
SM-->>Store: 200 OK
Note over Agent,SM: Read path (unchanged)
Agent->>Read: query, userId, apiKeyId
Read->>SM: containerTag user_userId or apikey_apiKeyId
SM-->>Read: results from user/apikey container
Read-->>Agent: memories — analytics summaries never returned
Note over Store,Read: Mismatch — writes go to website_* container, reads query user:* / apikey:* containers only
|
| content: summary, | ||
| containerTags: [`website:${websiteId}`], | ||
| content: sanitizeMemoryContent(summary), | ||
| containerTag: `website_${websiteId}`, |
There was a problem hiding this comment.
Analytics summaries stored in unreachable container
storeAnalyticsSummary now writes into container website_${websiteId}, but every read path — getMemoryContext (line 80) and searchMemories (line 223) — uses primaryContainerTag(userId, apiKeyId) which only ever returns user:${userId}, apikey:${apiKeyId}, or "anonymous". No call site ever queries a website_*-prefixed container, so the summaries generated by apps/insights/src/generation.ts are stored successfully but will never be surfaced in AI responses. The feature is still functionally inert, just silently so instead of erroring.
izadoesdev
left a comment
There was a problem hiding this comment.
Reviewed against staging. The SDK shape part looks directionally right: containerTag is the current Supermemory field and website_${websiteId} fits the documented tag constraints. I am holding this unmerged for two blockers/risks:
- CI is red:
Insights Health Checkis failing. The failing Docker build cannot resolve@databuddy/sdk/nodefrompackages/ai/src/lib/databuddy.ts, so this needs a rebase/update and a clean rerun before merge. - The PR fixes the write-side 400 by storing analytics summaries under
containerTag: website_${websiteId}, but the read paths still query user/API-key containers (getMemoryContext/searchMemories). If these summaries are intended to be retrieved later by the assistant, this may make writes succeed while leaving the summaries effectively unreachable.
Suggested follow-up before landing: rebase on current staging, clear the health check, and add/adjust a focused test around the storeAnalyticsSummary add payload and retrieval expectations.
izadoesdev
left a comment
There was a problem hiding this comment.
Fixed the requested behavior gap: analytics summaries stay in the website-scoped website_<id> Supermemory container, and memory loading/search now also reads that website container alongside the primary user/API-key container. I also centralized tag construction to underscore-form tags, threaded websiteId through MCP memory loading/tools, and made search results carry their source containerTag so forget deletes from the correct container. Added focused coverage in packages/ai/src/lib/supermemory.test.ts. Verification: cd packages/ai && bun test src/lib/supermemory.test.ts, cd packages/ai && bun run check-types, bun run lint, bun run check-types, and pre-push full bun run test all pass. Approving for staging merge.
Summary
The
storeAnalyticsSummaryfunction inpackages/ai/src/lib/supermemory.tswas callingclient.add()with two invalid parameters, causing every weekly analytics summary write to fail with a400error from the supermemory API:Root cause: The function used
containerTags: ['website:${websiteId}']— the deprecated plural-array parameter (SDK v4 replaced this with singularcontainerTag: string) — and the value contained a colon (:) which violates the API's documented constraint of alphanumeric/hyphens/underscores/dots only. With an invalid/ignored container tag the server falls back to URL extraction on the plain-text content and fails.Fix: Migrate to
containerTag: \website_${websiteId}`(singular string, underscore separator) and applysanitizeMemoryContent()to stay within the 2 000-char content limit. The other memory helpers (storeConversation,saveCuratedMemory`) have the same colon-in-tag pattern but swallow errors silently — those can be migrated in a follow-up.Incident on Superlog
Was this PR helpful? Leave feedback — goes straight to the Superlog team.
Summary by cubic
Fixes weekly analytics summary writes by using the correct
containerTagformat and content sanitization. Also makes memory reads website-aware by querying both primary and website containers and passingwebsiteIdend-to-end.containerTag: website_${websiteId}andsanitizeMemoryContent(summary)instoreAnalyticsSummary.getMemoryContext/searchMemoriesquery primary + website containers, dedupe, keepcontainerTag; propagatewebsiteIdthrough agent and tools.Written for commit 8b5335d. Summary will update on new commits.