@@ -41,8 +41,10 @@ describe("runQaManualLane", () => {
4141 const gatewayStop = vi . fn ( ) ;
4242 const mockStop = vi . fn ( ) ;
4343 const labStop = vi . fn ( ) ;
44+ let outboundReply : string | null ;
4445
4546 beforeEach ( ( ) => {
47+ outboundReply = "Protocol note: mock reply." ;
4648 gatewayCall . mockReset ( ) ;
4749 gatewayStop . mockReset ( ) ;
4850 mockStop . mockReset ( ) ;
@@ -78,13 +80,16 @@ describe("runQaManualLane", () => {
7880 searchMessages : vi . fn ( ( ) => [ ] ) ,
7981 waitFor : vi . fn ( ) ,
8082 getSnapshot : ( ) => ( {
81- messages : [
82- {
83- direction : "outbound" ,
84- conversation : { id : "qa-operator" } ,
85- text : "Protocol note: mock reply." ,
86- } ,
87- ] ,
83+ messages :
84+ outboundReply === null
85+ ? [ ]
86+ : [
87+ {
88+ direction : "outbound" ,
89+ conversation : { id : "qa-operator" } ,
90+ text : outboundReply ,
91+ } ,
92+ ] ,
8893 } ) ,
8994 } ,
9095 stop : labStop ,
@@ -147,6 +152,97 @@ describe("runQaManualLane", () => {
147152 expect ( labStop ) . toHaveBeenCalledTimes ( 1 ) ;
148153 } ) ;
149154
155+ it . each ( [
156+ {
157+ label : "timed-out run despite a stale reply" ,
158+ waited : { status : "timeout" , error : "provider stalled" } ,
159+ reply : "stale assistant reply" ,
160+ error : "provider stalled" ,
161+ } ,
162+ {
163+ label : "failed run despite a stale reply" ,
164+ waited : { status : "error" , error : "authentication failed" } ,
165+ reply : "stale assistant reply" ,
166+ error : "authentication failed" ,
167+ } ,
168+ {
169+ label : "successful run without an outbound reply" ,
170+ waited : { status : "ok" } ,
171+ reply : null ,
172+ error : "manual lane did not produce a successful reply" ,
173+ } ,
174+ {
175+ label : "successful run with a whitespace-only reply" ,
176+ waited : { status : "ok" } ,
177+ reply : " " ,
178+ error : "manual lane did not produce a successful reply" ,
179+ } ,
180+ {
181+ label : "legacy completed run without an outbound reply" ,
182+ waited : { status : "error" , error : "completed" } ,
183+ reply : null ,
184+ error : "manual lane did not produce a successful reply" ,
185+ } ,
186+ {
187+ label : "legacy completed run with a whitespace-only reply" ,
188+ waited : { status : "error" , error : " completed " } ,
189+ reply : " " ,
190+ error : "manual lane did not produce a successful reply" ,
191+ } ,
192+ {
193+ label : "timed-out run without an outbound reply" ,
194+ waited : { status : "timeout" , error : "provider stalled" } ,
195+ reply : null ,
196+ error : "manual lane did not produce a successful reply" ,
197+ } ,
198+ {
199+ label : "failed run with a whitespace-only reply" ,
200+ waited : { status : "error" , error : "authentication failed" } ,
201+ reply : " " ,
202+ error : "manual lane did not produce a successful reply" ,
203+ } ,
204+ ] ) ( "rejects a $label after resource cleanup" , async ( { waited, reply, error } ) => {
205+ outboundReply = reply ;
206+ gatewayCall . mockReset ( ) . mockResolvedValueOnce ( { runId : "run-1" } ) . mockResolvedValueOnce ( waited ) ;
207+
208+ await expect (
209+ runQaManualLane ( {
210+ repoRoot : "/tmp/openclaw-repo" ,
211+ providerMode : "mock-openai" ,
212+ primaryModel : "mock-openai/gpt-5.6-luna" ,
213+ alternateModel : "mock-openai/gpt-5.6-luna-alt" ,
214+ message : "check the kickoff file" ,
215+ replySettleMs : 0 ,
216+ } ) ,
217+ ) . rejects . toThrow ( error ) ;
218+
219+ expect ( gatewayStop ) . toHaveBeenCalledOnce ( ) ;
220+ expect ( cleanupTransportBeforeGatewayStop ) . toHaveBeenCalledOnce ( ) ;
221+ expect ( cleanupTransportAfterGatewayStop ) . toHaveBeenCalledOnce ( ) ;
222+ expect ( mockStop ) . toHaveBeenCalledOnce ( ) ;
223+ expect ( labStop ) . toHaveBeenCalledOnce ( ) ;
224+ } ) ;
225+
226+ it . each ( [
227+ { status : "ok" } ,
228+ { status : "completed" } ,
229+ { status : "succeeded" } ,
230+ { status : "error" , error : " completed " } ,
231+ ] ) ( "accepts the canonical successful agent wait result %#" , async ( waited ) => {
232+ gatewayCall . mockReset ( ) . mockResolvedValueOnce ( { runId : "run-1" } ) . mockResolvedValueOnce ( waited ) ;
233+
234+ await expect (
235+ runQaManualLane ( {
236+ repoRoot : "/tmp/openclaw-repo" ,
237+ providerMode : "mock-openai" ,
238+ primaryModel : "mock-openai/gpt-5.6-luna" ,
239+ alternateModel : "mock-openai/gpt-5.6-luna-alt" ,
240+ message : "check the kickoff file" ,
241+ replySettleMs : 0 ,
242+ } ) ,
243+ ) . resolves . toMatchObject ( { waited, reply : "Protocol note: mock reply." } ) ;
244+ } ) ;
245+
150246 it ( "skips the mock provider bootstrap for live frontier runs" , async ( ) => {
151247 const result = await runQaManualLane ( {
152248 repoRoot : "/tmp/openclaw-repo" ,
0 commit comments