mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 17:00:50 +00:00
test(agents): share aborted transcript fixture
This commit is contained in:
@@ -207,10 +207,8 @@ describe("sanitizeToolUseResultPairing", () => {
|
|||||||
expect(result.added[0]?.toolCallId).toBe("call_normal");
|
expect(result.added[0]?.toolCallId).toBe("call_normal");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("retains matching tool results that follow an aborted assistant message", () => {
|
function createAbortedAssistantTranscript() {
|
||||||
// Aborted assistant turns do not synthesize missing tool results, but real
|
return castAgentMessages([
|
||||||
// matching results in the same span remain part of the repaired transcript.
|
|
||||||
const input = castAgentMessages([
|
|
||||||
{
|
{
|
||||||
role: "assistant",
|
role: "assistant",
|
||||||
content: [{ type: "toolCall", id: "call_aborted", name: "exec", arguments: {} }],
|
content: [{ type: "toolCall", id: "call_aborted", name: "exec", arguments: {} }],
|
||||||
@@ -225,6 +223,12 @@ describe("sanitizeToolUseResultPairing", () => {
|
|||||||
},
|
},
|
||||||
{ role: "user", content: "retrying" },
|
{ role: "user", content: "retrying" },
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
it("retains matching tool results that follow an aborted assistant message", () => {
|
||||||
|
// Aborted assistant turns do not synthesize missing tool results, but real
|
||||||
|
// matching results in the same span remain part of the repaired transcript.
|
||||||
|
const input = createAbortedAssistantTranscript();
|
||||||
|
|
||||||
const result = repairToolUseResultPairing(input);
|
const result = repairToolUseResultPairing(input);
|
||||||
|
|
||||||
@@ -237,21 +241,7 @@ describe("sanitizeToolUseResultPairing", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("drops matching tool results for aborted assistant messages when requested", () => {
|
it("drops matching tool results for aborted assistant messages when requested", () => {
|
||||||
const input = castAgentMessages([
|
const input = createAbortedAssistantTranscript();
|
||||||
{
|
|
||||||
role: "assistant",
|
|
||||||
content: [{ type: "toolCall", id: "call_aborted", name: "exec", arguments: {} }],
|
|
||||||
stopReason: "aborted",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
role: "toolResult",
|
|
||||||
toolCallId: "call_aborted",
|
|
||||||
toolName: "exec",
|
|
||||||
content: [{ type: "text", text: "partial result" }],
|
|
||||||
isError: false,
|
|
||||||
},
|
|
||||||
{ role: "user", content: "retrying" },
|
|
||||||
]);
|
|
||||||
|
|
||||||
const result = repairToolUseResultPairing(input, {
|
const result = repairToolUseResultPairing(input, {
|
||||||
erroredAssistantResultPolicy: "drop",
|
erroredAssistantResultPolicy: "drop",
|
||||||
|
|||||||
Reference in New Issue
Block a user