fix(sdk): classify failed/blocked tool events as tool.call.failed (#9… · openclaw/openclaw@9a54e5b
ly-wang19
·
2026-06-23
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import { normalizeGatewayEvent } from "./normalize.js"; |
| 3 | + |
| 4 | +// Terminal tool/item events are emitted with phase:"end" plus the real status |
| 5 | +// (running|completed|failed|blocked), so failed/blocked must not collapse to completed. |
| 6 | +function agentItemEvent(data: Record<string, unknown>) { |
| 7 | +return { event: "agent", payload: { runId: "r1", stream: "item", data } }; |
| 8 | +} |
| 9 | + |
| 10 | +describe("normalizeGatewayEvent terminal tool item status", () => { |
| 11 | +it("classifies a failed terminal tool item as tool.call.failed", () => { |
| 12 | +expect(normalizeGatewayEvent(agentItemEvent({ phase: "end", status: "failed" })).type).toBe( |
| 13 | +"tool.call.failed", |
| 14 | +); |
| 15 | +}); |
| 16 | + |
| 17 | +it("classifies a blocked terminal tool item as tool.call.failed", () => { |
| 18 | +expect(normalizeGatewayEvent(agentItemEvent({ phase: "end", status: "blocked" })).type).toBe( |
| 19 | +"tool.call.failed", |
| 20 | +); |
| 21 | +}); |
| 22 | + |
| 23 | +it("still classifies a completed terminal tool item as tool.call.completed", () => { |
| 24 | +expect(normalizeGatewayEvent(agentItemEvent({ phase: "end", status: "completed" })).type).toBe( |
| 25 | +"tool.call.completed", |
| 26 | +); |
| 27 | +}); |
| 28 | + |
| 29 | +it("still classifies a phase:end tool item without status as tool.call.completed", () => { |
| 30 | +expect(normalizeGatewayEvent(agentItemEvent({ phase: "end" })).type).toBe( |
| 31 | +"tool.call.completed", |
| 32 | +); |
| 33 | +}); |
| 34 | +}); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。