@@ -13,18 +13,19 @@ scenario:
1313 - channels.qa-channel-final-reply
1414 regressionRefs :
1515 - openclaw/openclaw#117308
16- objective : Verify a naturally fired isolated one-shot cron with a spawn -only parent delivers its child 's exact reply before retiring.
16+ objective : Verify naturally fired isolated one-shot cron parents with empty or heartbeat -only replies deliver their children 's exact replies before retiring.
1717 successCriteria :
18- - The isolated parent successfully spawns exactly one child and finishes without producing assistant text.
19- - The child completes successfully and its exact reply reaches the QA channel once.
20- - Cron history records successful delivery before the one-shot job is retired.
18+ - Each isolated parent successfully spawns exactly one child and finishes with either no assistant text or a heartbeat acknowledgment .
19+ - Each child completes successfully and its exact reply reaches the QA channel once without leaking a heartbeat acknowledgment .
20+ - Cron history records each successful delivery before its one-shot job is retired.
2121 docsRefs :
2222 - docs/help/testing.md
2323 - docs/channels/qa-channel.md
2424 - docs/tools/subagents.md
2525 codeRefs :
2626 - src/cron/isolated-agent/run-finalize.ts
2727 - src/cron/isolated-agent/delivery-dispatch.ts
28+ - src/cron/isolated-agent/subagent-followup.ts
2829 - src/cron/service/timer-outcomes.ts
2930 - extensions/qa-lab/src/providers/mock-openai/server.ts
3031 execution :
@@ -34,7 +35,7 @@ scenario:
3435 channel : qa-channel
3536 retryCount : 0
3637 timeoutMs : 180000
37- summary : Naturally fire a spawn-only isolated cron and require one exact child delivery before one-shot retirement.
38+ summary : Naturally fire empty-parent and heartbeat-parent isolated cron jobs and require each exact child delivery before one-shot retirement.
3839 config :
3940 requiredProviderMode : mock-openai
4041 channelId : qa-room
@@ -44,11 +45,17 @@ scenario:
4445 workerSnippet : Subagent direct fallback worker
4546 expectedLabel : qa-direct-fallback-worker
4647 expectedMarker : QA-SUBAGENT-DIRECT-FALLBACK-OK
47- prompt : " Subagent direct fallback QA check: spawn one native subagent worker. The worker must finish with exactly QA-SUBAGENT-DIRECT-FALLBACK-OK. After the spawn is accepted, finish without assistant text. Empty response exhaustion QA check. Do not use ACP."
48+ cases :
49+ - name : empty-parent
50+ terminalNeedle : Empty response exhaustion QA check
51+ prompt : " Subagent direct fallback QA check: spawn one native subagent worker. The worker must finish with exactly QA-SUBAGENT-DIRECT-FALLBACK-OK. After the spawn is accepted, finish without assistant text. Empty response exhaustion QA check. Do not use ACP."
52+ - name : heartbeat-parent
53+ terminalNeedle : Read HEARTBEAT.md if it exists
54+ prompt : " Subagent direct fallback QA check: spawn one native subagent worker. The worker must finish with exactly QA-SUBAGENT-DIRECT-FALLBACK-OK. After the spawn is accepted, reply HEARTBEAT_OK. Do not use ACP.\n Read HEARTBEAT.md if it exists (workspace context). If nothing needs attention, reply HEARTBEAT_OK."
4855
4956flow :
5057 steps :
51- - name : naturally fires an isolated spawn -only one-shot job
58+ - name : delivers child replies from empty and heartbeat -only isolated cron parents
5259 actions :
5360 - call : waitForGatewayHealthy
5461 args :
@@ -58,137 +65,155 @@ flow:
5865 args :
5966 - ref : env
6067 - 120000
61- - call : reset
62- - set : requestCursorBefore
68+ - set : verdicts
6369 value :
64- expr : " (await fetchJson(`${env.mock.baseUrl}/debug/request-cursor`)).cursor"
65- - set : runStartedAt
66- value :
67- expr : " Date.now()"
68- - set : scheduledFor
69- value :
70- expr : " new Date(runStartedAt + config.fireDelayMs).toISOString()"
71- - call : env.gateway.call
72- saveAs : addedJob
73- args :
74- - cron.add
75- - agentId : qa
76- name :
77- expr : " `qa-cron-spawn-only-${randomUUID()}`"
78- enabled : true
79- deleteAfterRun : true
80- schedule :
81- kind : at
82- at :
83- ref : scheduledFor
84- sessionTarget : isolated
85- wakeMode : now
86- payload :
87- kind : agentTurn
88- timeoutSeconds : 90
89- toolsAllow :
90- - sessions_spawn
91- - read
92- message :
93- ref : config.prompt
94- delivery :
95- mode : announce
96- channel : qa-channel
97- to :
98- expr : " `channel:${config.channelId}`"
99- - timeoutMs : 30000
100- - set : jobId
101- value :
102- expr : " addedJob.id"
103- - assert :
104- expr : " Boolean(jobId) && addedJob.sessionTarget === 'isolated' && addedJob.deleteAfterRun === true && JSON.stringify(addedJob.payload?.toolsAllow) === JSON.stringify(['sessions_spawn', 'read'])"
105- message :
106- expr : " `expected an isolated delete-after-run cron job restricted to sessions_spawn and read, got ${JSON.stringify(addedJob)}`"
107- - call : waitForCronRunCompletion
108- saveAs : completedRun
109- args :
110- - callGateway :
111- expr : " env.gateway.call.bind(env.gateway)"
112- jobId :
113- ref : jobId
114- afterTs :
115- ref : runStartedAt
116- timeoutMs :
117- expr : " liveTurnTimeoutMs(env, config.fireDelayMs + 90000)"
118- - assert :
119- expr : " Date.now() >= new Date(scheduledFor).getTime()"
120- message : one-shot cron completed before its natural scheduled time
121- - assert :
122- expr : " completedRun.status === 'ok' && completedRun.delivered === true && completedRun.deliveryStatus === 'delivered'"
123- message :
124- expr : " `expected successful delivered spawn-only cron run, got ${JSON.stringify(completedRun)}`"
125- - assert :
126- expr : " String(completedRun.summary ?? '').trim() === config.expectedMarker"
127- message :
128- expr : " `cron summary did not preserve the child's exact reply: ${JSON.stringify(completedRun)}`"
129-
130- - name : proves the parent accepted its child without producing assistant text
131- actions :
132- - set : scenarioRequests
133- value :
134- expr : " await fetchJson(`${env.mock.baseUrl}/debug/requests?after=${requestCursorBefore}`)"
135- - set : parentRequests
136- value :
137- expr : " scenarioRequests.filter((request) => String(request.prompt ?? '').includes(config.promptSnippet))"
138- - set : spawnRequests
139- value :
140- expr : " parentRequests.filter((request) => request.plannedToolName === 'sessions_spawn')"
141- - set : terminalRequests
142- value :
143- expr : " parentRequests.filter((request) => !request.plannedToolName)"
144- - assert :
145- expr : " parentRequests.length === 2 && spawnRequests.length === 1 && terminalRequests.length === 1 && spawnRequests[0].plannedToolArgs?.label === config.expectedLabel && spawnRequests[0].cursor < terminalRequests[0].cursor && /empty response exhaustion qa check/i.test(String(terminalRequests[0].allInputText ?? ''))"
146- message :
147- expr : " `expected one child spawn followed by an empty tool-free parent response, saw ${JSON.stringify(parentRequests.map((request) => ({ tool: request.plannedToolName ?? null, label: request.plannedToolArgs?.label ?? null })))}`"
148- - set : acceptedSpawn
149- value :
150- expr : " (() => { let result = JSON.parse(String(terminalRequests[0].toolOutput ?? 'null')); if (result?.status === 'completed') result = result.value; return typeof result === 'string' ? JSON.parse(result) : result; })()"
151- - assert :
152- expr : " acceptedSpawn?.status === 'accepted' && Boolean(String(acceptedSpawn.childSessionKey ?? '').trim()) && Boolean(String(acceptedSpawn.runId ?? '').trim())"
153- message :
154- expr : " `parent did not receive a successful child-spawn result before its empty response: ${JSON.stringify(acceptedSpawn)}`"
155- - set : childRequests
156- value :
157- expr : " scenarioRequests.filter((request) => String(request.prompt ?? '').includes(config.workerSnippet))"
158- - assert :
159- expr : " childRequests.length === 1 && !childRequests[0].plannedToolName"
160- message :
161- expr : " `expected one child assistant reply without additional tools, saw ${JSON.stringify(childRequests.map((request) => request.plannedToolName ?? null))}`"
162-
163- - name : delivers the exact child reply once and retires the one-shot job
164- actions :
165- - call : waitForOutboundMessage
166- saveAs : deliveredReply
167- args :
168- - ref : state
169- - lambda :
170- params : [candidate]
171- expr : " candidate.conversation.id === config.channelId && String(candidate.text ?? '').trim() === config.expectedMarker"
172- - expr : " liveTurnTimeoutMs(env, 30000)"
173- - call : sleep
174- args :
175- - expr : " config.duplicateWindowMs"
176- - set : deliveredReplies
177- value :
178- expr : " getTransportSnapshot().messages.filter((message) => message.direction === 'outbound' && message.conversation.id === config.channelId && String(message.text ?? '').trim() === config.expectedMarker)"
179- - assert :
180- expr : " deliveredReplies.length === 1"
181- message :
182- expr : " `expected exactly one child reply on qa-channel, saw ${deliveredReplies.length}: ${JSON.stringify(deliveredReplies.map((message) => message.text))}`"
183- - call : waitForCondition
184- saveAs : retiredJobs
185- args :
186- - lambda :
187- async : true
188- expr : " env.gateway.call('cron.list', { includeDisabled: true }, { timeoutMs: 30000 }).then((page) => page.jobs.some((job) => job.id === jobId) ? undefined : page.jobs)"
189- - expr : " liveTurnTimeoutMs(env, 30000)"
190- - 250
191- - assert :
192- expr : " !retiredJobs.some((job) => job.id === jobId)"
193- message : successful one-shot job was not retired after exact child delivery
194- detailsExpr : " `child=${config.expectedLabel} accepted=true parentVisibleText=false delivery=${completedRun.deliveryStatus} reply=${deliveredReply.text} outboundCount=${deliveredReplies.length} retired=true`"
70+ expr : " []"
71+ - forEach :
72+ items :
73+ expr : config.cases
74+ item : parentCase
75+ actions :
76+ - call : reset
77+ - set : requestCursorBefore
78+ value :
79+ expr : " (await fetchJson(`${env.mock.baseUrl}/debug/request-cursor`)).cursor"
80+ - set : runStartedAt
81+ value :
82+ expr : " Date.now()"
83+ - set : scheduledFor
84+ value :
85+ expr : " new Date(runStartedAt + config.fireDelayMs).toISOString()"
86+ - call : env.gateway.call
87+ saveAs : addedJob
88+ args :
89+ - cron.add
90+ - agentId : qa
91+ name :
92+ expr : " `qa-cron-${parentCase.name}-${randomUUID()}`"
93+ enabled : true
94+ deleteAfterRun : true
95+ schedule :
96+ kind : at
97+ at :
98+ ref : scheduledFor
99+ sessionTarget : isolated
100+ wakeMode : now
101+ payload :
102+ kind : agentTurn
103+ timeoutSeconds : 90
104+ toolsAllow :
105+ - sessions_spawn
106+ - read
107+ message :
108+ ref : parentCase.prompt
109+ delivery :
110+ mode : announce
111+ channel : qa-channel
112+ to :
113+ expr : " `channel:${config.channelId}`"
114+ - timeoutMs : 30000
115+ - set : jobId
116+ value :
117+ expr : " addedJob.id"
118+ - assert :
119+ expr : " Boolean(jobId) && addedJob.sessionTarget === 'isolated' && addedJob.deleteAfterRun === true && JSON.stringify(addedJob.payload?.toolsAllow) === JSON.stringify(['sessions_spawn', 'read'])"
120+ message :
121+ expr : " `${parentCase.name}: expected an isolated delete-after-run job restricted to sessions_spawn and read, got ${JSON.stringify(addedJob)}`"
122+ - call : waitForCronRunCompletion
123+ saveAs : completedRun
124+ args :
125+ - callGateway :
126+ expr : " env.gateway.call.bind(env.gateway)"
127+ jobId :
128+ ref : jobId
129+ afterTs :
130+ ref : runStartedAt
131+ timeoutMs :
132+ expr : " liveTurnTimeoutMs(env, config.fireDelayMs + 90000)"
133+ - assert :
134+ expr : " Date.now() >= new Date(scheduledFor).getTime()"
135+ message :
136+ expr : " `${parentCase.name}: one-shot cron completed before its natural scheduled time`"
137+ - assert :
138+ expr : " completedRun.status === 'ok' && completedRun.delivered === true && completedRun.deliveryStatus === 'delivered'"
139+ message :
140+ expr : " `${parentCase.name}: expected a successfully delivered child handoff, got ${JSON.stringify(completedRun)}`"
141+ - assert :
142+ expr : " String(completedRun.summary ?? '').trim() === config.expectedMarker"
143+ message :
144+ expr : " `${parentCase.name}: cron summary did not preserve the child's exact reply: ${JSON.stringify(completedRun)}`"
145+ - set : scenarioRequests
146+ value :
147+ expr : " await fetchJson(`${env.mock.baseUrl}/debug/requests?after=${requestCursorBefore}`)"
148+ - set : parentRequests
149+ value :
150+ expr : " scenarioRequests.filter((request) => String(request.prompt ?? '').includes(config.promptSnippet))"
151+ - set : spawnRequests
152+ value :
153+ expr : " parentRequests.filter((request) => request.plannedToolName === 'sessions_spawn')"
154+ - set : terminalRequests
155+ value :
156+ expr : " parentRequests.filter((request) => !request.plannedToolName)"
157+ - assert :
158+ expr : " parentRequests.length === 2 && spawnRequests.length === 1 && terminalRequests.length === 1 && spawnRequests[0].plannedToolArgs?.label === config.expectedLabel && spawnRequests[0].cursor < terminalRequests[0].cursor && String(terminalRequests[0].allInputText ?? '').includes(parentCase.terminalNeedle)"
159+ message :
160+ expr : " `${parentCase.name}: expected one accepted child spawn followed by its configured tool-free parent response, saw ${JSON.stringify(parentRequests.map((request) => ({ tool: request.plannedToolName ?? null, label: request.plannedToolArgs?.label ?? null })))}`"
161+ - assert :
162+ expr : " parentCase.name !== 'heartbeat-parent' || (String(terminalRequests[0].prompt ?? '').split(String.fromCharCode(10)).some((line) => line.startsWith(parentCase.terminalNeedle)) && !/Internal task completion event/i.test(String(terminalRequests[0].allInputText ?? '')))"
163+ message :
164+ expr : " `${parentCase.name}: terminal provider request cannot prove a heartbeat reply instead of an empty completion-event response`"
165+ - set : acceptedSpawn
166+ value :
167+ expr : " (() => { let result = JSON.parse(String(terminalRequests[0].toolOutput ?? 'null')); if (result?.status === 'completed') result = result.value; return typeof result === 'string' ? JSON.parse(result) : result; })()"
168+ - assert :
169+ expr : " acceptedSpawn?.status === 'accepted' && Boolean(String(acceptedSpawn.childSessionKey ?? '').trim()) && Boolean(String(acceptedSpawn.runId ?? '').trim())"
170+ message :
171+ expr : " `${parentCase.name}: parent did not receive a successful child-spawn result before its final response: ${JSON.stringify(acceptedSpawn)}`"
172+ - set : childRequests
173+ value :
174+ expr : " scenarioRequests.filter((request) => String(request.prompt ?? '').includes(config.workerSnippet))"
175+ - assert :
176+ expr : " childRequests.length === 1 && !childRequests[0].plannedToolName"
177+ message :
178+ expr : " `${parentCase.name}: expected one child reply without additional tools, saw ${JSON.stringify(childRequests.map((request) => request.plannedToolName ?? null))}`"
179+ - call : waitForOutboundMessage
180+ saveAs : deliveredReply
181+ args :
182+ - ref : state
183+ - lambda :
184+ params : [candidate]
185+ expr : " candidate.conversation.id === config.channelId && String(candidate.text ?? '').trim() === config.expectedMarker"
186+ - expr : " liveTurnTimeoutMs(env, 30000)"
187+ - call : sleep
188+ args :
189+ - expr : " config.duplicateWindowMs"
190+ - set : caseOutbound
191+ value :
192+ expr : " getTransportSnapshot().messages.filter((message) => message.direction === 'outbound' && message.conversation.id === config.channelId)"
193+ - set : deliveredReplies
194+ value :
195+ expr : " caseOutbound.filter((message) => String(message.text ?? '').trim() === config.expectedMarker)"
196+ - assert :
197+ expr : " deliveredReplies.length === 1"
198+ message :
199+ expr : " `${parentCase.name}: expected exactly one child reply on qa-channel, saw ${deliveredReplies.length}: ${JSON.stringify(caseOutbound.map((message) => message.text))}`"
200+ - assert :
201+ expr : " caseOutbound.every((message) => !String(message.text ?? '').includes('HEARTBEAT_OK'))"
202+ message :
203+ expr : " `${parentCase.name}: parent heartbeat acknowledgment leaked to qa-channel: ${JSON.stringify(caseOutbound.map((message) => message.text))}`"
204+ - call : waitForCondition
205+ saveAs : retiredJobs
206+ args :
207+ - lambda :
208+ async : true
209+ expr : " env.gateway.call('cron.list', { includeDisabled: true }, { timeoutMs: 30000 }).then((page) => page.jobs.some((job) => job.id === jobId) ? undefined : page.jobs)"
210+ - expr : " liveTurnTimeoutMs(env, 30000)"
211+ - 250
212+ - assert :
213+ expr : " !retiredJobs.some((job) => job.id === jobId)"
214+ message :
215+ expr : " `${parentCase.name}: successful one-shot job was not retired after exact child delivery`"
216+ - set : appendVerdict
217+ value :
218+ expr : " verdicts.push({ parent: parentCase.name, child: config.expectedLabel, accepted: true, delivery: completedRun.deliveryStatus, reply: deliveredReply.text, outboundCount: deliveredReplies.length, heartbeatLeaked: false, retired: true })"
219+ detailsExpr : " JSON.stringify(verdicts)"
0 commit comments