@@ -1752,7 +1752,7 @@ describe("runEmbeddedAgent incomplete-turn safety", () => {
17521752 expectNoWarnMessageWith ( "settled post-tool turn lacked a final answer" ) ;
17531753 } ) ;
17541754
1755- it ( "returns NO_REPLY without retrying reasoning-only assistant turns when silence is allowed" , async ( ) => {
1755+ it ( "retries reasoning-only assistant turns even when deliberate silence is allowed" , async ( ) => {
17561756 mockedClassifyFailoverReason . mockReturnValue ( null ) ;
17571757 mockedRunEmbeddedAttempt . mockResolvedValueOnce (
17581758 makeAttemptResult ( {
@@ -1772,23 +1772,30 @@ describe("runEmbeddedAgent incomplete-turn safety", () => {
17721772 } as unknown as EmbeddedRunAttemptResult [ "lastAssistant" ] ,
17731773 } ) ,
17741774 ) ;
1775+ mockedRunEmbeddedAttempt . mockResolvedValueOnce (
1776+ makeAttemptResult ( {
1777+ assistantTexts : [ "Visible answer." ] ,
1778+ lastAssistant : {
1779+ role : "assistant" ,
1780+ stopReason : "end_turn" ,
1781+ provider : "openai" ,
1782+ model : "gpt-5.5" ,
1783+ content : [ { type : "text" , text : "Visible answer." } ] ,
1784+ } as unknown as EmbeddedRunAttemptResult [ "lastAssistant" ] ,
1785+ } ) ,
1786+ ) ;
17751787
1776- const result = await runEmbeddedAgent ( {
1788+ await runEmbeddedAgent ( {
17771789 ...overflowBaseRunParams ,
17781790 allowEmptyAssistantReplyAsSilent : true ,
17791791 provider : "openai" ,
17801792 model : "gpt-5.5" ,
17811793 runId : "run-reasoning-only-silent" ,
17821794 } ) ;
17831795
1784- expect ( mockedRunEmbeddedAttempt ) . toHaveBeenCalledTimes ( 1 ) ;
1785- const onlyCall = runAttemptCall ( 0 ) ;
1786- expect ( onlyCall . prompt ) . not . toContain ( REASONING_ONLY_RETRY_INSTRUCTION ) ;
1787- expect ( onlyCall . prompt ) . not . toContain ( EMPTY_RESPONSE_RETRY_INSTRUCTION ) ;
1788- expectNoWarnMessageWith ( "reasoning-only assistant turn detected" ) ;
1789- expect ( result . payloads ) . toEqual ( [ { text : "NO_REPLY" } ] ) ;
1790- expect ( result . meta . terminalReplyKind ) . toBe ( "silent-empty" ) ;
1791- expect ( result . meta . livenessState ) . toBe ( "working" ) ;
1796+ expect ( mockedRunEmbeddedAttempt ) . toHaveBeenCalledTimes ( 2 ) ;
1797+ expect ( runAttemptCall ( 1 ) . prompt ) . toBe ( REASONING_ONLY_RETRY_INSTRUCTION ) ;
1798+ expectWarnMessageWith ( "reasoning-only assistant turn detected" ) ;
17921799 } ) ;
17931800
17941801 it ( "replays an unpersisted reasoning continuation across a missing-assistant retry" , async ( ) => {
@@ -4618,7 +4625,7 @@ describe("runEmbeddedAgent incomplete-turn safety", () => {
46184625 expect ( retryInstruction ) . toBe ( EMPTY_RESPONSE_RETRY_INSTRUCTION ) ;
46194626 } ) ;
46204627
4621- it ( "treats clean empty assistant turns as silent only when the caller allows it " , ( ) => {
4628+ it ( "treats clean empty assistant turns as silent only for reply-optional runs " , ( ) => {
46224629 const attempt = makeAttemptResult ( {
46234630 assistantTexts : [ ] ,
46244631 lastAssistant : {
@@ -4638,6 +4645,16 @@ describe("runEmbeddedAgent incomplete-turn safety", () => {
46384645 timedOut : false ,
46394646 attempt,
46404647 } ) ,
4648+ ) . toBe ( false ) ;
4649+ expect (
4650+ shouldTreatEmptyAssistantReplyAsSilent ( {
4651+ allowEmptyAssistantReplyAsSilent : true ,
4652+ terminalReplyExpectation : "optional" ,
4653+ payloadCount : 0 ,
4654+ aborted : false ,
4655+ timedOut : false ,
4656+ attempt,
4657+ } ) ,
46414658 ) . toBe ( true ) ;
46424659 expect (
46434660 shouldTreatEmptyAssistantReplyAsSilent ( {
@@ -4650,7 +4667,7 @@ describe("runEmbeddedAgent incomplete-turn safety", () => {
46504667 ) . toBe ( false ) ;
46514668 } ) ;
46524669
4653- it ( "treats reasoning-only assistant turns as silent only when the caller allows it " , ( ) => {
4670+ it ( "treats reasoning-only assistant turns as silent only for reply-optional runs " , ( ) => {
46544671 const attempt = makeAttemptResult ( {
46554672 assistantTexts : [ ] ,
46564673 lastAssistant : {
@@ -4676,6 +4693,16 @@ describe("runEmbeddedAgent incomplete-turn safety", () => {
46764693 timedOut : false ,
46774694 attempt,
46784695 } ) ,
4696+ ) . toBe ( false ) ;
4697+ expect (
4698+ shouldTreatEmptyAssistantReplyAsSilent ( {
4699+ allowEmptyAssistantReplyAsSilent : true ,
4700+ terminalReplyExpectation : "optional" ,
4701+ payloadCount : 0 ,
4702+ aborted : false ,
4703+ timedOut : false ,
4704+ attempt,
4705+ } ) ,
46794706 ) . toBe ( true ) ;
46804707 expect (
46814708 shouldTreatEmptyAssistantReplyAsSilent ( {
@@ -4828,9 +4855,9 @@ describe("runEmbeddedAgent incomplete-turn safety", () => {
48284855 ) . toBe ( false ) ;
48294856 } ) ;
48304857
4831- it ( "returns NO_REPLY without retrying clean empty assistant turns when silence is allowed" , async ( ) => {
4858+ it ( "retries clean empty assistant turns even when deliberate silence is allowed" , async ( ) => {
48324859 mockedClassifyFailoverReason . mockReturnValue ( null ) ;
4833- mockedRunEmbeddedAttempt . mockResolvedValue (
4860+ mockedRunEmbeddedAttempt . mockResolvedValueOnce (
48344861 makeAttemptResult ( {
48354862 assistantTexts : [ ] ,
48364863 lastAssistant : {
@@ -4842,22 +4869,30 @@ describe("runEmbeddedAgent incomplete-turn safety", () => {
48424869 } as unknown as EmbeddedRunAttemptResult [ "lastAssistant" ] ,
48434870 } ) ,
48444871 ) ;
4872+ mockedRunEmbeddedAttempt . mockResolvedValueOnce (
4873+ makeAttemptResult ( {
4874+ assistantTexts : [ "Visible answer." ] ,
4875+ lastAssistant : {
4876+ role : "assistant" ,
4877+ stopReason : "stop" ,
4878+ provider : "openai" ,
4879+ model : "gpt-5.5" ,
4880+ content : [ { type : "text" , text : "Visible answer." } ] ,
4881+ } as unknown as EmbeddedRunAttemptResult [ "lastAssistant" ] ,
4882+ } ) ,
4883+ ) ;
48454884
4846- const result = await runEmbeddedAgent ( {
4885+ await runEmbeddedAgent ( {
48474886 ...overflowBaseRunParams ,
48484887 allowEmptyAssistantReplyAsSilent : true ,
48494888 provider : "openai" ,
48504889 model : "gpt-5.5" ,
48514890 runId : "run-empty-assistant-silent" ,
48524891 } ) ;
48534892
4854- expect ( mockedRunEmbeddedAttempt ) . toHaveBeenCalledTimes ( 1 ) ;
4855- const onlyCall = runAttemptCall ( 0 ) ;
4856- expect ( onlyCall . prompt ) . not . toContain ( REASONING_ONLY_RETRY_INSTRUCTION ) ;
4857- expect ( onlyCall . prompt ) . not . toContain ( EMPTY_RESPONSE_RETRY_INSTRUCTION ) ;
4858- expect ( result . payloads ) . toEqual ( [ { text : "NO_REPLY" } ] ) ;
4859- expect ( result . meta . terminalReplyKind ) . toBe ( "silent-empty" ) ;
4860- expect ( result . meta . livenessState ) . toBe ( "working" ) ;
4893+ expect ( mockedRunEmbeddedAttempt ) . toHaveBeenCalledTimes ( 2 ) ;
4894+ expect ( runAttemptCall ( 1 ) . prompt ) . toBe ( EMPTY_RESPONSE_RETRY_INSTRUCTION ) ;
4895+ expectWarnMessageWith ( "empty response detected" ) ;
48614896 } ) ;
48624897
48634898 it ( "returns NO_REPLY without retrying exact silent assistant replies when silence is allowed" , async ( ) => {
0 commit comments