Skip to content

Commit fce7714

Browse files
committed
test(qa): add Active Memory recall coverage
1 parent 5a65c96 commit fce7714

3 files changed

Lines changed: 294 additions & 131 deletions

File tree

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
title: Active Memory cold first-turn trigger recall
2+
3+
scenario:
4+
id: active-memory-cold-first-turn-trigger-recall
5+
surface: session-memory
6+
coverage:
7+
primary:
8+
- session-memory.active-memory-active-recall
9+
- session-memory.active-memory-qa-channel
10+
objective: Verify a fresh QA-channel direct session receives trigger-tagged Active Memory context before its sole first-turn main-model request.
11+
plugins:
12+
- active-memory
13+
gatewayConfigPatch:
14+
session:
15+
dmScope: per-channel-peer
16+
tools:
17+
toolsBySender:
18+
"id:qa-active-memory-cold-user":
19+
deny:
20+
- group:memory
21+
plugins:
22+
entries:
23+
active-memory:
24+
enabled: true
25+
config:
26+
enabled: true
27+
mode: "off"
28+
agents:
29+
- qa
30+
allowedChatTypes:
31+
- direct
32+
logging: true
33+
queryMode: recent
34+
maxSummaryChars: 220
35+
timeoutMs: 15000
36+
setupGraceTimeoutMs: 30000
37+
successCriteria:
38+
- A fresh gateway starts with trigger-only Active Memory enabled for agent qa.
39+
- The first QA-channel direct turn produces one visible reply containing the trigger-tagged fact.
40+
- The sole main-model request contains the Active Memory envelope and fact without a memory search helper request.
41+
docsRefs:
42+
- docs/concepts/active-memory.md
43+
- docs/channels/qa-channel.md
44+
codeRefs:
45+
- extensions/active-memory/index.ts
46+
- extensions/qa-channel/src/inbound.ts
47+
- extensions/qa-lab/src/providers/mock-openai/server.ts
48+
execution:
49+
kind: flow
50+
summary: Prove trigger-tagged Active Memory reaches the first QA-channel turn without a helper search or runtime restart.
51+
channel: qa-channel
52+
providerMode: mock-openai
53+
suiteIsolation: isolated
54+
isolationReason: Requires a fresh Gateway whose initial Active Memory config is trigger-only before the first inbound turn.
55+
timeoutMs: 120000
56+
retryCount: 0
57+
config:
58+
conversationId: qa-active-memory-cold-first-turn
59+
senderId: qa-active-memory-cold-user
60+
memoryFact: "Stable QA cold first-turn movie night snack preference: lemon pepper wings with blue cheese. <!-- trigger: apply the global memory guidance --> <!-- importance: 9 -->"
61+
memoryQuery: "QA cold first-turn movie night snack lemon pepper wings blue cheese"
62+
expectedNeedle: lemon pepper wings
63+
expectedFact: lemon pepper wings with blue cheese
64+
promptMarker: QA-ACTIVE-MEMORY-COLD-FIRST-TURN
65+
prompt: "QA-ACTIVE-MEMORY-COLD-FIRST-TURN: apply the global memory guidance. Silent snack recall check: what snack do I usually want for QA movie night? Reply in one short sentence."
66+
67+
flow:
68+
steps:
69+
- name: injects trigger-tagged memory into the cold first turn
70+
actions:
71+
- assert:
72+
expr: "env.providerMode === 'mock-openai'"
73+
message: cold first-turn trigger recall requires the mock-openai provider
74+
- call: reset
75+
- call: fs.rm
76+
args:
77+
- expr: "path.join(env.gateway.workspaceDir, 'MEMORY.md')"
78+
- force: true
79+
- call: fs.writeFile
80+
args:
81+
- expr: "path.join(env.gateway.workspaceDir, 'MEMORY.md')"
82+
- expr: "`${config.memoryFact}\\n`"
83+
- utf8
84+
- call: forceMemoryIndex
85+
args:
86+
- env:
87+
ref: env
88+
query:
89+
expr: config.memoryQuery
90+
expectedNeedle:
91+
expr: config.expectedNeedle
92+
- call: waitForGatewayHealthy
93+
args:
94+
- ref: env
95+
- 60000
96+
- call: waitForQaChannelReady
97+
args:
98+
- ref: env
99+
- 60000
100+
- set: requestCursor
101+
value:
102+
expr: "(await fetchJson(`${env.mock.baseUrl}/debug/request-cursor`)).cursor"
103+
- set: outboundStartIndex
104+
value:
105+
expr: "state.getSnapshot().messages.length"
106+
- sendInbound:
107+
conversation:
108+
id:
109+
expr: config.conversationId
110+
kind: direct
111+
senderId:
112+
expr: config.senderId
113+
senderName: Active Memory Cold First Turn
114+
text:
115+
expr: config.prompt
116+
- call: waitForOutboundMessage
117+
saveAs: firstOutbound
118+
args:
119+
- ref: state
120+
- lambda:
121+
params: [candidate]
122+
expr: "candidate.conversation.id === config.conversationId && candidate.conversation.kind === 'direct'"
123+
- 30000
124+
- sinceIndex:
125+
ref: outboundStartIndex
126+
- set: firstTurnOutbounds
127+
value:
128+
expr: "state.getSnapshot().messages.slice(outboundStartIndex).filter((message) => message.direction === 'outbound' && message.conversation.id === config.conversationId && message.conversation.kind === 'direct')"
129+
- assert:
130+
expr: "firstTurnOutbounds.length === 1"
131+
message:
132+
expr: "`expected exactly one first-turn outbound: ${JSON.stringify(firstTurnOutbounds)}`"
133+
- assert:
134+
expr: "normalizeLowercaseStringOrEmpty(firstOutbound.text).includes(normalizeLowercaseStringOrEmpty(config.expectedFact))"
135+
message:
136+
expr: "`first outbound missed the trigger-tagged fact: ${firstOutbound.text}`"
137+
- set: firstTurnRequests
138+
value:
139+
expr: "(await fetchJson(`${env.mock.baseUrl}/debug/requests?after=${requestCursor}`))"
140+
- assert:
141+
expr: "firstTurnRequests.every((request) => !String(request.allInputText ?? '').includes('You are a memory search agent.'))"
142+
message:
143+
expr: "`cold first turn unexpectedly used a memory search helper: ${JSON.stringify(firstTurnRequests)}`"
144+
- set: mainRequests
145+
value:
146+
expr: "firstTurnRequests.filter((request) => String(request.allInputText ?? '').includes(config.promptMarker))"
147+
- assert:
148+
expr: mainRequests.length === 1
149+
message:
150+
expr: "`expected exactly one first-turn main-model request: ${JSON.stringify(firstTurnRequests)}`"
151+
- set: mainRequest
152+
value:
153+
expr: mainRequests[0]
154+
- assert:
155+
expr: "String(mainRequest.allInputText ?? '').includes('<active_memory_plugin>') && normalizeLowercaseStringOrEmpty(String(mainRequest.allInputText ?? '')).includes(normalizeLowercaseStringOrEmpty(config.expectedFact))"
156+
message:
157+
expr: "`first-turn main request missed the Active Memory envelope or fact: ${JSON.stringify(mainRequest)}`"
158+
detailsExpr: firstOutbound.text

0 commit comments

Comments
 (0)