From 5fe79674d5557ee252d55932cf23d69e8f65fb8b Mon Sep 17 00:00:00 2001 From: lyon Date: Thu, 25 Jun 2026 06:53:01 +0800 Subject: [PATCH] fix: canonicalize canceled workbench final response --- internal/cloud/workbench-projection-writer.test.ts | 1 + internal/cloud/workbench-turn-projection.ts | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/cloud/workbench-projection-writer.test.ts b/internal/cloud/workbench-projection-writer.test.ts index 4a727fc8..8bf74f22 100644 --- a/internal/cloud/workbench-projection-writer.test.ts +++ b/internal/cloud/workbench-projection-writer.test.ts @@ -128,6 +128,7 @@ test("workbench projection writer seals canceled AgentRun turns with canonical c payload: { traceId: "trc_writer_canceled", status: "canceled", + finalResponse: { text: "command cancelled before backend start", status: "canceled", traceId: "trc_writer_canceled" }, userMessage: "当前 AgentRun 请求已取消;traceId/runId/commandId 已保留,可重试上一条消息。", runnerTrace: { traceId: "trc_writer_canceled", diff --git a/internal/cloud/workbench-turn-projection.ts b/internal/cloud/workbench-turn-projection.ts index 118ed3f4..bd308c92 100644 --- a/internal/cloud/workbench-turn-projection.ts +++ b/internal/cloud/workbench-turn-projection.ts @@ -188,9 +188,13 @@ function terminalTurnEvidence({ result = null, traceTerminal = null } = {}) { } function terminalFinalResponse(status, result = null, traceTerminal = null) { + if (normalizeWorkbenchStatus(status) === "canceled") return canonicalCancelFinalResponse(result, traceTerminal); const direct = traceTerminal?.finalResponse ?? result?.finalResponse; if (direct) return direct; - if (normalizeWorkbenchStatus(status) !== "canceled") return null; + return null; +} + +function canonicalCancelFinalResponse(result = null, traceTerminal = null) { return { text: CANCEL_FINAL_RESPONSE_TEXT, status: "canceled",