Skip to content

Commit 79dac91

Browse files
authored
test(qa): prove failure recovery visibility (#119034)
1 parent 6419711 commit 79dac91

3 files changed

Lines changed: 98 additions & 17 deletions

File tree

‎qa/scenarios/runtime/empty-response-recovery-replay-safe-read.yaml‎

Lines changed: 51 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ scenario:
66
coverage:
77
primary:
88
- agent-runtime.failure-recovery-empty-response-recovery
9-
secondary:
109
- agent-runtime.failure-recovery-retry-policy
10+
- agent-runtime.failure-recovery-evidence
11+
- agent-runtime.progress-visibility-failure-recovery
1112
objective: Verify an empty visible GPT turn after a replay-safe read auto-continues into a visible answer.
1213
successCriteria:
1314
- Scenario is mock-openai only so live lanes do not pick it up implicitly.
1415
- The agent performs a replay-safe read before the empty response.
1516
- The runtime injects the visible-answer continuation instruction after the empty turn.
17+
- The authenticated read result survives the empty turn and canonical retry unchanged.
1618
- The final visible reply contains the exact recovery marker.
1719
docsRefs:
1820
- docs/help/testing.md
@@ -27,6 +29,7 @@ scenario:
2729
promptSnippet: Empty response continuation QA check
2830
prompt: "Empty response continuation QA check: read QA_KICKOFF_TASK.md, then answer with exactly EMPTY-RECOVERED-OK."
2931
expectedReply: EMPTY-RECOVERED-OK
32+
evidenceNonce: EMPTY-RECOVERY-EVIDENCE-7B2F
3033
retryNeedle: The previous assistant turn completed its tool calls but did not produce a user-visible answer.
3134

3235
flow:
@@ -41,6 +44,17 @@ flow:
4144
- ref: env
4245
- 60000
4346
- call: reset
47+
- assert:
48+
expr: "!config.prompt.includes(config.evidenceNonce)"
49+
message: recovery evidence nonce must originate only from the read result
50+
- call: fs.writeFile
51+
args:
52+
- expr: "path.join(env.gateway.workspaceDir, 'QA_KICKOFF_TASK.md')"
53+
- expr: "`${config.evidenceNonce}\\n`"
54+
- utf8
55+
- set: outboundStartIndex
56+
value:
57+
expr: "state.getSnapshot().messages.filter((message) => message.direction === 'outbound').length"
4458
- set: requestCursorBefore
4559
value:
4660
expr: "env.mock ? (await fetchJson(`${env.mock.baseUrl}/debug/request-cursor`)).cursor : 0"
@@ -68,16 +82,46 @@ flow:
6882
expr: "outbound.text.includes(config.expectedReply)"
6983
message:
7084
expr: "`missing empty-response recovery marker: ${outbound.text}`"
85+
- call: sleep
86+
args:
87+
- 300
88+
- set: scenarioOutbound
89+
value:
90+
expr: "state.getSnapshot().messages.filter((message) => message.direction === 'outbound').slice(outboundStartIndex).filter((message) => message.conversation.id === 'qa-operator')"
91+
- call: readSessionTranscriptSummary
92+
saveAs: transcript
93+
args:
94+
- ref: env
95+
- ref: sessionKey
7196
- if:
7297
expr: "Boolean(env.mock)"
7398
then:
7499
- set: scenarioRequests
75100
value:
76-
expr: "(await fetchJson(`${env.mock.baseUrl}/debug/requests?after=${requestCursorBefore}`))"
101+
expr: "(await fetchJson(`${env.mock.baseUrl}/debug/requests?after=${requestCursorBefore}`)).filter((request) => String(request.allInputText ?? '').includes(config.promptSnippet))"
102+
- set: retryRequests
103+
value:
104+
expr: "scenarioRequests.filter((request) => String(request.allInputText ?? '').includes(config.retryNeedle))"
105+
- assert:
106+
expr: "scenarioRequests.length === 3"
107+
message:
108+
expr: "`expected read, post-tool empty, and canonical retry requests; saw ${JSON.stringify(scenarioRequests.map((request) => ({ cursor: request.cursor, tool: request.plannedToolName ?? null, callId: request.toolOutputCallId ?? null })))}`"
77109
- assert:
78-
expr: "scenarioRequests.some((request) => String(request.allInputText ?? '').includes(config.promptSnippet) && request.plannedToolName === 'read')"
79-
message: expected replay-safe read request in mock trace
110+
expr: "scenarioRequests[0]?.plannedToolName === 'read' && scenarioRequests.filter((request) => request.plannedToolName === 'read').length === 1 && retryRequests.length === 1 && scenarioRequests[2] === retryRequests[0] && String(scenarioRequests[2]?.allInputText ?? '').split(config.promptSnippet).length === 2 && String(scenarioRequests[2]?.allInputText ?? '').split(config.retryNeedle).length === 2"
111+
message: expected one replay-safe read and one final canonical retry
80112
- assert:
81-
expr: "scenarioRequests.some((request) => String(request.allInputText ?? '').includes(config.retryNeedle))"
82-
message: expected empty-response retry instruction in mock trace
83-
detailsExpr: "env.mock ? `${outbound.text}\\nrequests=${String(scenarioRequests?.length ?? 0)}` : outbound.text"
113+
expr: "typeof scenarioRequests[0]?.plannedToolCallId === 'string' && scenarioRequests[0].plannedToolCallId.length > 0 && scenarioRequests[1]?.toolOutputCallId === scenarioRequests[0].plannedToolCallId && [scenarioRequests[1], scenarioRequests[2]].every((request) => { const input = Array.isArray(request?.body?.input) ? request.body.input : []; const callIds = input.filter((item) => item?.type === 'function_call').map((item) => item.call_id); const outputIds = input.filter((item) => item?.type === 'function_call_output').map((item) => item.call_id); return callIds.length === 1 && outputIds.length === 1 && callIds[0] === outputIds[0]; })"
114+
message:
115+
expr: "`read result call id did not remain paired through the empty turn and normalized retry: ${JSON.stringify(scenarioRequests.map((request) => ({ cursor: request.cursor, plannedToolCallId: request.plannedToolCallId ?? null, toolOutputCallId: request.toolOutputCallId ?? null })))}`"
116+
- assert:
117+
expr: "[scenarioRequests[1], scenarioRequests[2]].every((request) => String(request.toolOutput ?? '').includes(config.evidenceNonce) && String(request.allInputText ?? '').includes(config.evidenceNonce))"
118+
message: authenticated read nonce did not survive into both post-tool requests
119+
- assert:
120+
expr: "transcript.userMessageCount === 2 && transcript.assistantToolCallCounts.read === 1 && transcript.completedToolCallCounts.read === 1 && transcript.successfulToolCallCounts.read === 1 && transcript.finalText.includes(config.expectedReply)"
121+
message:
122+
expr: "`recovery transcript lost requester, read-result, or final evidence: ${JSON.stringify(transcript)}`"
123+
- assert:
124+
expr: "scenarioOutbound.length === 1 && scenarioOutbound[0]?.text.trim() === config.expectedReply && !scenarioOutbound[0].text.trim().startsWith('⚠️')"
125+
message:
126+
expr: "`expected one warning-free final delivery and no intermediate success: ${JSON.stringify(scenarioOutbound.map((message) => message.text))}`"
127+
detailsExpr: "env.mock ? `${outbound.text}\\nrequests=${String(scenarioRequests?.length ?? 0)} readResults=${String(transcript.successfulToolCallCounts.read ?? 0)}` : outbound.text"

‎qa/scenarios/runtime/empty-response-retry-budget-exhausted.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ scenario:
66
coverage:
77
primary:
88
- agent-runtime.failure-recovery-empty-response-recovery
9+
- agent-runtime.progress-visibility-failure-recovery
910
secondary:
1011
- agent-runtime.failure-recovery-retry-policy
1112
objective: Verify repeated empty GPT turns exhaust each configured model's retry budget after one continuation attempt.

‎qa/scenarios/runtime/reasoning-only-no-auto-retry-after-write.yaml‎

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ scenario:
66
coverage:
77
primary:
88
- agent-runtime.failure-recovery-reasoning-only-recovery
9-
secondary:
109
- agent-runtime.failure-recovery-retry-policy
10+
- agent-runtime.failure-recovery-no-fake-progress
1111
objective: Verify a GPT-style reasoning-only turn after a mutating write stays replay-unsafe and does not auto-retry.
1212
successCriteria:
1313
- Scenario is mock-openai only so live lanes do not pick it up implicitly.
1414
- The agent performs the seeded mutating write.
1515
- Mock trace does not include an automatic reasoning-only retry instruction.
1616
- Mock trace stops after the write-side reasoning-only terminal turn instead of attempting a continuation.
17+
- Exactly one visible warning reports that side effects may already have happened.
1718
docsRefs:
1819
- docs/help/testing.md
1920
codeRefs:
@@ -28,6 +29,8 @@ scenario:
2829
prompt: "Reasoning-only after write safety check: write reasoning-only-side-effect.txt, then answer with exactly SIDE-EFFECT-GUARD-OK."
2930
retryNeedle: recorded reasoning but did not produce a user-visible answer
3031
outputFile: reasoning-only-side-effect.txt
32+
expectedWarning: "⚠️ Agent couldn't generate a response. Note: some tool actions may have already been executed — please verify before retrying."
33+
forbiddenReplyNeedles: [SIDE-EFFECT-GUARD-OK, successfully, completed, complete]
3134

3235
flow:
3336
steps:
@@ -41,6 +44,9 @@ flow:
4144
- ref: env
4245
- 60000
4346
- call: reset
47+
- set: outboundStartIndex
48+
value:
49+
expr: "state.getSnapshot().messages.filter((message) => message.direction === 'outbound').length"
4450
- set: requestCursorBefore
4551
value:
4652
expr: "env.mock ? (await fetchJson(`${env.mock.baseUrl}/debug/request-cursor`)).cursor : 0"
@@ -61,9 +67,9 @@ flow:
6167
value:
6268
expr: "await env.gateway.call('agent.wait', { runId: started.runId, timeoutMs: liveTurnTimeoutMs(env, 45000) }, { timeoutMs: liveTurnTimeoutMs(env, 50000) })"
6369
- assert:
64-
expr: "['ok', 'completed', 'succeeded'].includes(String(waited?.status)) || (waited?.status === 'error' && String(waited?.error ?? '').trim().toLowerCase() === 'completed')"
70+
expr: "String(waited?.status) === 'error' && String(waited?.error) === 'failed'"
6571
message:
66-
expr: "`agent.wait returned ${String(waited?.status ?? 'unknown')}: ${String(waited?.error ?? '')}`"
72+
expr: "`agent.wait should expose the terminal no-visible-answer failure, got ${String(waited?.status ?? 'unknown')}: ${String(waited?.error ?? '')}`"
6773
- call: fs.readFile
6874
saveAs: sideEffect
6975
args:
@@ -73,19 +79,49 @@ flow:
7379
expr: "sideEffect.includes('side effects already happened')"
7480
message:
7581
expr: "`side-effect file missing expected contents: ${sideEffect}`"
82+
- set: warning
83+
value:
84+
expr: "(async () => { const deadline = Date.now() + liveTurnTimeoutMs(env, 30000); do { const message = state.getSnapshot().messages.filter((candidate) => candidate.direction === 'outbound').slice(outboundStartIndex).find((candidate) => candidate.conversation.id === 'qa-operator' && candidate.text === config.expectedWarning); if (message) { return message; } await sleep(100); } while (Date.now() < deadline); throw new Error('timed out waiting for the side-effect warning'); })()"
85+
- call: sleep
86+
args:
87+
- 300
88+
- set: scenarioOutbound
89+
value:
90+
expr: "state.getSnapshot().messages.filter((message) => message.direction === 'outbound').slice(outboundStartIndex).filter((message) => message.conversation.id === 'qa-operator')"
91+
- call: readSessionTranscriptSummary
92+
saveAs: transcript
93+
args:
94+
- ref: env
95+
- ref: sessionKey
7696
- if:
7797
expr: "Boolean(env.mock)"
7898
then:
7999
- set: scenarioRequests
80100
value:
81-
expr: "(await fetchJson(`${env.mock.baseUrl}/debug/requests?after=${requestCursorBefore}`))"
101+
expr: "(await fetchJson(`${env.mock.baseUrl}/debug/requests?after=${requestCursorBefore}`)).filter((request) => String(request.allInputText ?? '').includes(config.promptSnippet))"
102+
- set: retryRequests
103+
value:
104+
expr: "scenarioRequests.filter((request) => String(request.allInputText ?? '').includes(config.retryNeedle))"
82105
- assert:
83-
expr: "scenarioRequests.some((request) => String(request.allInputText ?? '').includes(config.promptSnippet) && request.plannedToolName === 'write')"
84-
message: expected mutating write request in mock trace
106+
expr: "scenarioRequests.length === 2 && scenarioRequests[0]?.plannedToolName === 'write' && !scenarioRequests[1]?.plannedToolName"
107+
message:
108+
expr: "`expected exactly one write request plus one reasoning-only terminal request: ${JSON.stringify(scenarioRequests.map((request) => ({ cursor: request.cursor, tool: request.plannedToolName ?? null, callId: request.toolOutputCallId ?? null })))}`"
85109
- assert:
86-
expr: "!scenarioRequests.some((request) => String(request.allInputText ?? '').includes(config.retryNeedle))"
110+
expr: "retryRequests.length === 0"
87111
message: reasoning-only retry instruction should not be injected after a write
88112
- assert:
89-
expr: "scenarioRequests.filter((request) => String(request.allInputText ?? '').includes(config.promptSnippet)).length === 2"
90-
message: expected exactly the write request plus the reasoning-only terminal request
91-
detailsExpr: "env.mock ? `requests=${String(scenarioRequests?.length ?? 0)} sideEffect=${sideEffect.trim()}` : sideEffect"
113+
expr: "typeof scenarioRequests[0]?.plannedToolCallId === 'string' && scenarioRequests[0].plannedToolCallId.length > 0 && scenarioRequests[1]?.toolOutputCallId === scenarioRequests[0].plannedToolCallId && String(scenarioRequests[1]?.toolOutput ?? '').length > 0"
114+
message: committed write result did not match its planned tool call
115+
- assert:
116+
expr: "transcript.userMessageCount === 1 && transcript.assistantToolCallCounts.write === 1 && transcript.completedToolCallCounts.write === 1 && transcript.successfulToolCallCounts.write === 1"
117+
message:
118+
expr: "`write transcript did not persist exactly one successful side effect: ${JSON.stringify(transcript)}`"
119+
- assert:
120+
expr: "scenarioOutbound.length === 1 && warning.text === config.expectedWarning && scenarioOutbound[0]?.text === config.expectedWarning"
121+
message:
122+
expr: "`expected exactly one visible side-effect warning: ${JSON.stringify(scenarioOutbound.map((message) => message.text))}`"
123+
- assert:
124+
expr: "config.forbiddenReplyNeedles.every((needle) => !normalizeLowercaseStringOrEmpty(warning.text).includes(normalizeLowercaseStringOrEmpty(needle))) && !normalizeLowercaseStringOrEmpty(transcript.finalText).includes(normalizeLowercaseStringOrEmpty('SIDE-EFFECT-GUARD-OK'))"
125+
message:
126+
expr: "`side-effect warning or transcript claimed success/completion: warning=${warning.text} final=${transcript.finalText}`"
127+
detailsExpr: "env.mock ? `requests=${String(scenarioRequests?.length ?? 0)} writes=${String(transcript.successfulToolCallCounts.write ?? 0)} warning=${warning.text}` : sideEffect"

0 commit comments

Comments
 (0)