Tuning

Models per stage

Configure which LLM is used for each processing stage in SurrealDB Agent Memory.

SurrealDB Agent Memory’s pipeline uses separate LLM stages with different latency and quality needs. Assign a model per stage rather than one model for everything. Embeddings are fixed deployment-wide.

For provider keys and Gemini defaults, see Configuration.

Runs on conversational turns and document jobs. Classifies content and extracts entities, attributes, relations, instructions, and uncertainties. Often on the critical path for /facts?infer=full, so latency matters.

Optional LLM assist when structural entity merge is inconclusive. Not every write invokes it.

Powers /chat and /reflect answer generation from retrieved context. Quality usually matters more than on extraction.

Background “dreaming” work on the worker tier: elaboration and consolidation passes. Not on the user-facing critical path.

Converts text (and multimodal content) into dense vectors for HNSW retrieval and the semantic cache. Fixed to gemini-embedding-2 at 3072 dimensions. Not freely assignable per Context - Context config may only pin that same model id. Vector reads filter by embedding_model_id. After changing the deployment embedding model, run a reindex.

Model assignment is per-Context. Each LLM stage takes {provider, model}:

PATCH /api/v1/contexts/{context_id}
Content-Type: application/json

{
  "config": {
    "models": {
      "extraction": { "provider": "google", "model": "gemini-2.5-flash" },
      "synthesis": { "provider": "anthropic", "model": "claude-sonnet-4" },
      "elaboration_consolidation": { "provider": "google", "model": "gemini-2.5-flash" },
      "embedding": "gemini-embedding-2"
    }
  }
}

Omit any stage to leave the current assignment (or deployment default) unchanged. Missing provider keys for a selected provider fail at configuration time rather than silently re-routing.

ProviderRole
Google (Gemini)LLM stages; required for embeddings
OpenAILLM stages
AnthropicLLM stages

Provider keys may be set deployment-wide (SPECTRON_PROVIDER_*) or per Context. Keys are write-only on the API; reads return which providers are configured, not the secrets.

StageTypical pathPrefer
extractionSync on write / ingestFast, inexpensive model
reconciliationOccasional on writeFast or mid-tier
synthesis/chat, /reflectMore capable when answer quality matters
elaboration_consolidationWorker backgroundFast enough for batch work
embeddingIngest + queryFixed: gemini-embedding-2 (3072-dim)

A common pattern is a cheap model for extraction and a stronger model for synthesis only.

Embeddings are Gemini-only at 3072 dimensions. Switching the deployment embedding model requires a reindex so stored vectors and query vectors share one space. See Management API - force reindex.

Was this page helpful?