Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(memory): local engine embeds through Ollama's native API and chats via BYOK

M3gA-Mind376fa50a7ab4
diff --git a/scripts/memory-scenarios/cortexdb/docker-compose.yml b/scripts/memory-scenarios/cortexdb/docker-compose.yml
index 42285adf61..22d2fa0ec5 100644
--- a/scripts/memory-scenarios/cortexdb/docker-compose.yml
+++ b/scripts/memory-scenarios/cortexdb/docker-compose.yml
@@ -18,7 +18,7 @@ services:
environment:
CORTEX_API_KEY: ${MEMSCEN_CORTEX_KEY:?set by run.mjs}
CORTEX_DEPLOYMENT_PRESET: dev_local
- CORTEX_EMBEDDING_URL: ${CORTEX_INFERENCE_URL:?set by run.mjs}
+ CORTEX_EMBEDDING_URL: ${CORTEX_EMBEDDING_URL:-${CORTEX_INFERENCE_URL:?set by run.mjs}}
CORTEX_EMBEDDING_API_KEY: ${CORTEX_INFERENCE_KEY:-ollama}
OPENAI_API_KEY: ${CORTEX_INFERENCE_KEY:-ollama}
CORTEX_EMBEDDING_MODEL: ${CORTEX_EMBEDDING_MODEL:-nomic-embed-text}
diff --git a/scripts/memory-scenarios/engines.mjs b/scripts/memory-scenarios/engines.mjs
index 1dc6895715..63a658ab12 100644
--- a/scripts/memory-scenarios/engines.mjs
+++ b/scripts/memory-scenarios/engines.mjs
@@ -27,6 +27,7 @@ const OLLAMA = process.env.MEMSCEN_OLLAMA_URL || "http://127.0.0.1:11434";
export const OLLAMA_EMBED_MODEL =
process.env.MEMSCEN_EMBED_MODEL || "nomic-embed-text";
export const OLLAMA_EMBED_DIMS = process.env.MEMSCEN_EMBED_DIMS || "768";
+export const OLLAMA_URL = OLLAMA;
export const OLLAMA_CHAT_MODEL =
process.env.MEMSCEN_CHAT_MODEL || "llama3.2:3b";
@@ -90,6 +91,14 @@ export async function startLocalCortex({
MEMSCEN_CORTEX_PORT: String(port),
// From inside the container the host's loopback is host.docker.internal.
CORTEX_INFERENCE_URL: `${OLLAMA.replace("127.0.0.1", "host.docker.internal").replace("localhost", "host.docker.internal")}/v1`,
+ // Embeddings use Ollama's native API at the bare base: CortexDB pins the
+ // provider as `ollama:<model>`, and under /v1 every embedding 404s
+ // ("model not found"), leaving each store waiting for an index that never
+ // comes (408 WAIT_TIMEOUT after 30 s).
+ CORTEX_EMBEDDING_URL: OLLAMA.replace(
+ "127.0.0.1",
+ "host.docker.internal",
+ ).replace("localhost", "host.docker.internal"),
CORTEX_EMBEDDING_MODEL: OLLAMA_EMBED_MODEL,
CORTEX_EMBEDDING_DIMS: OLLAMA_EMBED_DIMS,
CORTEX_CHAT_MODEL: OLLAMA_CHAT_MODEL,
diff --git a/scripts/memory-scenarios/run.mjs b/scripts/memory-scenarios/run.mjs
index 8aeddcbd69..1d4f473f6e 100644
--- a/scripts/memory-scenarios/run.mjs
+++ b/scripts/memory-scenarios/run.mjs
@@ -24,6 +24,8 @@ import {
} from "./lib.mjs";
import {
startLocalCortex,
+ OLLAMA_URL,
+ OLLAMA_CHAT_MODEL,
activeWorkspace,
placeMigrationGuard,
verifyBuiltinUntouched,
@@ -237,6 +239,34 @@ async function runEngine(engine, { opts, runDir, runId, findings, results }) {
},
{ attempts: 20, delayMs: 1000, what: "local CortexDB engine" },
);
+ // The offline local profile cannot use the managed model, so the local
+ // core chats through the same local Ollama (BYOK), set the way the
+ // Settings screen does it and read back: `auth_set_credential` above
+ // activates a user dir whose config wins, and a write that lands before
+ // it is lost (scripts/life-scenarios/run.mjs, "BYOK route").
+ const inferenceUrl = `${OLLAMA_URL}/v1`;
+ await withRetries(
+ async () => {
+ await core.rpc("openhuman.config_update_model_settings", {
+ inference_url: inferenceUrl,
+ api_key: "ollama",
+ default_model: OLLAMA_CHAT_MODEL,
+ });
+ const snap = await core.rpc("openhuman.config_get", {});
+ const cfg = snap?.config ?? {};
+ if (
+ cfg.inference_url !== inferenceUrl ||
+ !(cfg.cloud_providers ?? []).some(
+ (p) => p?.endpoint === inferenceUrl,
+ )
+ )
+ throw new Error(
+ `BYOK route not active yet (inference_url=${cfg.inference_url ?? "unset"})`,
+ );
+ },
+ { attempts: 10, delayMs: 500, what: "local chat route (Ollama)" },
+ );
+ engineResults.inference.chat_route = `BYOK ${inferenceUrl} ${OLLAMA_CHAT_MODEL}`;
// config.toml now lives in the activated user dir: the composio block too.
const { config } = await activeWorkspace(core);
const snap = await core.rpc("openhuman.config_get", {});