Skip to content

Commit 52c9448

Browse files
authored
test(qa): prove shared-channel memory recall (#119111)
1 parent 84cfc43 commit 52c9448

1 file changed

Lines changed: 72 additions & 10 deletions

File tree

‎qa/scenarios/memory/memory-tools-channel-context.yaml‎

Lines changed: 72 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ scenario:
55
surface: session-memory
66
coverage:
77
primary:
8-
- session-memory.memory-tools
8+
- session-memory.group-memory
9+
- session-memory.qa-channel-memory
910
secondary:
11+
- session-memory.memory-tools
1012
- channels.room-session-group-messages
11-
objective: Verify the agent uses memory tools in a shared channel when the answer lives only in memory files, not the live transcript.
13+
objective: Verify a shared QA-channel message causally recalls a fact from a nested memory file before the agent replies in the same room.
1214
successCriteria:
13-
- Agent uses memory_search before answering.
14-
- Final reply returns the memory-only fact correctly in-channel.
15+
- The initial model request does not contain the memory-only fact and plans memory_search with the expected arguments.
16+
- The matching memory_search result plans memory_get for the seeded path, whose correlated result supplies the recalled fact.
17+
- The ordered tool chain produces exactly one visible final reply in the originating QA room.
1518
docsRefs:
1619
- docs/concepts/memory.md
1720
- docs/concepts/memory-search.md
@@ -21,12 +24,17 @@ scenario:
2124
execution:
2225
kind: flow
2326
channel: qa-channel
24-
summary: Verify the agent uses memory tools in a shared channel when the answer lives only in memory files, not the live transcript.
27+
providerMode: mock-openai
28+
retryCount: 0
29+
summary: Prove a QA-channel group message consumes a matched nested-memory result before one in-room reply.
2530
config:
31+
requiredProviderMode: mock-openai
2632
channelId: qa-memory-room
2733
channelTitle: QA Memory Room
34+
expectedMemoryPath: memory/qa-shared-channel.md
2835
memoryFact: "Hidden QA fact: the project codename is ORBIT-9."
2936
memoryQuery: "hidden project codename"
37+
expectedCorpus: null
3038
expectedNeedle: ORBIT-9
3139
prompt: "@openclaw Memory tools check: what is the hidden project codename stored only in memory? Use memory tools first."
3240
promptSnippet: "Memory tools check"
@@ -35,10 +43,18 @@ flow:
3543
steps:
3644
- name: uses memory_search before answering in-channel
3745
actions:
46+
- assert:
47+
expr: "env.providerMode === config.requiredProviderMode"
48+
message:
49+
expr: "`expected provider mode ${config.requiredProviderMode}, got ${env.providerMode}`"
3850
- call: reset
51+
- call: fs.mkdir
52+
args:
53+
- expr: "path.dirname(path.join(env.gateway.workspaceDir, config.expectedMemoryPath))"
54+
- recursive: true
3955
- call: fs.writeFile
4056
args:
41-
- expr: "path.join(env.gateway.workspaceDir, 'MEMORY.md')"
57+
- expr: "path.join(env.gateway.workspaceDir, config.expectedMemoryPath)"
4258
- expr: "`${config.memoryFact}\\n`"
4359
- utf8
4460
- call: forceMemoryIndex
@@ -57,6 +73,12 @@ flow:
5773
args:
5874
- ref: env
5975
- 60000
76+
- set: requestCursorBeforeInbound
77+
value:
78+
expr: "(await fetchJson(`${env.mock.baseUrl}/debug/request-cursor`)).cursor"
79+
- set: outboundStartIndex
80+
value:
81+
expr: "state.getSnapshot().messages.length"
6082
- sendInbound:
6183
conversation:
6284
id:
@@ -74,9 +96,49 @@ flow:
7496
- ref: state
7597
- lambda:
7698
params: [candidate]
77-
expr: "candidate.conversation.id === config.channelId && candidate.text.includes(config.expectedNeedle)"
99+
expr: "candidate.direction === 'outbound' && candidate.conversation.id === config.channelId && candidate.conversation.kind === 'channel' && candidate.text.includes(config.expectedNeedle)"
78100
- expr: liveTurnTimeoutMs(env, 30000)
101+
- sinceIndex:
102+
ref: outboundStartIndex
103+
- set: scenarioRequests
104+
value:
105+
expr: "(await fetchJson(`${env.mock.baseUrl}/debug/requests?after=${requestCursorBeforeInbound}`)).filter((request) => String(request.allInputText ?? '').includes(config.promptSnippet))"
106+
- assert:
107+
expr: scenarioRequests.length === 3
108+
message:
109+
expr: "`expected one memory_search plan, one matched result request, and one finalization request: ${JSON.stringify(scenarioRequests)}`"
110+
- set: searchPlanRequest
111+
value:
112+
expr: scenarioRequests[0]
113+
- set: searchResultRequest
114+
value:
115+
expr: scenarioRequests[1]
116+
- set: finalRequest
117+
value:
118+
expr: scenarioRequests[2]
119+
- assert:
120+
expr: "searchPlanRequest.plannedToolName === 'memory_search' && searchPlanRequest.plannedToolArgs?.query === config.memoryQuery && (searchPlanRequest.plannedToolArgs?.corpus ?? null) === config.expectedCorpus && typeof searchPlanRequest.plannedToolCallId === 'string' && searchPlanRequest.plannedToolCallId.length > 0 && !searchPlanRequest.toolOutputCallId && !String(searchPlanRequest.allInputText ?? '').includes(config.expectedNeedle)"
121+
message:
122+
expr: "`initial request exposed the hidden fact or missed the expected memory_search plan: ${JSON.stringify(searchPlanRequest)}`"
123+
- assert:
124+
expr: "searchResultRequest.cursor > searchPlanRequest.cursor && searchResultRequest.toolOutputCallId === searchPlanRequest.plannedToolCallId && searchResultRequest.toolOutputStructuredError !== true && String(searchResultRequest.toolOutput ?? '').includes(config.expectedMemoryPath) && String(searchResultRequest.toolOutput ?? '').includes(config.expectedNeedle) && searchResultRequest.plannedToolName === 'memory_get' && searchResultRequest.plannedToolArgs?.path === config.expectedMemoryPath && typeof searchResultRequest.plannedToolCallId === 'string' && searchResultRequest.plannedToolCallId.length > 0 && searchResultRequest.plannedToolCallId !== searchPlanRequest.plannedToolCallId"
125+
message:
126+
expr: "`following request did not consume memory_search and plan a distinct memory_get call for the expected path: ${JSON.stringify(searchResultRequest)}`"
127+
- assert:
128+
expr: "finalRequest.cursor > searchResultRequest.cursor && finalRequest.toolOutputCallId === searchResultRequest.plannedToolCallId && finalRequest.toolOutputStructuredError !== true && String(finalRequest.toolOutput ?? '').includes(config.expectedMemoryPath) && String(finalRequest.toolOutput ?? '').includes(config.expectedNeedle) && !finalRequest.plannedToolName"
129+
message:
130+
expr: "`final request did not consume the matching successful memory_get result: ${JSON.stringify(finalRequest)}`"
131+
- call: sleep
132+
args: [4000]
133+
- set: visibleChannelOutbounds
134+
value:
135+
expr: "state.getSnapshot().messages.slice(outboundStartIndex).filter((message) => message.direction === 'outbound' && !message.deleted && message.conversation.id === config.channelId && message.conversation.kind === 'channel')"
136+
- assert:
137+
expr: "visibleChannelOutbounds.length === 1 && visibleChannelOutbounds[0].id === outbound.id"
138+
message:
139+
expr: "`expected exactly one visible QA-room reply after the ordered memory result: ${JSON.stringify(visibleChannelOutbounds)}`"
79140
- assert:
80-
expr: "!env.mock || (await fetchJson(`${env.mock.baseUrl}/debug/requests`)).filter((request) => String(request.allInputText ?? '').includes(config.promptSnippet)).some((request) => request.plannedToolName === 'memory_search')"
81-
message: expected memory_search in mock request plan
82-
detailsExpr: outbound.text
141+
expr: "(outbound.text.match(new RegExp(config.expectedNeedle, 'g')) ?? []).length === 1"
142+
message:
143+
expr: "`final QA-room reply must contain ${config.expectedNeedle} exactly once: ${outbound.text}`"
144+
detailsExpr: "`${outbound.text}; path=${config.expectedMemoryPath}; matched=${searchResultRequest.toolOutputCallId === searchPlanRequest.plannedToolCallId}; room=${config.channelId}`"

0 commit comments

Comments
 (0)