@@ -41,7 +41,7 @@ const QA_EMPTY_RESPONSE_RECOVERY_PROMPT =
4141const QA_EMPTY_RESPONSE_EXHAUSTION_PROMPT =
4242 "Empty response exhaustion QA check: read QA_KICKOFF_TASK.md, then answer with exactly EMPTY-EXHAUSTED-OK." ;
4343const QA_EMPTY_RESPONSE_SIDE_EFFECT_RECOVERY_PROMPT =
44- "Empty response after write recovery QA check: write qa-empty-response-side-effect.txt, then answer with exactly TELEGRAM-EMPTY-WRITE-RECOVERED-OK." ;
44+ "Empty response after write recovery QA check: write qa-empty-response-side-effect.txt, then reply with exact marker: ` TELEGRAM-EMPTY-WRITE-RECOVERED-OK` ." ;
4545const QA_ANTHROPIC_THINKING_ERROR_RECOVERY_PROMPT =
4646 "Anthropic thinking error QA check: read QA_KICKOFF_TASK.md, then answer with exactly ANTHROPIC-THINKING-ERROR-RECOVERED-OK." ;
4747const QA_REASONING_ONLY_RETRY_INSTRUCTION =
@@ -8251,66 +8251,80 @@ Update and merge these partial structured summaries.`,
82518251 expect ( secondEmpty . output ?. [ 0 ] ?. content ?. [ 0 ] ?. text ) . toBe ( "" ) ;
82528252 } ) ;
82538253
8254- it ( "scripts settled continuation after an empty response from a side-effecting write" , async ( ) => {
8255- const server = await startMockServer ( ) ;
8254+ it . each ( [
8255+ { history : "fresh" , precedingInput : [ ] } ,
8256+ {
8257+ history : "earlier reply directive" ,
8258+ precedingInput : [ makeUserInput ( "Earlier check: exact marker: `PREVIOUS-SCENARIO-OK`." ) ] ,
8259+ } ,
8260+ ] ) (
8261+ "scripts settled continuation after a side-effecting write with $history" ,
8262+ async ( { precedingInput } ) => {
8263+ const server = await startMockServer ( ) ;
82568264
8257- const toolPlan = await expectOpenAiStreamingResponsesText ( server , {
8258- input : [ makeUserInput ( QA_EMPTY_RESPONSE_SIDE_EFFECT_RECOVERY_PROMPT ) ] ,
8259- } ) ;
8260- expect ( toolPlan ) . toContain ( '"name":"write"' ) ;
8265+ const toolPlan = await expectOpenAiStreamingResponsesText ( server , {
8266+ input : [ ... precedingInput , makeUserInput ( QA_EMPTY_RESPONSE_SIDE_EFFECT_RECOVERY_PROMPT ) ] ,
8267+ } ) ;
8268+ expect ( toolPlan ) . toContain ( '"name":"write"' ) ;
82618269
8262- const toolOutput = {
8263- type : "function_call_output" as const ,
8264- output : "Successfully wrote 27 bytes to qa-empty-response-side-effect.txt" ,
8265- } ;
8266- const emptyPayload = await expectOpenAiNonStreamingResponsesJson < {
8267- output ?: Array < { content ?: Array < { text ?: string } > } > ;
8268- } > ( server , {
8269- input : [ makeUserInput ( QA_EMPTY_RESPONSE_SIDE_EFFECT_RECOVERY_PROMPT ) , toolOutput ] ,
8270- } ) ;
8271- expect ( emptyPayload . output ?. [ 0 ] ?. content ?. [ 0 ] ?. text ) . toBe ( "" ) ;
8270+ const toolOutput = {
8271+ type : "function_call_output" as const ,
8272+ output : "Successfully wrote 27 bytes to qa-empty-response-side-effect.txt" ,
8273+ } ;
8274+ const emptyPayload = await expectOpenAiNonStreamingResponsesJson < {
8275+ output ?: Array < { content ?: Array < { text ?: string } > } > ;
8276+ } > ( server , {
8277+ input : [
8278+ ...precedingInput ,
8279+ makeUserInput ( QA_EMPTY_RESPONSE_SIDE_EFFECT_RECOVERY_PROMPT ) ,
8280+ toolOutput ,
8281+ ] ,
8282+ } ) ;
8283+ expect ( emptyPayload . output ?. [ 0 ] ?. content ?. [ 0 ] ?. text ) . toBe ( "" ) ;
82728284
8273- const recoveredPayload = await expectOpenAiNonStreamingResponsesJson < {
8274- output ?: Array < { content ?: Array < { text ?: string } > } > ;
8275- } > ( server , {
8276- input : [
8277- makeUserInput ( QA_EMPTY_RESPONSE_SIDE_EFFECT_RECOVERY_PROMPT ) ,
8278- makeUserInput ( QA_SETTLED_TOOL_TERMINAL_CONTINUATION_INSTRUCTION ) ,
8279- toolOutput ,
8280- ] ,
8281- } ) ;
8282- expect ( outputText ( recoveredPayload ) ) . toBe ( "TELEGRAM-EMPTY-WRITE-RECOVERED-OK" ) ;
8285+ const recoveredPayload = await expectOpenAiNonStreamingResponsesJson < {
8286+ output ?: Array < { content ?: Array < { text ?: string } > } > ;
8287+ } > ( server , {
8288+ input : [
8289+ ...precedingInput ,
8290+ makeUserInput ( QA_EMPTY_RESPONSE_SIDE_EFFECT_RECOVERY_PROMPT ) ,
8291+ makeUserInput ( QA_SETTLED_TOOL_TERMINAL_CONTINUATION_INSTRUCTION ) ,
8292+ toolOutput ,
8293+ ] ,
8294+ } ) ;
8295+ expect ( outputText ( recoveredPayload ) ) . toBe ( "TELEGRAM-EMPTY-WRITE-RECOVERED-OK" ) ;
82838296
8284- const cronRecoveredPayload = await expectOpenAiNonStreamingResponsesJson < {
8285- output ?: Array < { content ?: Array < { text ?: string } > } > ;
8286- } > ( server , {
8287- input : [
8288- makeUserInput (
8289- [
8290- "Empty response after write recovery QA check: write once, then respond with exact marker: `CRON-EMPTY-WRITE-RECOVERED-OK`." ,
8291- "This is an unattended scheduled run. If nothing needs doing, reply exactly HEARTBEAT_OK." ,
8292- ] . join ( "\n\n" ) ,
8293- ) ,
8294- makeUserInput (
8295- `${ QA_SETTLED_TOOL_TERMINAL_CONTINUATION_INSTRUCTION } \nRead HEARTBEAT.md if it exists.` ,
8296- ) ,
8297- toolOutput ,
8298- ] ,
8299- } ) ;
8300- expect ( outputText ( cronRecoveredPayload ) ) . toBe ( "CRON-EMPTY-WRITE-RECOVERED-OK" ) ;
8297+ const cronRecoveredPayload = await expectOpenAiNonStreamingResponsesJson < {
8298+ output ?: Array < { content ?: Array < { text ?: string } > } > ;
8299+ } > ( server , {
8300+ input : [
8301+ makeUserInput (
8302+ [
8303+ "Empty response after write recovery QA check: write once, then respond with exact marker: `CRON-EMPTY-WRITE-RECOVERED-OK`." ,
8304+ "This is an unattended scheduled run. If nothing needs doing, reply exactly HEARTBEAT_OK." ,
8305+ ] . join ( "\n\n" ) ,
8306+ ) ,
8307+ makeUserInput (
8308+ `${ QA_SETTLED_TOOL_TERMINAL_CONTINUATION_INSTRUCTION } \nRead HEARTBEAT.md if it exists.` ,
8309+ ) ,
8310+ toolOutput ,
8311+ ] ,
8312+ } ) ;
8313+ expect ( outputText ( cronRecoveredPayload ) ) . toBe ( "CRON-EMPTY-WRITE-RECOVERED-OK" ) ;
83018314
8302- const laterHeartbeatPayload = await expectOpenAiNonStreamingResponsesJson < {
8303- output ?: Array < { content ?: Array < { text ?: string } > } > ;
8304- } > ( server , {
8305- input : [
8306- makeUserInput ( QA_EMPTY_RESPONSE_SIDE_EFFECT_RECOVERY_PROMPT ) ,
8307- makeUserInput ( QA_SETTLED_TOOL_TERMINAL_CONTINUATION_INSTRUCTION ) ,
8308- toolOutput ,
8309- makeUserInput ( "Read HEARTBEAT.md if it exists." ) ,
8310- ] ,
8311- } ) ;
8312- expect ( outputText ( laterHeartbeatPayload ) ) . toBe ( "HEARTBEAT_OK" ) ;
8313- } ) ;
8315+ const laterHeartbeatPayload = await expectOpenAiNonStreamingResponsesJson < {
8316+ output ?: Array < { content ?: Array < { text ?: string } > } > ;
8317+ } > ( server , {
8318+ input : [
8319+ makeUserInput ( QA_EMPTY_RESPONSE_SIDE_EFFECT_RECOVERY_PROMPT ) ,
8320+ makeUserInput ( QA_SETTLED_TOOL_TERMINAL_CONTINUATION_INSTRUCTION ) ,
8321+ toolOutput ,
8322+ makeUserInput ( "Read HEARTBEAT.md if it exists." ) ,
8323+ ] ,
8324+ } ) ;
8325+ expect ( outputText ( laterHeartbeatPayload ) ) . toBe ( "HEARTBEAT_OK" ) ;
8326+ } ,
8327+ ) ;
83148328
83158329 it ( "reports a failed Code Mode read honestly through ordinary continuation" , async ( ) => {
83168330 const server = await startMockServer ( ) ;
0 commit comments