mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 19:10:58 +00:00
fix: align SDK wait and protocol contracts
This commit is contained in:
@@ -64,7 +64,13 @@ function runStatusFromWaitPayload(payload: unknown): RunResult["status"] {
|
||||
if (status === "ok" || status === "completed" || status === "succeeded") {
|
||||
return "completed";
|
||||
}
|
||||
if (status === "timeout" || status === "timed_out") {
|
||||
if (status === "timeout") {
|
||||
if (stopReason === "timeout" || stopReason === "timed_out" || record.aborted === true) {
|
||||
return "timed_out";
|
||||
}
|
||||
return "accepted";
|
||||
}
|
||||
if (status === "timed_out") {
|
||||
return "timed_out";
|
||||
}
|
||||
if (status === "accepted") {
|
||||
|
||||
@@ -136,6 +136,41 @@ describe("OpenClaw SDK", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps wait-only deadlines non-terminal", async () => {
|
||||
const transport = new FakeTransport({
|
||||
"agent.wait": { status: "timeout", runId: "run_still_active" },
|
||||
});
|
||||
const oc = new OpenClaw({ transport });
|
||||
|
||||
const result = await oc.runs.wait("run_still_active");
|
||||
|
||||
expect(result).toMatchObject({
|
||||
runId: "run_still_active",
|
||||
status: "accepted",
|
||||
});
|
||||
expect(result.error).toBeUndefined();
|
||||
});
|
||||
|
||||
it("maps terminal runtime timeout snapshots to timed_out", async () => {
|
||||
const transport = new FakeTransport({
|
||||
"agent.wait": {
|
||||
status: "timeout",
|
||||
runId: "run_timed_out",
|
||||
stopReason: "timeout",
|
||||
error: "agent runtime timeout",
|
||||
},
|
||||
});
|
||||
const oc = new OpenClaw({ transport });
|
||||
|
||||
const result = await oc.runs.wait("run_timed_out");
|
||||
|
||||
expect(result).toMatchObject({
|
||||
runId: "run_timed_out",
|
||||
status: "timed_out",
|
||||
error: { message: "agent runtime timeout" },
|
||||
});
|
||||
});
|
||||
|
||||
it("splits provider-qualified model refs and rejects unsupported run options", async () => {
|
||||
const transport = new FakeTransport({
|
||||
agent: { status: "accepted", runId: "run_openrouter" },
|
||||
|
||||
Reference in New Issue
Block a user