






















@@ -72,6 +72,57 @@ describe("codex conversation turn collector", () => {
7272await expect(completion).resolves.toEqual({ replyText: "right" });
7373});
747475+it("ignores unscoped deltas once the active turn is known", async () => {
76+const collector = createCodexConversationTurnCollector("thread-1");
77+collector.setTurnId("turn-1");
78+const completion = collector.wait({ timeoutMs: 1_000 });
79+80+collector.handleNotification({
81+method: "item/agentMessage/delta",
82+params: { threadId: "thread-1", itemId: "wrong", delta: "wrong" },
83+});
84+collector.handleNotification({
85+method: "item/agentMessage/delta",
86+params: { threadId: "thread-1", turnId: "turn-1", itemId: "right", delta: "right" },
87+});
88+collector.handleNotification({
89+method: "turn/completed",
90+params: { threadId: "thread-1", turn: { id: "turn-1", status: "completed", items: [] } },
91+});
92+93+await expect(completion).resolves.toEqual({ replyText: "right" });
94+});
95+96+it("does not complete from unscoped turn completion once the active turn is known", async () => {
97+const collector = createCodexConversationTurnCollector("thread-1");
98+collector.setTurnId("turn-1");
99+const completion = collector.wait({ timeoutMs: 1_000 });
100+101+collector.handleNotification({
102+method: "turn/completed",
103+params: {
104+threadId: "thread-1",
105+turn: {
106+status: "completed",
107+items: [{ type: "agentMessage", id: "wrong", text: "wrong" }],
108+},
109+},
110+});
111+collector.handleNotification({
112+method: "turn/completed",
113+params: {
114+threadId: "thread-1",
115+turn: {
116+id: "turn-1",
117+status: "completed",
118+items: [{ type: "agentMessage", id: "right", text: "right" }],
119+},
120+},
121+});
122+123+await expect(completion).resolves.toEqual({ replyText: "right" });
124+});
125+75126it("rejects failed turns with the app-server error message", async () => {
76127const collector = createCodexConversationTurnCollector("thread-1");
77128collector.setTurnId("turn-1");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。