fix openclaw openresponses terminal event detection
This commit is contained in:
@@ -326,7 +326,6 @@ function inferSseTerminal(input: {
|
|||||||
const doneType =
|
const doneType =
|
||||||
normalizedType === "done" ||
|
normalizedType === "done" ||
|
||||||
normalizedType.endsWith(".completed") ||
|
normalizedType.endsWith(".completed") ||
|
||||||
normalizedType.endsWith(".done") ||
|
|
||||||
normalizedType === "completed";
|
normalizedType === "completed";
|
||||||
if (doneType) {
|
if (doneType) {
|
||||||
return { terminal: true, failed: false, errorMessage: null };
|
return { terminal: true, failed: false, errorMessage: null };
|
||||||
@@ -357,7 +356,7 @@ function inferSseTerminal(input: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (payloadType) {
|
if (payloadType) {
|
||||||
if (payloadType.endsWith(".completed") || payloadType.endsWith(".done")) {
|
if (payloadType.endsWith(".completed")) {
|
||||||
return { terminal: true, failed: false, errorMessage: null };
|
return { terminal: true, failed: false, errorMessage: null };
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -392,6 +392,34 @@ describe("openclaw adapter execute", () => {
|
|||||||
expect(headers["x-openclaw-session-key"]).toBe("paperclip");
|
expect(headers["x-openclaw-session-key"]).toBe("paperclip");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("does not treat response.output_text.done as a terminal OpenResponses event", async () => {
|
||||||
|
const fetchMock = vi.fn().mockResolvedValue(
|
||||||
|
sseResponse([
|
||||||
|
"event: response.output_text.done\n",
|
||||||
|
'data: {"type":"response.output_text.done","text":"partial"}\n\n',
|
||||||
|
"event: response.completed\n",
|
||||||
|
'data: {"type":"response.completed","status":"completed"}\n\n',
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
vi.stubGlobal("fetch", fetchMock);
|
||||||
|
|
||||||
|
const result = await execute(
|
||||||
|
buildContext({
|
||||||
|
url: "https://agent.example/v1/responses",
|
||||||
|
method: "POST",
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(result.exitCode).toBe(0);
|
||||||
|
expect(result.resultJson).toEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
terminal: true,
|
||||||
|
eventCount: 2,
|
||||||
|
lastEventType: "response.completed",
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it("appends wake text when OpenResponses input is provided as a message object", async () => {
|
it("appends wake text when OpenResponses input is provided as a message object", async () => {
|
||||||
const fetchMock = vi.fn().mockResolvedValue(
|
const fetchMock = vi.fn().mockResolvedValue(
|
||||||
sseResponse([
|
sseResponse([
|
||||||
|
|||||||
Reference in New Issue
Block a user