|
| 1 | +title: QA channel final reply after a failed terminal tool |
| 2 | + |
| 3 | +scenario: |
| 4 | + id: qa-channel-failed-tool-terminal-finalization |
| 5 | + surface: channel |
| 6 | + coverage: |
| 7 | + primary: [agent-runtime.failure-recovery-empty-response-recovery] |
| 8 | + secondary: [channels.qa-channel-final-reply, agent-runtime.failure-recovery-retry-policy] |
| 9 | + regressionRefs: |
| 10 | + - openclaw/openclaw#118274 |
| 11 | + gatewayConfigPatch: |
| 12 | + tools: |
| 13 | + codeMode: |
| 14 | + enabled: true |
| 15 | + objective: Verify a settled failed terminal tool receives one failure-honest, tool-free finalization and one channel reply. |
| 16 | + successCriteria: |
| 17 | + - Code Mode dispatches exactly one missing-file read and records one failed exec result. |
| 18 | + - The failed tool call is never replayed or described as successful. |
| 19 | + - The model receives one tools-disabled finalization and qa-channel delivers exactly one visible reply. |
| 20 | + codeRefs: |
| 21 | + - src/agents/embedded-agent-runner/run/incomplete-turn.ts |
| 22 | + - src/agents/embedded-agent-runner/run/code-mode-repair.ts |
| 23 | + - extensions/qa-lab/src/providers/mock-openai/server.ts |
| 24 | + execution: |
| 25 | + kind: flow |
| 26 | + suiteIsolation: isolated |
| 27 | + isolationReason: Enables Code Mode and verifies one exact tool call and isolated qa-channel delivery. |
| 28 | + channel: qa-channel |
| 29 | + retryCount: 0 |
| 30 | + summary: Prove a real failed terminal Code Mode tool still produces one failure-honest qa-channel reply. |
| 31 | + config: |
| 32 | + requiredProviderMode: mock-openai |
| 33 | + channelId: qa-failed-terminal |
| 34 | + promptSnippet: Failed tool terminal recovery QA check |
| 35 | + retryNeedle: The previous assistant turn completed its tool calls but did not produce a user-visible answer. |
| 36 | + failureHonestyNeedle: state that failure plainly and do not claim it succeeded |
| 37 | + expectedMarker: QA-FAILED-TOOL-FINALIZED-OK |
| 38 | + expectedReply: "The requested file could not be read: ENOENT. QA-FAILED-TOOL-FINALIZED-OK" |
| 39 | + |
| 40 | +flow: |
| 41 | + steps: |
| 42 | + - name: finalizes one failed Code Mode tool without replaying it |
| 43 | + actions: |
| 44 | + - assert: |
| 45 | + expr: "env.providerMode === config.requiredProviderMode" |
| 46 | + message: failed-terminal qa-channel proof requires mock-openai |
| 47 | + - call: waitForGatewayHealthy |
| 48 | + args: |
| 49 | + - ref: env |
| 50 | + - 60000 |
| 51 | + - call: waitForQaChannelReady |
| 52 | + args: |
| 53 | + - ref: env |
| 54 | + - 60000 |
| 55 | + - call: reset |
| 56 | + - set: requestCursorBefore |
| 57 | + value: |
| 58 | + expr: "(await fetchJson(`${env.mock.baseUrl}/debug/request-cursor`)).cursor" |
| 59 | + - set: outboundStartIndex |
| 60 | + value: |
| 61 | + expr: "state.getSnapshot().messages.filter((message) => message.direction === 'outbound').length" |
| 62 | + - set: sessionKey |
| 63 | + value: |
| 64 | + expr: "`agent:qa:qa-channel:group:group:${config.channelId}`" |
| 65 | + - sendInbound: |
| 66 | + conversation: |
| 67 | + id: |
| 68 | + ref: config.channelId |
| 69 | + kind: group |
| 70 | + senderId: qa-driver |
| 71 | + senderName: QA Driver |
| 72 | + text: "@openclaw Failed tool terminal recovery QA check: read the missing workspace file, then respond with exact marker: `QA-FAILED-TOOL-FINALIZED-OK`." |
| 73 | + - waitForOutbound: |
| 74 | + conversation: |
| 75 | + id: |
| 76 | + ref: config.channelId |
| 77 | + kind: group |
| 78 | + sinceIndex: |
| 79 | + ref: outboundStartIndex |
| 80 | + textIncludes: |
| 81 | + ref: config.expectedMarker |
| 82 | + timeoutMs: 60000 |
| 83 | + saveAs: reply |
| 84 | + - set: scenarioRequests |
| 85 | + value: |
| 86 | + expr: "(await fetchJson(`${env.mock.baseUrl}/debug/requests?after=${requestCursorBefore}`)).filter((request) => String(request.allInputText ?? '').includes(config.promptSnippet))" |
| 87 | + - set: readPlans |
| 88 | + value: |
| 89 | + expr: "scenarioRequests.filter((request) => request.plannedToolName === 'read')" |
| 90 | + - set: finalizations |
| 91 | + value: |
| 92 | + expr: "scenarioRequests.filter((request) => String(request.allInputText ?? '').includes(config.retryNeedle))" |
| 93 | + - assert: |
| 94 | + expr: "readPlans.length === 1 && readPlans[0].plannedWireToolName === 'exec'" |
| 95 | + message: |
| 96 | + expr: "`expected one Code Mode read plan, got ${JSON.stringify(readPlans)}`" |
| 97 | + - assert: |
| 98 | + expr: "finalizations.length === 1 && String(finalizations[0].allInputText ?? '').includes(config.failureHonestyNeedle)" |
| 99 | + message: |
| 100 | + expr: "`expected one failure-honest finalization, got ${JSON.stringify(finalizations)}`" |
| 101 | + - set: replayedExecCalls |
| 102 | + value: |
| 103 | + expr: "(Array.isArray(finalizations[0].body?.input) ? finalizations[0].body.input : []).filter((item) => item?.type === 'function_call' && item.name === 'exec' && String(item.arguments ?? '').includes('qa-failed-terminal-missing-file.txt'))" |
| 104 | + - set: failedExecOutputs |
| 105 | + value: |
| 106 | + expr: "(Array.isArray(finalizations[0].body?.input) ? finalizations[0].body.input : []).filter((item) => item?.type === 'function_call_output' && item.call_id === replayedExecCalls[0]?.call_id && /ENOENT|no such file/i.test(typeof item.output === 'string' ? item.output : JSON.stringify(item.output ?? '')))" |
| 107 | + - assert: |
| 108 | + expr: "replayedExecCalls.length === 1 && failedExecOutputs.length === 1 && finalizations[0].toolOutputCallId === replayedExecCalls[0].call_id" |
| 109 | + message: |
| 110 | + expr: "`finalization did not preserve the normalized parent exec/result pairing: calls=${JSON.stringify(replayedExecCalls.map((item) => item.call_id))} outputs=${JSON.stringify(failedExecOutputs.map((item) => item.call_id))}`" |
| 111 | + - assert: |
| 112 | + expr: "!Array.isArray(finalizations[0].body?.tools) || finalizations[0].body.tools.length === 0" |
| 113 | + message: failed-tool finalization exposed a replayable model tool surface |
| 114 | + - call: readSessionTranscriptSummary |
| 115 | + saveAs: transcript |
| 116 | + args: |
| 117 | + - ref: env |
| 118 | + - ref: sessionKey |
| 119 | + - assert: |
| 120 | + expr: "transcript.assistantToolCallCounts.exec === 1 && transcript.completedToolCallCounts.exec === 1 && !transcript.successfulToolCallCounts.exec" |
| 121 | + message: |
| 122 | + expr: "`expected exactly one settled failed exec result, got ${JSON.stringify(transcript)}`" |
| 123 | + - set: deliveries |
| 124 | + value: |
| 125 | + expr: "state.getSnapshot().messages.filter((message) => message.direction === 'outbound' && message.conversation.id === config.channelId)" |
| 126 | + - assert: |
| 127 | + expr: "deliveries.length === 1 && reply.text.trim() === config.expectedReply" |
| 128 | + message: |
| 129 | + expr: "`expected exactly one failure-honest reply, got ${JSON.stringify(deliveries)}`" |
| 130 | + detailsExpr: "`${reply.text}; calls=${String(transcript.assistantToolCallCounts.exec)} failed=${String(transcript.completedToolCallCounts.exec)} finalizations=${String(finalizations.length)}`" |
0 commit comments