Skip to content

Commit e06e804

Browse files
authored
fix(qa): reject incomplete manual lane responses (#129395)
* fix(qa): reject incomplete manual lane responses * fix(qa): preserve missing-reply failure diagnostics
1 parent 0ea03f3 commit e06e804

2 files changed

Lines changed: 112 additions & 15 deletions

File tree

‎extensions/qa-lab/src/manual-lane.runtime.test.ts‎

Lines changed: 103 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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",

‎extensions/qa-lab/src/manual-lane.runtime.ts‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,7 @@ export async function runQaManualLane(params: QaManualLaneParams) {
174174
candidate.direction === "outbound" && candidate.conversation.id === "qa-operator",
175175
)?.text ?? null;
176176

177-
result = {
178-
model: params.primaryModel,
179-
waited,
180-
reply,
181-
watchUrl: lab.baseUrl,
182-
};
177+
result = { model: params.primaryModel, waited, reply, watchUrl: lab.baseUrl };
183178
} catch (error) {
184179
runError = error;
185180
} finally {
@@ -208,8 +203,14 @@ export async function runQaManualLane(params: QaManualLaneParams) {
208203
throw cleanupError;
209204
}
210205

211-
if (!result) {
212-
throw new Error("manual lane did not produce a result");
206+
if (
207+
!result?.reply?.trim() ||
208+
(result.waited.status === "error"
209+
? result.waited.error?.trim().toLowerCase() !== "completed"
210+
: !["ok", "completed", "succeeded"].includes(result.waited.status ?? ""))
211+
) {
212+
const providerError = result?.reply?.trim() && result.waited.error;
213+
throw new Error(providerError || "manual lane did not produce a successful reply");
213214
}
214215
return result;
215216
}

0 commit comments

Comments
 (0)