Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion open-sse/config/cliFingerprints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ export const CLI_FINGERPRINTS: Record<string, CliFingerprint> = {
"instructions",
"store",
"reasoning",
"prompt_cache_key",
"tools",
"tool_choice",
"include",
"service_tier",
"prompt_cache_key",
"client_metadata",
"parallel_tool_calls",
"metadata",
Expand Down
11 changes: 9 additions & 2 deletions open-sse/mcp-server/tools/memoryTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { z } from "zod";
import { retrieveMemories } from "@/lib/memory/retrieval";
import { createMemory, deleteMemory, listMemories } from "@/lib/memory/store";
import { MemoryType } from "@/lib/memory/types";
import { getMemorySettings, toMemoryRetrievalConfig, DEFAULT_MEMORY_SETTINGS } from "@/lib/memory/settings";
import {
getMemorySettings,
toMemoryRetrievalConfig,
DEFAULT_MEMORY_SETTINGS,
} from "@/lib/memory/settings";

export const MemorySearchSchema = z.object({
apiKeyId: z.string(),
Expand Down Expand Up @@ -44,7 +48,10 @@ export const memoryTools = {

const config = {
...baseConfig,
maxTokens: args.maxTokens || (baseConfig.maxTokens ?? DEFAULT_MEMORY_SETTINGS.maxTokens),
enabled: true,
maxTokens:
args.maxTokens ??
(memorySettings.enabled ? memorySettings.maxTokens : DEFAULT_MEMORY_SETTINGS.maxTokens),
};

const memories = await retrieveMemories(args.apiKeyId, config);
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/memory-pipeline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const harness = await createChatPipelineHarness("memory-pipeline");
// The harness sets DATA_DIR before importing DB modules, so these must resolve after that.
const { extractFactsFromText } = await import("../../src/lib/memory/extraction.ts");
const { retrieveMemories } = await import("../../src/lib/memory/retrieval.ts");
const { invalidateMemorySettingsCache } = await import("../../src/lib/memory/settings.ts");
const { injectMemory, formatMemoryContext } = await import("../../src/lib/memory/injection.ts");
const {
BaseExecutor,
Expand Down Expand Up @@ -45,12 +46,14 @@ function dropFts5Artifacts() {
test.beforeEach(async () => {
BaseExecutor.RETRY_CONFIG.delayMs = 0;
await resetStorage();
invalidateMemorySettingsCache();
dropFts5Artifacts();
});

test.afterEach(async () => {
BaseExecutor.RETRY_CONFIG.delayMs = harness.originalRetryDelayMs;
await resetStorage();
invalidateMemorySettingsCache();
});

test.after(async () => {
Expand Down
36 changes: 36 additions & 0 deletions tests/unit/cli-fingerprints.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import test from "node:test";
import assert from "node:assert/strict";

const { applyFingerprint } = await import("../../open-sse/config/cliFingerprints.ts");

test("Codex CLI fingerprint orders prompt_cache_key before include", () => {
const body = {
model: "gpt-5.5-low",
stream: true,
input: [{ role: "user", content: "hello" }],
instructions: "You are Codex.",
store: false,
reasoning: { effort: "low" },
tools: [],
tool_choice: "auto",
include: ["reasoning.encrypted_content"],
prompt_cache_key: "conv-codex",
service_tier: "priority",
};

const result = applyFingerprint("codex", {}, body);
const orderedKeys = Object.keys(JSON.parse(result.bodyString));

assert.deepEqual(orderedKeys.slice(0, 10), [
"model",
"stream",
"input",
"instructions",
"store",
"reasoning",
"prompt_cache_key",
"tools",
"tool_choice",
"include",
]);
});
9 changes: 5 additions & 4 deletions tests/unit/memory-tools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ test("memory search respects a configured zero token budget", async () => {
assert.equal(result.data.totalTokens, 0);
});

test("memory search keeps globally disabled memory disabled with explicit maxTokens", async () => {
test("memory search runs explicitly even when global memory injection is disabled", async () => {
await settingsDb.updateSettings({ memoryEnabled: false, memoryMaxTokens: 2000 });
invalidateMemorySettingsCache();

Expand All @@ -137,9 +137,10 @@ test("memory search keeps globally disabled memory disabled with explicit maxTok
});

assert.equal(result.success, true);
assert.equal(result.data.count, 0);
assert.deepEqual(result.data.memories, []);
assert.equal(result.data.totalTokens, 0);
assert.equal(result.data.count, 1);
assert.equal(result.data.memories.length, 1);
assert.match(result.data.memories[0].content, /TypeScript/i);
assert.ok(result.data.totalTokens > 0);
});

test("memory clear deletes only older filtered entries and reports the deleted count", async () => {
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/provider-validation-specialty.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,12 +372,12 @@ test("web-cookie provider validators surface auth and subscription failures", as
__setPplxTlsFetchOverride(async () => {
return { status: 403, headers: new Headers(), text: null, body: null };
});
__setGrokTlsFetchOverride(async () => {
return { status: 401, headers: new Headers(), text: "Unauthorized", body: null };
});

globalThis.fetch = async (url, init = {}) => {
const target = String(url);
if (target.includes("grok.com/rest/app-chat/conversations/new")) {
return new Response(JSON.stringify({ error: "unauthorized" }), { status: 401 });
}
if (target.includes("app.blackbox.ai/api/auth/session")) {
const cookie = (init.headers as Record<string, string>)?.Cookie || "";
if (cookie.includes("expired-cookie")) {
Expand Down
Loading