@jaypie/llm 1.2.19 → 1.2.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +25 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +25 -0
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -4427,6 +4427,19 @@ class OperateLoop {
|
|
|
4427
4427
|
status: jaypieError.status,
|
|
4428
4428
|
title: ERROR$1.BAD_FUNCTION_CALL,
|
|
4429
4429
|
});
|
|
4430
|
+
// Add error tool_result to history so the tool_use block is not orphaned.
|
|
4431
|
+
// Without this, the next turn's request would have a tool_use without a
|
|
4432
|
+
// matching tool_result, causing Anthropic API to reject with 400.
|
|
4433
|
+
const errorResult = {
|
|
4434
|
+
callId: toolCall.callId,
|
|
4435
|
+
output: JSON.stringify({
|
|
4436
|
+
error: error.message || "Tool execution failed",
|
|
4437
|
+
}),
|
|
4438
|
+
success: false,
|
|
4439
|
+
error: error.message,
|
|
4440
|
+
};
|
|
4441
|
+
const toolResultFormatted = this.adapter.formatToolResult(toolCall, errorResult);
|
|
4442
|
+
state.responseBuilder.appendToHistory(toolResultFormatted);
|
|
4430
4443
|
log$1.error(`Error executing function call ${toolCall.name}`);
|
|
4431
4444
|
log$1.var({ error });
|
|
4432
4445
|
}
|
|
@@ -4907,6 +4920,18 @@ class StreamLoop {
|
|
|
4907
4920
|
title: ERROR.BAD_FUNCTION_CALL,
|
|
4908
4921
|
},
|
|
4909
4922
|
};
|
|
4923
|
+
// Add error tool_result to history so the tool_use block is not orphaned.
|
|
4924
|
+
// Without this, the next turn's request would have a tool_use without a
|
|
4925
|
+
// matching tool_result, causing Anthropic API to reject with 400.
|
|
4926
|
+
const errorOutput = JSON.stringify({
|
|
4927
|
+
error: error.message || "Tool execution failed",
|
|
4928
|
+
});
|
|
4929
|
+
state.currentInput.push({
|
|
4930
|
+
type: exports.LlmMessageType.FunctionCallOutput,
|
|
4931
|
+
output: errorOutput,
|
|
4932
|
+
call_id: toolCall.callId,
|
|
4933
|
+
name: toolCall.name,
|
|
4934
|
+
});
|
|
4910
4935
|
log$1.error(`Error executing function call ${toolCall.name}`);
|
|
4911
4936
|
log$1.var({ error });
|
|
4912
4937
|
}
|