@@ -117,7 +117,7 @@ describe("runEmbeddedAgent incomplete-turn safety", () => {
117117 } ) ,
118118 ) ;
119119
120- const result = await runEmbeddedAgent ( {
120+ await runEmbeddedAgent ( {
121121 ...overflowBaseRunParams ,
122122 runId : "run-tool-summary-failure-count" ,
123123 } ) ;
@@ -1566,7 +1566,7 @@ describe("runEmbeddedAgent incomplete-turn safety", () => {
15661566 expectNoWarnMessageWith ( "settled post-tool turn lacked a final answer" ) ;
15671567 } ) ;
15681568
1569- it ( "returns NO_REPLY without retrying reasoning-only assistant turns when silence is allowed" , async ( ) => {
1569+ it ( "retries reasoning-only assistant turns even when deliberate silence is allowed" , async ( ) => {
15701570 mockedClassifyFailoverReason . mockReturnValue ( null ) ;
15711571 mockedRunEmbeddedAttempt . mockResolvedValueOnce (
15721572 makeAttemptResult ( {
@@ -1586,6 +1586,18 @@ describe("runEmbeddedAgent incomplete-turn safety", () => {
15861586 } as unknown as EmbeddedRunAttemptResult [ "lastAssistant" ] ,
15871587 } ) ,
15881588 ) ;
1589+ mockedRunEmbeddedAttempt . mockResolvedValueOnce (
1590+ makeAttemptResult ( {
1591+ assistantTexts : [ "Visible answer." ] ,
1592+ lastAssistant : {
1593+ role : "assistant" ,
1594+ stopReason : "end_turn" ,
1595+ provider : "openai" ,
1596+ model : "gpt-5.5" ,
1597+ content : [ { type : "text" , text : "Visible answer." } ] ,
1598+ } as unknown as EmbeddedRunAttemptResult [ "lastAssistant" ] ,
1599+ } ) ,
1600+ ) ;
15891601
15901602 const result = await runEmbeddedAgent ( {
15911603 ...overflowBaseRunParams ,
@@ -1595,14 +1607,9 @@ describe("runEmbeddedAgent incomplete-turn safety", () => {
15951607 runId : "run-reasoning-only-silent" ,
15961608 } ) ;
15971609
1598- expect ( mockedRunEmbeddedAttempt ) . toHaveBeenCalledTimes ( 1 ) ;
1599- const onlyCall = runAttemptCall ( 0 ) ;
1600- expect ( onlyCall . prompt ) . not . toContain ( REASONING_ONLY_RETRY_INSTRUCTION ) ;
1601- expect ( onlyCall . prompt ) . not . toContain ( EMPTY_RESPONSE_RETRY_INSTRUCTION ) ;
1602- expectNoWarnMessageWith ( "reasoning-only assistant turn detected" ) ;
1603- expect ( result . payloads ) . toEqual ( [ { text : "NO_REPLY" } ] ) ;
1604- expect ( result . meta . terminalReplyKind ) . toBe ( "silent-empty" ) ;
1605- expect ( result . meta . livenessState ) . toBe ( "working" ) ;
1610+ expect ( mockedRunEmbeddedAttempt ) . toHaveBeenCalledTimes ( 2 ) ;
1611+ expect ( runAttemptCall ( 1 ) . prompt ) . toBe ( REASONING_ONLY_RETRY_INSTRUCTION ) ;
1612+ expectWarnMessageWith ( "reasoning-only assistant turn detected" ) ;
16061613 } ) ;
16071614
16081615 it ( "replays an unpersisted reasoning continuation across a missing-assistant retry" , async ( ) => {
@@ -1680,7 +1687,7 @@ describe("runEmbeddedAgent incomplete-turn safety", () => {
16801687 } ) ,
16811688 ) ;
16821689
1683- const result = await runEmbeddedAgent ( {
1690+ await runEmbeddedAgent ( {
16841691 ...overflowBaseRunParams ,
16851692 provider : "openai" ,
16861693 model : "gpt-5.4" ,
@@ -4243,7 +4250,7 @@ describe("runEmbeddedAgent incomplete-turn safety", () => {
42434250 expect ( retryInstruction ) . toBe ( EMPTY_RESPONSE_RETRY_INSTRUCTION ) ;
42444251 } ) ;
42454252
4246- it ( "treats clean empty assistant turns as silent only when the caller allows it " , ( ) => {
4253+ it ( "treats clean empty assistant turns as silent only for reply-optional runs " , ( ) => {
42474254 const attempt = makeAttemptResult ( {
42484255 assistantTexts : [ ] ,
42494256 lastAssistant : {
@@ -4263,6 +4270,16 @@ describe("runEmbeddedAgent incomplete-turn safety", () => {
42634270 timedOut : false ,
42644271 attempt,
42654272 } ) ,
4273+ ) . toBe ( false ) ;
4274+ expect (
4275+ shouldTreatEmptyAssistantReplyAsSilent ( {
4276+ allowEmptyAssistantReplyAsSilent : true ,
4277+ terminalReplyExpectation : "optional" ,
4278+ payloadCount : 0 ,
4279+ aborted : false ,
4280+ timedOut : false ,
4281+ attempt,
4282+ } ) ,
42664283 ) . toBe ( true ) ;
42674284 expect (
42684285 shouldTreatEmptyAssistantReplyAsSilent ( {
@@ -4275,7 +4292,7 @@ describe("runEmbeddedAgent incomplete-turn safety", () => {
42754292 ) . toBe ( false ) ;
42764293 } ) ;
42774294
4278- it ( "treats reasoning-only assistant turns as silent only when the caller allows it " , ( ) => {
4295+ it ( "treats reasoning-only assistant turns as silent only for reply-optional runs " , ( ) => {
42794296 const attempt = makeAttemptResult ( {
42804297 assistantTexts : [ ] ,
42814298 lastAssistant : {
@@ -4301,6 +4318,16 @@ describe("runEmbeddedAgent incomplete-turn safety", () => {
43014318 timedOut : false ,
43024319 attempt,
43034320 } ) ,
4321+ ) . toBe ( false ) ;
4322+ expect (
4323+ shouldTreatEmptyAssistantReplyAsSilent ( {
4324+ allowEmptyAssistantReplyAsSilent : true ,
4325+ terminalReplyExpectation : "optional" ,
4326+ payloadCount : 0 ,
4327+ aborted : false ,
4328+ timedOut : false ,
4329+ attempt,
4330+ } ) ,
43044331 ) . toBe ( true ) ;
43054332 expect (
43064333 shouldTreatEmptyAssistantReplyAsSilent ( {
@@ -4453,9 +4480,9 @@ describe("runEmbeddedAgent incomplete-turn safety", () => {
44534480 ) . toBe ( false ) ;
44544481 } ) ;
44554482
4456- it ( "returns NO_REPLY without retrying clean empty assistant turns when silence is allowed" , async ( ) => {
4483+ it ( "retries clean empty assistant turns even when deliberate silence is allowed" , async ( ) => {
44574484 mockedClassifyFailoverReason . mockReturnValue ( null ) ;
4458- mockedRunEmbeddedAttempt . mockResolvedValue (
4485+ mockedRunEmbeddedAttempt . mockResolvedValueOnce (
44594486 makeAttemptResult ( {
44604487 assistantTexts : [ ] ,
44614488 lastAssistant : {
@@ -4467,6 +4494,18 @@ describe("runEmbeddedAgent incomplete-turn safety", () => {
44674494 } as unknown as EmbeddedRunAttemptResult [ "lastAssistant" ] ,
44684495 } ) ,
44694496 ) ;
4497+ mockedRunEmbeddedAttempt . mockResolvedValueOnce (
4498+ makeAttemptResult ( {
4499+ assistantTexts : [ "Visible answer." ] ,
4500+ lastAssistant : {
4501+ role : "assistant" ,
4502+ stopReason : "stop" ,
4503+ provider : "openai" ,
4504+ model : "gpt-5.5" ,
4505+ content : [ { type : "text" , text : "Visible answer." } ] ,
4506+ } as unknown as EmbeddedRunAttemptResult [ "lastAssistant" ] ,
4507+ } ) ,
4508+ ) ;
44704509
44714510 const result = await runEmbeddedAgent ( {
44724511 ...overflowBaseRunParams ,
@@ -4476,13 +4515,9 @@ describe("runEmbeddedAgent incomplete-turn safety", () => {
44764515 runId : "run-empty-assistant-silent" ,
44774516 } ) ;
44784517
4479- expect ( mockedRunEmbeddedAttempt ) . toHaveBeenCalledTimes ( 1 ) ;
4480- const onlyCall = runAttemptCall ( 0 ) ;
4481- expect ( onlyCall . prompt ) . not . toContain ( REASONING_ONLY_RETRY_INSTRUCTION ) ;
4482- expect ( onlyCall . prompt ) . not . toContain ( EMPTY_RESPONSE_RETRY_INSTRUCTION ) ;
4483- expect ( result . payloads ) . toEqual ( [ { text : "NO_REPLY" } ] ) ;
4484- expect ( result . meta . terminalReplyKind ) . toBe ( "silent-empty" ) ;
4485- expect ( result . meta . livenessState ) . toBe ( "working" ) ;
4518+ expect ( mockedRunEmbeddedAttempt ) . toHaveBeenCalledTimes ( 2 ) ;
4519+ expect ( runAttemptCall ( 1 ) . prompt ) . toBe ( EMPTY_RESPONSE_RETRY_INSTRUCTION ) ;
4520+ expectWarnMessageWith ( "empty response detected" ) ;
44864521 } ) ;
44874522
44884523 it ( "returns NO_REPLY without retrying exact silent assistant replies when silence is allowed" , async ( ) => {
0 commit comments