MemorySync
SDKs

Production Patterns

Use a small set of repeatable rules for scope, failures, observability, and model safety. These rules apply whether you call MemorySync from Python, Node.js, or direct HTTPS.

Build every request from trusted state

Trusted request path
  1. 01

    Authenticate

    Verify the user and action in your own application.

  2. 02

    Resolve scope

    Select the project and stable opaque end-user ID on the server.

  3. 03

    Call

    Use the matching client with credentials loaded from a secret store.

  4. 04

    Inspect

    Branch on the documented result or typed error.

  5. 05

    Return

    Expose only fields your application authorizes.

Treat interrupted writes as uncertain

A write timed out or lost its response. What next?

You received a documented success response

The SDK returned a created, skipped, updated, or deleted result.

Use: Use that operation-specific result.

The server rejected the request

Authentication, validation, or not-found failures need correction or a user-facing state.

Use: Do not retry the same request unchanged.

The result is unknown

A timeout or network failure does not prove whether the server applied a mutation.

Use: Reconcile through a safe read before repeating the write.

Classify failures before retrying

Failure decisions
401 / 403
Fix access

Correct the credential, session, permission, or selected scope.

400 / 409 / 422
Fix input

Correct fields or state; do not retry unchanged.

404
Unavailable in scope

Show a normal unavailable state without revealing other scopes.

429
Wait when directed

Use the typed retry delay when present and bound attempts.

5xx
Recover carefully

Reads can be retried with bounded backoff; reconcile uncertain writes.

Network
Outcome may be unknown

Keep the product state recoverable and avoid blind write retries.

Log enough, but not secrets

LogAvoid
Operation name, safe application correlation ID, status class, latencyAPI keys, bearer tokens, passwords, refresh tokens
Server request ID when the error provides oneRaw memory text or complete response bodies by default
Project alias or internal safe identifier when policy permitsEmail addresses or arbitrary end-user identifiers
Retry attempt and final outcomeWebhook secrets or credential-bearing URLs

Treat retrieved memory as untrusted data

Prompt boundary

Trusted instructions

Owned by your application.

  • System policy.
  • Tool authorization.
  • Output and safety rules.

Retrieved memory

May contain user-controlled text.

  • Delimit it as context.
  • Select only relevant records.
  • Never let it override trusted instructions.

Production checklist

  • Keep every credential in trusted server code.
  • Test that one project or end user cannot access another scope.
  • Branch on created and skipped Add responses.
  • Bound read retries and reconcile uncertain mutations.
  • Close clients deterministically where the language provides lifecycle hooks.
  • Review logs, exports, deletion, token handling, and support escalation before launch.

Language-specific implementation

Was this page helpful?