fix: keep failed ACP tools valid in conversation history (#9467)

Co-authored-by: Tianyu Yang <yangtianyu.cl@bytedance.com>
This commit is contained in:
paseo-bot[bot]andTianyu Yang authored and GitHub committed 2026-11-12 15:14:46 +00:00
1 parent aa7cabb455
commit 4df5307eaa
2 files changed
+70 -1

No files matched your search

@@ -1527,7 +1527,9 @@ function toolTimelineItem(snapshot: AcpToolCallSnapshot): ToolCallTimelineItem {
name: snapshot.name ?? snapshot.title,
detail,
};
if (status === "failed") return { ...base, status, error: snapshot.output };
if (status === "failed") {
return { ...base, status, error: snapshot.output ?? { message: "Tool failed" } };
}
return { ...base, status, error: null };
}
+67
View File
@@ -9,6 +9,7 @@ import {
} from "@agentclientprotocol/sdk";
import type { ProviderConnection, ProviderEvent, ProviderInput } from "./provider.js";
import { afterEach, describe, expect, it } from "vitest";
import { AgentTimelineItemPayloadSchema } from "@getpaseo/protocol/messages";
import { runAcpProvider, type AcpStreamMessage } from "./acp.js";
const temporaryDirectories: string[] = [];
@@ -890,6 +891,72 @@ lines.on("line", (line) => {
},
);
it.each([
{ status: "failed", output: undefined, error: { message: "Tool failed" } },
{ status: "failed", output: null, error: { message: "Tool failed" } },
{
status: "failed",
output: { message: "File not found" },
error: { message: "File not found" },
},
{ status: "failed", output: "Permission denied", error: "Permission denied" },
{ status: "completed", output: null, error: null },
] as const)(
"keeps a $status ACP tool with output $output valid on the history wire",
async ({ status, output, error }) => {
const harness = connectorHarness({
promptUpdates: () => [
{
sessionUpdate: "tool_call",
toolCallId: "read-1",
title: "Read file",
kind: "read",
status: "in_progress",
},
{ sessionUpdate: "tool_call_update", toolCallId: "read-1", status, rawOutput: output },
],
});
const registration = runAcpProvider({
id: "tool-history-acp",
label: "Tool history ACP",
connector: harness.connector,
});
const connection = await registration.connect({
versions: [1],
capabilities: ["prompt.message"],
});
const events: ProviderEvent[] = [];
connection.onEvent((event) => events.push(event));
try {
await connection.send(openInput());
await waitForEvent(events, (event) => event.type === "session.ready");
await connection.send({
type: "session.prompt",
sessionId: "session-1",
prompt: {
clientMessageId: "first",
delivery: "auto",
input: { type: "message", content: [{ type: "text", text: "Read a file" }] },
},
});
await waitForEvent(
events,
(event) => event.type === "session.turn" && event.state === "completed",
);
const rows = events.flatMap((event) =>
event.type === "timeline.item" && event.item.id === "read-1" ? [event.item] : [],
);
expect(rows).toHaveLength(2);
for (const row of rows) {
expect(AgentTimelineItemPayloadSchema.safeParse(row).success).toBe(true);
}
expect(rows.at(-1)).toMatchObject({ type: "tool_call", status, error });
} finally {
await connection.close();
}
},
);
it("serializes configuration mutations", async () => {
let releaseMutation: (() => void) | null = null;
const configOptions = [