@jaypie/llm 1.2.18 → 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 +27 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +27 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -2314,8 +2314,9 @@ class OpenAiAdapter extends BaseProviderAdapter {
|
|
|
2314
2314
|
async executeRequest(client, request, signal) {
|
|
2315
2315
|
const openai = client;
|
|
2316
2316
|
try {
|
|
2317
|
+
return await openai.responses.create(
|
|
2317
2318
|
// @ts-expect-error OpenAI SDK types don't match our request format exactly
|
|
2318
|
-
|
|
2319
|
+
request, signal ? { signal } : undefined);
|
|
2319
2320
|
}
|
|
2320
2321
|
catch (error) {
|
|
2321
2322
|
if (signal?.aborted)
|
|
@@ -4426,6 +4427,19 @@ class OperateLoop {
|
|
|
4426
4427
|
status: jaypieError.status,
|
|
4427
4428
|
title: ERROR$1.BAD_FUNCTION_CALL,
|
|
4428
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);
|
|
4429
4443
|
log$1.error(`Error executing function call ${toolCall.name}`);
|
|
4430
4444
|
log$1.var({ error });
|
|
4431
4445
|
}
|
|
@@ -4906,6 +4920,18 @@ class StreamLoop {
|
|
|
4906
4920
|
title: ERROR.BAD_FUNCTION_CALL,
|
|
4907
4921
|
},
|
|
4908
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
|
+
});
|
|
4909
4935
|
log$1.error(`Error executing function call ${toolCall.name}`);
|
|
4910
4936
|
log$1.var({ error });
|
|
4911
4937
|
}
|