mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:00:42 +00:00
fix(codex): reject unscoped bound turn events
This commit is contained in:
committed by
Peter Steinberger
parent
f7caf83da4
commit
cc87c9b120
@@ -72,6 +72,57 @@ describe("codex conversation turn collector", () => {
|
||||
await expect(completion).resolves.toEqual({ replyText: "right" });
|
||||
});
|
||||
|
||||
it("ignores unscoped deltas once the active turn is known", async () => {
|
||||
const collector = createCodexConversationTurnCollector("thread-1");
|
||||
collector.setTurnId("turn-1");
|
||||
const completion = collector.wait({ timeoutMs: 1_000 });
|
||||
|
||||
collector.handleNotification({
|
||||
method: "item/agentMessage/delta",
|
||||
params: { threadId: "thread-1", itemId: "wrong", delta: "wrong" },
|
||||
});
|
||||
collector.handleNotification({
|
||||
method: "item/agentMessage/delta",
|
||||
params: { threadId: "thread-1", turnId: "turn-1", itemId: "right", delta: "right" },
|
||||
});
|
||||
collector.handleNotification({
|
||||
method: "turn/completed",
|
||||
params: { threadId: "thread-1", turn: { id: "turn-1", status: "completed", items: [] } },
|
||||
});
|
||||
|
||||
await expect(completion).resolves.toEqual({ replyText: "right" });
|
||||
});
|
||||
|
||||
it("does not complete from unscoped turn completion once the active turn is known", async () => {
|
||||
const collector = createCodexConversationTurnCollector("thread-1");
|
||||
collector.setTurnId("turn-1");
|
||||
const completion = collector.wait({ timeoutMs: 1_000 });
|
||||
|
||||
collector.handleNotification({
|
||||
method: "turn/completed",
|
||||
params: {
|
||||
threadId: "thread-1",
|
||||
turn: {
|
||||
status: "completed",
|
||||
items: [{ type: "agentMessage", id: "wrong", text: "wrong" }],
|
||||
},
|
||||
},
|
||||
});
|
||||
collector.handleNotification({
|
||||
method: "turn/completed",
|
||||
params: {
|
||||
threadId: "thread-1",
|
||||
turn: {
|
||||
id: "turn-1",
|
||||
status: "completed",
|
||||
items: [{ type: "agentMessage", id: "right", text: "right" }],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
await expect(completion).resolves.toEqual({ replyText: "right" });
|
||||
});
|
||||
|
||||
it("rejects failed turns with the app-server error message", async () => {
|
||||
const collector = createCodexConversationTurnCollector("thread-1");
|
||||
collector.setTurnId("turn-1");
|
||||
|
||||
@@ -142,7 +142,7 @@ function isNotificationForTurn(
|
||||
return directTurnId === turnId;
|
||||
}
|
||||
const turn = isJsonObject(params.turn) ? params.turn : undefined;
|
||||
return !turn || readString(turn, "id") === turnId;
|
||||
return readString(turn, "id") === turnId;
|
||||
}
|
||||
|
||||
function readRecord(value: unknown): Record<string, unknown> | undefined {
|
||||
|
||||
Reference in New Issue
Block a user