Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
fix(codex): configure recall compressor base URL (#3601)
Tequila Sunset9042a0254f92
diff --git a/examples/codex-memory-plugin/DESIGN.md b/examples/codex-memory-plugin/DESIGN.mdindex dccd9c128..19254cb19 100644--- a/examples/codex-memory-plugin/DESIGN.md+++ b/examples/codex-memory-plugin/DESIGN.md@@ -253,6 +253,7 @@ Env var overrides for tuning without rebuilding:| `OPENVIKING_RECALL_COMPRESS` | `1` | set `0` / `off` to skip `codex exec` compression || `OPENVIKING_RECALL_COMPRESS_MODEL` | unset | custom first-choice compressor model; `off` disables compression || `OPENVIKING_RECALL_COMPRESS_THINKING` | unset | custom `model_reasoning_effort`; `default` means omit override; alias `OPENVIKING_RECALL_COMPRESS_REASONING_EFFORT` |+| `OPENVIKING_RECALL_COMPRESS_BASE_URL` | unset | custom API base URL for the nested `codex exec` compressor || `OPENVIKING_RECALL_COMPRESS_DETECT_ON_STARTUP` | `1` | recreate/cache compressor profile during every `SessionStart` || `OPENVIKING_RECALL_COMPRESS_DETECT_TIMEOUT_MS` | `15000` | per-candidate compressor probe timeout || `OPENVIKING_RECALL_COMPRESS_DETECT_TTL_MS` | `604800000` (7 days) | cache TTL used by `UserPromptSubmit` reads |@@ -285,6 +286,20 @@ both:codex -m <model> -c 'model_reasoning_effort="low"' exec ...```+The compressor runs with `--ignore-user-config`, so it does not inherit the+main Codex process's provider table. When+`OPENVIKING_RECALL_COMPRESS_BASE_URL` is set, the plugin adds an isolated+provider for the nested request:++```bash+-c 'model_provider="openviking_compressor"' \+-c 'model_providers.openviking_compressor.name="openviking_compressor"' \+-c 'model_providers.openviking_compressor.base_url="<url>"'+```++The selected model and thinking effort remain profile data; the base URL is+runtime configuration and is supplied when the command is built.+`thinking=default` omits the `model_reasoning_effort` override. This isimportant for model families whose default effort is tuned by Codex.diff --git a/examples/codex-memory-plugin/README.md b/examples/codex-memory-plugin/README.mdindex e180652c5..849eab33d 100644--- a/examples/codex-memory-plugin/README.md+++ b/examples/codex-memory-plugin/README.md@@ -129,6 +129,7 @@ export OPENVIKING_RECALL_LIMIT=10export OPENVIKING_RECALL_COMPRESS=1export OPENVIKING_RECALL_COMPRESS_MODEL=gpt-5.3-codex-sparkexport OPENVIKING_RECALL_COMPRESS_THINKING=default+export OPENVIKING_RECALL_COMPRESS_BASE_URL=https://api.example.com/v1export OPENVIKING_RECALL_TIMEOUT_MS=120000export OPENVIKING_CAPTURE_ASSISTANT_TURNS=1export OPENVIKING_AUTO_COMMIT_ON_COMPACT=1@@ -226,6 +227,7 @@ Config knobs:| `OPENVIKING_RECALL_COMPRESS` | `1` | Set `0` / `off` to disable `codex exec` compression. || `OPENVIKING_RECALL_COMPRESS_MODEL` | unset | Custom first-choice compressor model. Set `off` to disable compression. || `OPENVIKING_RECALL_COMPRESS_THINKING` | unset | Custom `model_reasoning_effort`; `default` omits the Codex config override. Alias: `OPENVIKING_RECALL_COMPRESS_REASONING_EFFORT`. |+| `OPENVIKING_RECALL_COMPRESS_BASE_URL` | unset | Base URL for the nested compressor's provider. Use this when `--ignore-user-config` prevents the compressor from reading the main Codex provider configuration. || `OPENVIKING_RECALL_COMPRESS_DETECT_ON_STARTUP` | `1` | Recreate/cache compressor profile in `SessionStart`. || `OPENVIKING_RECALL_COMPRESS_DETECT_TIMEOUT_MS` | `15000` | Per-candidate startup probe timeout. || `OPENVIKING_RECALL_COMPRESS_DETECT_TTL_MS` | `604800000` | Cache TTL used by `UserPromptSubmit` when reading the latest profile. |diff --git a/examples/codex-memory-plugin/scripts/auto-recall.mjs b/examples/codex-memory-plugin/scripts/auto-recall.mjsindex 8489e6124..2fd0d9360 100644--- a/examples/codex-memory-plugin/scripts/auto-recall.mjs+++ b/examples/codex-memory-plugin/scripts/auto-recall.mjs@@ -421,7 +421,7 @@ async function getRecallCompressorProfile() {async function runCodexCompressor(prompt, profile) {const tmp = await mkdtemp(join(tmpdir(), "ov-recall-compress-"));const outputPath = join(tmp, "last-message.txt");- const args = buildCodexExecArgs(profile, outputPath);+ const args = buildCodexExecArgs(profile, outputPath, cfg);try {return await new Promise((resolve) => {diff --git a/examples/codex-memory-plugin/scripts/auto-recall.test.mjs b/examples/codex-memory-plugin/scripts/auto-recall.test.mjsindex 1242c277d..1273b5f44 100644--- a/examples/codex-memory-plugin/scripts/auto-recall.test.mjs+++ b/examples/codex-memory-plugin/scripts/auto-recall.test.mjs@@ -117,6 +117,7 @@ async function withFakeCodex(output, fn, { exitCode = 0 } = {}) {"codex.js",);const callLog = join(binDir, "calls.log");+ const argsLog = join(binDir, "args.log");const fakeCodex = `#!/usr/bin/env nodeconst fs = require("node:fs");@@ -124,6 +125,7 @@ const outputFlagIndex = process.argv.indexOf("--output-last-message");const outputPath = outputFlagIndex >= 0 ? process.argv[outputFlagIndex + 1] : "";fs.readFileSync(0);fs.appendFileSync(process.env.FAKE_CODEX_CALL_LOG, "called\\n");+fs.appendFileSync(process.env.FAKE_CODEX_ARGS_LOG, process.argv.slice(2).join("\\n") + "\\n");const exitCode = Number(process.env.FAKE_CODEX_EXIT_CODE || 0);if (exitCode !== 0) process.exit(exitCode);@@ -137,9 +139,11 @@ fs.writeFileSync(outputPath, process.env.FAKE_CODEX_OUTPUT || "");try {return await fn({callLog,+ argsLog,env: {PATH: `${binDir}${delimiter}${process.env.PATH}`,FAKE_CODEX_CALL_LOG: callLog,+ FAKE_CODEX_ARGS_LOG: argsLog,FAKE_CODEX_EXIT_CODE: String(exitCode),FAKE_CODEX_OUTPUT: output,},@@ -160,7 +164,7 @@ async function runEndpointCompressionCase({const stateDir = await mkdtemp(join(tmpdir(), "ov-auto-recall-endpoint-compress-"));let requestBody = null;try {- return await withFakeCodex(compressorOutput, async ({ callLog, env }) => {+ return await withFakeCodex(compressorOutput, async ({ callLog, argsLog, env }) => {const result = await withMockOpenViking(async (req, res) => {const url = new URL(req.url, "http://127.0.0.1");if (req.method === "GET" && url.pathname === "/health") {@@ -197,9 +201,11 @@ async function runEndpointCompressionCase({},));const compressorCallLog = await readFile(callLog, "utf-8").catch(() => "");+ const compressorArgs = await readFile(argsLog, "utf-8").catch(() => "");return {output: JSON.parse(result.stdout.trim()),compressorCalls: compressorCallLog.trim().split("\n").filter(Boolean).length,+ compressorArgs: compressorArgs.trim().split("\n").filter(Boolean),requestBody,};}, { exitCode });@@ -382,6 +388,26 @@ test("auto-recall applies the relevance compressor to server recall entries", asassert.equal(result.requestBody.max_chars, 18000);});+test("auto-recall passes the configured compressor base URL to Codex", async () => {+ const result = await runEndpointCompressionCase({+ prompt: "Explain HTTP 429",+ entry: {+ uri: "viking://user/zeus/memories/events/retry.md",+ score: 0.91,+ type: "events",+ mode: "summary",+ summary: "Retry with backoff",+ },+ rendered: "<memory_group>Retry with backoff</memory_group>",+ compressorOutput: "NO_RELEVANT_MEMORY",+ extraEnv: { OPENVIKING_RECALL_COMPRESS_BASE_URL: "https://compressor.example/v1" },+ });++ assert.ok(result.compressorArgs.includes('model_provider="openviking_compressor"'));+ assert.ok(result.compressorArgs.includes('model_providers.openviking_compressor.name="openviking_compressor"'));+ assert.ok(result.compressorArgs.includes('model_providers.openviking_compressor.base_url="https://compressor.example/v1"'));+});+test("auto-recall falls back to a bounded deterministic digest when endpoint compression fails", async () => {const result = await runEndpointCompressionCase({prompt: "Which editor do I prefer?",diff --git a/examples/codex-memory-plugin/scripts/config.mjs b/examples/codex-memory-plugin/scripts/config.mjsindex b8e393d57..477416b41 100644--- a/examples/codex-memory-plugin/scripts/config.mjs+++ b/examples/codex-memory-plugin/scripts/config.mjs@@ -34,6 +34,7 @@* OPENVIKING_TIMEOUT_MS, OPENVIKING_CAPTURE_TIMEOUT_MS* OPENVIKING_RECALL_TIMEOUT_MS, OPENVIKING_RECALL_COMPRESS_TIMEOUT_MS* OPENVIKING_RECALL_COMPRESS_MODEL, OPENVIKING_RECALL_COMPRESS_THINKING+ * OPENVIKING_RECALL_COMPRESS_BASE_URL* OPENVIKING_RECALL_LIMIT, OPENVIKING_SCORE_THRESHOLD* OPENVIKING_WORKSPACE_PEER, OPENVIKING_RECALL_PEER_SCOPE* OPENVIKING_NO_AUTO_INJECT, OPENVIKING_PROFILE_TOKEN_BUDGET@@ -139,6 +140,10 @@ export function loadConfig() {process.env.OPENVIKING_RECALL_COMPRESS_MODEL,hasOwn(cx, "recallCompressModel") ? str(cx.recallCompressModel, "") : "",);+ const recallCompressBaseUrl = str(+ process.env.OPENVIKING_RECALL_COMPRESS_BASE_URL,+ hasOwn(cx, "recallCompressBaseUrl") ? str(cx.recallCompressBaseUrl, "") : "",+ );const cxRecallCompressThinking = hasOwn(cx, "recallCompressThinking")? cx.recallCompressThinking: (hasOwn(cx, "recallCompressReasoningEffort") ? cx.recallCompressReasoningEffort : "");@@ -186,6 +191,7 @@ export function loadConfig() {recallPeerScope,recallCompress: envBool("OPENVIKING_RECALL_COMPRESS") ?? configBool(cx.recallCompress, true),recallCompressModel,+ recallCompressBaseUrl,recallCompressThinking,recallCompressConfigured: Boolean(recallCompressModel || recallCompressThinking),recallCompressTimeoutMs,diff --git a/examples/codex-memory-plugin/scripts/recall-compressor-profile.mjs b/examples/codex-memory-plugin/scripts/recall-compressor-profile.mjsindex 5e7b32e8f..21e1f0ea6 100644--- a/examples/codex-memory-plugin/scripts/recall-compressor-profile.mjs+++ b/examples/codex-memory-plugin/scripts/recall-compressor-profile.mjs@@ -8,6 +8,7 @@ const DEFAULT_PRIMARY = { model: "gpt-5.3-codex-spark", thinking: "default", souconst DEFAULT_FALLBACK = { model: "gpt-5.6-luna", thinking: "low", source: "default_fallback" };const PROFILE_SCHEMA_VERSION = 3;const DEFAULT_CODEX_HOME = join(homedir(), ".codex");+const COMPRESSOR_PROVIDER = "openviking_compressor";function isOff(value) {return /^(?:0|false|no|off|none|disabled)$/i.test(String(value || "").trim());@@ -27,12 +28,19 @@ export function recallCompressionExplicitlyOff(cfg) {return !cfg.recallCompress || isOff(cfg.recallCompressModel) || isOff(cfg.recallCompressThinking);}-export function buildCodexExecArgs(profile, outputPath) {+export function buildCodexExecArgs(profile, outputPath, cfg = {}) {const args = [];if (profile.model) args.push("-m", profile.model);if (profile.thinking && profile.thinking !== "default") {args.push("-c", `model_reasoning_effort=${JSON.stringify(profile.thinking)}`);}+ if (cfg.recallCompressBaseUrl) {+ args.push(+ "-c", `model_provider=${JSON.stringify(COMPRESSOR_PROVIDER)}`,+ "-c", `model_providers.${COMPRESSOR_PROVIDER}.name=${JSON.stringify(COMPRESSOR_PROVIDER)}`,+ "-c", `model_providers.${COMPRESSOR_PROVIDER}.base_url=${JSON.stringify(cfg.recallCompressBaseUrl)}`,+ );+ }args.push("--sandbox","read-only",diff --git a/examples/codex-memory-plugin/scripts/recall-compressor-profile.test.mjs b/examples/codex-memory-plugin/scripts/recall-compressor-profile.test.mjsindex 2ea21a1f3..2101a0112 100644--- a/examples/codex-memory-plugin/scripts/recall-compressor-profile.test.mjs+++ b/examples/codex-memory-plugin/scripts/recall-compressor-profile.test.mjs@@ -5,6 +5,7 @@ import { join } from "node:path";import test from "node:test";import {+ buildCodexExecArgs,detectRecallCompressorProfile,invalidateRecallCompressorProfileCache,loadCachedRecallCompressorProfile,@@ -50,6 +51,31 @@ async function writeModelsCache(codexHome, slugs) {);}+test("buildCodexExecArgs injects a configured compressor base URL", () => {+ const args = buildCodexExecArgs(+ { model: "gpt-5.3-codex-spark", thinking: "default" },+ "/tmp/last-message.txt",+ { recallCompressBaseUrl: "https://compressor.example/v1" },+ );++ assert.deepEqual(args.slice(0, 8), [+ "-m", "gpt-5.3-codex-spark",+ "-c", 'model_provider="openviking_compressor"',+ "-c", 'model_providers.openviking_compressor.name="openviking_compressor"',+ "-c", 'model_providers.openviking_compressor.base_url="https://compressor.example/v1"',+ ]);+ assert.ok(args.indexOf("exec") > args.indexOf('model_providers.openviking_compressor.base_url="https://compressor.example/v1"'));+});++test("buildCodexExecArgs preserves the existing command without a compressor base URL", () => {+ const args = buildCodexExecArgs(+ { model: "gpt-5.3-codex-spark", thinking: "default" },+ "/tmp/last-message.txt",+ );++ assert.equal(args.some((arg) => arg.includes("openviking_compressor")), false);+});+test("loadCodexModelsCache returns empty set when cache missing", async () => {await withTempState(async ({ codexHome }) => {const result = await loadCodexModelsCache({ CODEX_HOME: codexHome });