Replay completed tool results from provider history
This commit is contained in:
@@ -56,6 +56,49 @@ describe("convertClaudeHistoryEntry", () => {
|
|||||||
expect(Array.isArray(mapBlocks.mock.calls[0][0])).toBe(true);
|
expect(Array.isArray(mapBlocks.mock.calls[0][0])).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("replays persisted Claude tool results as completed tool calls", () => {
|
||||||
|
const entry = {
|
||||||
|
type: "user",
|
||||||
|
message: {
|
||||||
|
role: "user",
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
type: "tool_result",
|
||||||
|
tool_use_id: "toolu_persisted",
|
||||||
|
content: "done",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
toolUseResult: {
|
||||||
|
stdout: "done",
|
||||||
|
stderr: "",
|
||||||
|
interrupted: false,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const completedToolCall: AgentTimelineItem[] = [
|
||||||
|
{
|
||||||
|
type: "tool_call",
|
||||||
|
callId: "toolu_persisted",
|
||||||
|
name: "Bash",
|
||||||
|
status: "completed",
|
||||||
|
detail: {
|
||||||
|
type: "shell",
|
||||||
|
command: "echo done",
|
||||||
|
output: "done",
|
||||||
|
exitCode: 0,
|
||||||
|
},
|
||||||
|
error: null,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const mapPersistedToolResultBlocks = (): AgentTimelineItem[] => completedToolCall;
|
||||||
|
|
||||||
|
expect(convertClaudeHistoryEntry(entry, mapPersistedToolResultBlocks)).toEqual(
|
||||||
|
completedToolCall,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test("returns user messages when no tool blocks exist", () => {
|
test("returns user messages when no tool blocks exist", () => {
|
||||||
const entry = {
|
const entry = {
|
||||||
type: "user",
|
type: "user",
|
||||||
|
|||||||
@@ -1188,7 +1188,7 @@ function isToolResultUserEntry(entry: unknown): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isSyntheticHistoryUserEntry(entry: Record<string, unknown>): boolean {
|
function isSyntheticHistoryUserEntry(entry: Record<string, unknown>): boolean {
|
||||||
return isSyntheticUserEntry(entry);
|
return isSyntheticUserEntry(entry) && !isToolResultUserEntry(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
function firstTrimmedString(sources: readonly unknown[]): string | null {
|
function firstTrimmedString(sources: readonly unknown[]): string | null {
|
||||||
@@ -4666,7 +4666,7 @@ function convertClaudeHistoryEntryPreamble(
|
|||||||
if (entry.isCompactSummary) {
|
if (entry.isCompactSummary) {
|
||||||
return { shortCircuit: [] };
|
return { shortCircuit: [] };
|
||||||
}
|
}
|
||||||
if (entry.type === "user" && isSyntheticUserEntry(entry)) {
|
if (entry.type === "user" && isSyntheticHistoryUserEntry(entry)) {
|
||||||
return { shortCircuit: [] };
|
return { shortCircuit: [] };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user