Skip to content

Commit 702eb6e

Browse files
authored
fix(qa): prove newer session facts outrank competing durable memory (#119496)
* fix(qa): prove session memory outranks stale durable facts * fix(qa): require the canonical memory search result window * fix(qa): honor the optional canonical memory search limit
1 parent 47ce269 commit 702eb6e

5 files changed

Lines changed: 567 additions & 31 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { describe, expect, it } from "vitest";
2+
import { startQaMockOpenAiServer } from "./server.js";
3+
4+
describe("QA mock OpenAI session memory ranking", () => {
5+
it("plans an answer-free search across both configured memory sources", async () => {
6+
const server = await startQaMockOpenAiServer({ host: "127.0.0.1", port: 0 });
7+
8+
try {
9+
const response = await fetch(`${server.baseUrl}/v1/responses`, {
10+
method: "POST",
11+
headers: { "content-type": "application/json" },
12+
body: JSON.stringify({
13+
model: "gpt-5.6-luna",
14+
stream: false,
15+
input: [
16+
{
17+
role: "user",
18+
content: [
19+
{
20+
type: "input_text",
21+
text: "Session memory ranking check: what is the current Project Nebula codename? Use memory tools first.",
22+
},
23+
],
24+
},
25+
],
26+
}),
27+
});
28+
29+
expect(response.status).toBe(200);
30+
const payload = (await response.json()) as {
31+
output?: Array<{ type?: string; name?: string; arguments?: string }>;
32+
};
33+
const searchCall = payload.output?.find(
34+
(item) => item.type === "function_call" && item.name === "memory_search",
35+
);
36+
expect(searchCall).toBeDefined();
37+
const args = JSON.parse(searchCall?.arguments ?? "null") as Record<string, unknown>;
38+
39+
expect(args).toEqual({
40+
query: "current Project Nebula codename",
41+
maxResults: 6,
42+
});
43+
expect(JSON.stringify(args)).not.toMatch(/ORBIT-(?:9|10)/);
44+
expect(args).not.toHaveProperty("corpus");
45+
} finally {
46+
await server.stop();
47+
}
48+
});
49+
});

‎extensions/qa-lab/src/providers/mock-openai/server.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3752,7 +3752,7 @@ Update and merge these partial structured summaries.`,
37523752
],
37533753
});
37543754
expect(memoryText).toContain('"name":"memory_search"');
3755-
expect(memoryText).toContain('\\"corpus\\":\\"sessions\\"');
3755+
expect(memoryText).not.toContain('\\"corpus\\"');
37563756

37573757
const threadMemorySearchText = await expectStreamingResponsesText(server, {
37583758
instructions:

‎extensions/qa-lab/src/providers/mock-openai/server.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,9 +1946,8 @@ async function buildResponsesPayload(
19461946
if (/session memory ranking check/i.test(prompt)) {
19471947
if (!scenarioToolOutput) {
19481948
return buildToolCallEventsWithArgs("memory_search", {
1949-
query: "current Project Nebula codename ORBIT-10",
1950-
maxResults: 3,
1951-
corpus: "sessions",
1949+
query: "current Project Nebula codename",
1950+
maxResults: 6,
19521951
});
19531952
}
19541953
if (memoryToolUnavailable) {

0 commit comments

Comments
 (0)