Repository navigation
Description
Problem
Beta/dev users can fail ChatGPT/Claude memory imports after pasting an export response into Omi. The UI reports that durable memories could not be created / extracted, but the root cause is usually the write phase: onboarding/import paths fan out many individual POST /v3/memories writes.
This can exceed the backend memories:create limiter and also creates Firestore ledger transaction contention.
Evidence from beta/dev investigation
Project: based-hardware-dev
Cloud Run service: backend
Observed revision label: backend-03eb3ac-1 (03eb3ace...)
One affected burst from a beta client/IP between 2026-07-01T17:00:00Z and 18:00:00Z:
POST /v3/memories total: 435
200 OK: 59
503: 32
429: 344
Minute breakdown:
17:33 43 OK, 32 503, 90 429
17:34 12 OK, 181 429
17:35 3 OK, 21 429
17:39–17:41 repeated 429s
Sampled /v3/memories beta traffic for the day:
200: 931
429: 658
503: 43
Relevant backend policy:
# backend/utils/rate_limit_config.py
"memories:create": (60, 3600)
"memories:batch": (30, 3600)Representative 503 root cause in logs:
google.api_core.exceptions.Aborted: 409 Aborted due to cross-transaction contention
ValueError: Failed to commit transaction in 5 attempts.
ERROR:routers.memories:Firestore create_memory failed uid=...
Also observed non-blocking vector failures after successful memory saves:
Pinecone 400: Metadata value must be a string, number, boolean or list of strings,
got 'null' for field 'source_commit_id'
ERROR:routers.memories:Vector upsert failed ... (memory saved, vector missing)
Code paths to fix
ChatGPT / Claude memory-log import
desktop/macos/Desktop/Sources/OnboardingMemoryLogImportService.swift
Current behavior:
- Extracts
memoryStringsfrom the pasted ChatGPT/Claude memory log. - Loops over each memory.
- Calls
APIClient.shared.createMemory(...)once per memory.
This should use APIClient.shared.createMemoriesBatch(...) with MemoryBatchItem chunks.
Other onboarding/import paths that still fan out writes
Audit and batch/pacing candidates:
desktop/macos/Desktop/Sources/AppleNotesReaderService.swift- synthesized profile memories
- raw note memories via concurrent
saveAsMemories
desktop/macos/Desktop/Sources/GmailReaderService.swift- synthesized profile memories
- raw email memories via concurrent
saveAsMemories
desktop/macos/Desktop/Sources/CalendarReaderService.swift- synthesized profile memories
- raw event memories via concurrent
saveAsMemories
desktop/macos/Desktop/Sources/ProactiveAssistants/Assistants/MemoryExtraction/MemoryAssistant.swift- may need pacing/backoff rather than batching depending on UX expectations
desktop/macos/Desktop/Sources/ProactiveAssistants/Assistants/Focus/FocusAssistant.swiftdesktop/macos/Desktop/Sources/ProactiveAssistants/Assistants/Insight/InsightAssistant.swift
Positive reference path:
desktop/macos/Desktop/Sources/OnboardingPagedIntroCoordinator.swiftimportLocalFileMemoriesalready chunks throughPOST /v3/memories/batchwithAPIClient.memoriesBatchMaxSize.
UX issues
The user-facing error conflates several failure modes:
- The pasted ChatGPT/Claude response contained no usable durable memories.
- Extraction succeeded, but saving memories was rate-limited (
429). - Extraction succeeded, but saving memories failed due to temporary backend/Firestore contention (
503). - Partial success: some memories were created, then later writes failed.
Recommended UX improvements:
- Show a distinct message for “no durable memories found in the pasted response.”
- Show retry/backoff guidance for rate limit or temporary server errors.
- If partial success occurs, show how many memories were saved and offer retry for the remainder instead of treating the whole import as failed.
- Log/track structured error reason (
extraction_empty,save_rate_limited,save_transient,partial_success) so product/support can distinguish these cases.
Proposed implementation
- Add a helper for batching memory strings into
MemoryBatchItemchunks, usingAPIClient.memoriesBatchMaxSize. - Convert ChatGPT/Claude memory-log import to batch writes first.
- Convert Apple Notes / Gmail / Calendar onboarding imports to batch writes where possible.
- For ongoing proactive assistant writes, add paced/retry behavior if batching is not semantically appropriate.
- Preserve tags/headline/category/visibility/source metadata where supported; if
sourceis needed in batch items, extend the batch request/model deliberately rather than silently dropping it. - Handle partial batch failures with retry/backoff and explicit user feedback.
Acceptance criteria
- ChatGPT/Claude memory-log import creates extracted memories through
/v3/memories/batch, not N individual/v3/memoriesrequests. - Onboarding import flows no longer generate bursts that can hit
memories:createduring normal use. - Firestore transaction contention from concurrent onboarding memory writes is materially reduced.
- UI distinguishes extraction-empty vs save-failed vs partial-success cases.
- Regression test or focused harness covers at least the ChatGPT/Claude import path and asserts batched API usage.
- Pinecone vector metadata upsert no longer sends
nullmetadata values such assource_commit_id: null.
Non-goal for now
Do not raise backend rate limits unless we see sustained pressure after batching ships.
Activity
Batch onboarding memory imports (#8762)