@@ -41,9 +41,13 @@ function terminalReceipt(params: {
4141async function runFollowUp ( params ?: {
4242 alternateModel ?: string ;
4343 alternateReceiptRunId ?: string ;
44+ primaryReplyText ?: string ;
45+ primaryOutboundText ?: string ;
46+ primaryDelivery ?: { status : string ; resultCount : number } | null ;
4447 alternateReplyText ?: string ;
4548 alternateOutboundText ?: string ;
4649 alternateDelivery ?: { status : string ; resultCount : number } | null ;
50+ unrelatedPrimaryOutboundText ?: string ;
4751 unrelatedLaterOutboundText ?: string ;
4852 onRun ?: ( ) => void ;
4953} ) {
@@ -58,34 +62,39 @@ async function runFollowUp(params?: {
5862 const model = prompt . model ?? "primary-model" ;
5963 const replyText =
6064 call === 1
61- ? "hello from the primary model"
65+ ? ( params ?. primaryReplyText ?? "hello from the primary model" )
6266 : ( params ?. alternateReplyText ?? "the model switch handoff completed" ) ;
6367 state . addOutboundMessage ( {
6468 accountId : "qa-channel" ,
6569 to : "dm:qa-operator" ,
6670 text :
67- call === 2
68- ? ( params ?. alternateOutboundText ?? replyText )
69- : "hello from the primary model" ,
71+ call === 1
72+ ? ( params ?. primaryOutboundText ?? replyText )
73+ : ( params ?. alternateOutboundText ?? replyText ) ,
7074 } ) ;
75+ if ( call === 1 && params ?. unrelatedPrimaryOutboundText ) {
76+ state . addOutboundMessage ( {
77+ accountId : "qa-channel" ,
78+ to : "dm:qa-operator" ,
79+ text : params . unrelatedPrimaryOutboundText ,
80+ } ) ;
81+ }
7182 if ( call === 2 && params ?. unrelatedLaterOutboundText ) {
7283 state . addOutboundMessage ( {
7384 accountId : "qa-channel" ,
7485 to : "dm:qa-operator" ,
7586 text : params . unrelatedLaterOutboundText ,
7687 } ) ;
7788 }
89+ const terminalDelivery = call === 1 ? params ?. primaryDelivery : params ?. alternateDelivery ;
7890 return {
7991 started : { runId } ,
8092 waited : {
8193 status : "ok" ,
82- ...( call === 2 && params ?. alternateDelivery === null
94+ ...( terminalDelivery === null
8395 ? { }
8496 : {
85- terminalDelivery :
86- call === 2
87- ? ( params ?. alternateDelivery ?? { status : "sent" , resultCount : 1 } )
88- : { status : "sent" , resultCount : 1 } ,
97+ terminalDelivery : terminalDelivery ?? { status : "sent" , resultCount : 1 } ,
8998 } ) ,
9099 terminalReply : { disposition : "visible" , text : replyText } ,
91100 terminalReceipt : terminalReceipt ( {
@@ -120,6 +129,8 @@ async function runFollowUp(params?: {
120129describe ( "model-switch follow-up terminal evidence" , ( ) => {
121130 it ( "invokes the canonical alias target and records exact run-owned evidence" , async ( ) => {
122131 const { result, runAgentPrompt } = await runFollowUp ( {
132+ primaryReplyText : "hello **from the primary model**" ,
133+ primaryOutboundText : "hello from the primary model" ,
123134 alternateReplyText : "the **model switch** handoff completed" ,
124135 alternateOutboundText : "the model switch handoff completed" ,
125136 } ) ;
@@ -138,6 +149,7 @@ describe("model-switch follow-up terminal evidence", () => {
138149 } ,
139150 terminalDelivery : { status : "sent" , resultCount : 1 } ,
140151 } ) ;
152+ expect ( result . steps [ 0 ] ?. details ) . toBe ( "hello **from the primary model**" ) ;
141153 expect ( result . steps [ 1 ] ?. details ) . toBe ( "the **model switch** handoff completed" ) ;
142154 } ) ;
143155
@@ -164,6 +176,23 @@ describe("model-switch follow-up terminal evidence", () => {
164176 ) . rejects . toThrow ( "alternate-model terminal reply missed switch continuity" ) ;
165177 } ) ;
166178
179+ it . each ( [
180+ [ "missing" , null ] ,
181+ [ "suppressed" , { status : "suppressed" , resultCount : 0 } ] ,
182+ [ "zero-count" , { status : "sent" , resultCount : 0 } ] ,
183+ ] as const ) (
184+ "rejects %s primary delivery evidence despite identical and unrelated bus messages" ,
185+ async ( _ , evidence ) => {
186+ await expect (
187+ runFollowUp ( {
188+ primaryDelivery : evidence ,
189+ primaryOutboundText : "hello from the primary model" ,
190+ unrelatedPrimaryOutboundText : "an unrelated run also replied" ,
191+ } ) ,
192+ ) . rejects . toThrow ( "default-model run did not return owned sent delivery evidence" ) ;
193+ } ,
194+ ) ;
195+
167196 it . each ( [
168197 [ "missing" , null ] ,
169198 [ "suppressed" , { status : "suppressed" , resultCount : 0 } ] ,
0 commit comments