@jaypie/llm 1.2.21 → 1.2.23
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/constants.d.ts +1 -1
- package/dist/cjs/index.cjs +54 -17
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/operate/OperateLoop.d.ts +1 -0
- package/dist/cjs/operate/types.d.ts +2 -0
- package/dist/cjs/providers/anthropic/utils.d.ts +1 -1
- package/dist/cjs/providers/gemini/utils.d.ts +1 -1
- package/dist/cjs/providers/openai/utils.d.ts +1 -1
- package/dist/cjs/providers/openrouter/utils.d.ts +1 -1
- package/dist/cjs/providers/xai/utils.d.ts +1 -1
- package/dist/cjs/util/logger.d.ts +2 -2
- package/dist/cjs/util/maxTurnsFromOptions.d.ts +1 -1
- package/dist/esm/constants.d.ts +1 -1
- package/dist/esm/index.js +54 -17
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/operate/OperateLoop.d.ts +1 -0
- package/dist/esm/operate/types.d.ts +2 -0
- package/dist/esm/providers/anthropic/utils.d.ts +1 -1
- package/dist/esm/providers/gemini/utils.d.ts +1 -1
- package/dist/esm/providers/openai/utils.d.ts +1 -1
- package/dist/esm/providers/openrouter/utils.d.ts +1 -1
- package/dist/esm/providers/xai/utils.d.ts +1 -1
- package/dist/esm/util/logger.d.ts +2 -2
- package/dist/esm/util/maxTurnsFromOptions.d.ts +1 -1
- package/package.json +1 -1
package/dist/cjs/constants.d.ts
CHANGED
|
@@ -98,7 +98,7 @@ export declare const DEFAULT: {
|
|
|
98
98
|
};
|
|
99
99
|
export declare const ALL: {
|
|
100
100
|
readonly BASE: readonly ["claude-sonnet-4-6", "gemini-3.1-pro-preview", "gpt-5.4", "grok-4.20-0309-reasoning"];
|
|
101
|
-
readonly COMBINED: readonly
|
|
101
|
+
readonly COMBINED: readonly ("claude-sonnet-4-6" | "claude-opus-4-6" | "claude-haiku-4-5" | "gemini-3.1-pro-preview" | "gemini-3-flash-preview" | "gemini-3.1-flash-lite-preview" | "gpt-5.4" | "gpt-5.4-mini" | "gpt-5.4-nano" | "grok-4.20-0309-reasoning" | "grok-4.20-0309-non-reasoning" | "grok-4-1-fast-non-reasoning")[];
|
|
102
102
|
readonly LARGE: readonly ["claude-opus-4-6", "gemini-3.1-pro-preview", "gpt-5.4", "grok-4.20-0309-reasoning"];
|
|
103
103
|
readonly SMALL: readonly ["claude-sonnet-4-6", "gemini-3-flash-preview", "gpt-5.4-mini", "grok-4.20-0309-non-reasoning"];
|
|
104
104
|
readonly TINY: readonly ["claude-haiku-4-5", "gemini-3.1-flash-lite-preview", "gpt-5.4-nano", "grok-4-1-fast-non-reasoning"];
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -151,22 +151,24 @@ const ALL = {
|
|
|
151
151
|
PROVIDER.XAI.MODEL.DEFAULT,
|
|
152
152
|
],
|
|
153
153
|
COMBINED: [
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
154
|
+
...new Set([
|
|
155
|
+
PROVIDER.ANTHROPIC.MODEL.DEFAULT,
|
|
156
|
+
PROVIDER.ANTHROPIC.MODEL.LARGE,
|
|
157
|
+
PROVIDER.ANTHROPIC.MODEL.SMALL,
|
|
158
|
+
PROVIDER.ANTHROPIC.MODEL.TINY,
|
|
159
|
+
PROVIDER.GEMINI.MODEL.DEFAULT,
|
|
160
|
+
PROVIDER.GEMINI.MODEL.LARGE,
|
|
161
|
+
PROVIDER.GEMINI.MODEL.SMALL,
|
|
162
|
+
PROVIDER.GEMINI.MODEL.TINY,
|
|
163
|
+
PROVIDER.OPENAI.MODEL.DEFAULT,
|
|
164
|
+
PROVIDER.OPENAI.MODEL.LARGE,
|
|
165
|
+
PROVIDER.OPENAI.MODEL.SMALL,
|
|
166
|
+
PROVIDER.OPENAI.MODEL.TINY,
|
|
167
|
+
PROVIDER.XAI.MODEL.DEFAULT,
|
|
168
|
+
PROVIDER.XAI.MODEL.LARGE,
|
|
169
|
+
PROVIDER.XAI.MODEL.SMALL,
|
|
170
|
+
PROVIDER.XAI.MODEL.TINY,
|
|
171
|
+
]),
|
|
170
172
|
],
|
|
171
173
|
LARGE: [
|
|
172
174
|
PROVIDER.ANTHROPIC.MODEL.LARGE,
|
|
@@ -557,7 +559,7 @@ const log$1 = getLogger$5();
|
|
|
557
559
|
|
|
558
560
|
// Turn policy constants
|
|
559
561
|
const MAX_TURNS_ABSOLUTE_LIMIT = 72;
|
|
560
|
-
const MAX_TURNS_DEFAULT_LIMIT =
|
|
562
|
+
const MAX_TURNS_DEFAULT_LIMIT = 24;
|
|
561
563
|
/**
|
|
562
564
|
* Determines the maximum number of turns based on the provided options
|
|
563
565
|
*
|
|
@@ -4149,6 +4151,7 @@ class RetryExecutor {
|
|
|
4149
4151
|
const ERROR$1 = {
|
|
4150
4152
|
BAD_FUNCTION_CALL: "Bad Function Call",
|
|
4151
4153
|
};
|
|
4154
|
+
const MAX_CONSECUTIVE_TOOL_ERRORS = 6;
|
|
4152
4155
|
//
|
|
4153
4156
|
//
|
|
4154
4157
|
// Helpers
|
|
@@ -4271,6 +4274,7 @@ class OperateLoop {
|
|
|
4271
4274
|
}
|
|
4272
4275
|
}
|
|
4273
4276
|
return {
|
|
4277
|
+
consecutiveToolErrors: 0,
|
|
4274
4278
|
currentInput: processedInput.history,
|
|
4275
4279
|
currentTurn: 0,
|
|
4276
4280
|
formattedFormat,
|
|
@@ -4395,6 +4399,8 @@ class OperateLoop {
|
|
|
4395
4399
|
output: JSON.stringify(result),
|
|
4396
4400
|
success: true,
|
|
4397
4401
|
};
|
|
4402
|
+
// Reset consecutive error counter on success
|
|
4403
|
+
state.consecutiveToolErrors = 0;
|
|
4398
4404
|
// Update provider request with tool result
|
|
4399
4405
|
currentProviderRequest = this.adapter.appendToolResult(currentProviderRequest, toolCall, formattedResult);
|
|
4400
4406
|
// Sync state from updated request
|
|
@@ -4436,6 +4442,19 @@ class OperateLoop {
|
|
|
4436
4442
|
state.responseBuilder.appendToHistory(toolResultFormatted);
|
|
4437
4443
|
log$1.error(`Error executing function call ${toolCall.name}`);
|
|
4438
4444
|
log$1.var({ error });
|
|
4445
|
+
// Track consecutive errors and stop if threshold reached
|
|
4446
|
+
state.consecutiveToolErrors++;
|
|
4447
|
+
if (state.consecutiveToolErrors >= MAX_CONSECUTIVE_TOOL_ERRORS) {
|
|
4448
|
+
const detail = `Stopped after ${MAX_CONSECUTIVE_TOOL_ERRORS} consecutive tool errors`;
|
|
4449
|
+
log$1.warn(detail);
|
|
4450
|
+
state.responseBuilder.setError({
|
|
4451
|
+
detail,
|
|
4452
|
+
status: 502,
|
|
4453
|
+
title: ERROR$1.BAD_FUNCTION_CALL,
|
|
4454
|
+
});
|
|
4455
|
+
state.responseBuilder.incomplete();
|
|
4456
|
+
return false; // Stop loop
|
|
4457
|
+
}
|
|
4439
4458
|
}
|
|
4440
4459
|
}
|
|
4441
4460
|
// Check if we've reached max turns
|
|
@@ -4683,6 +4702,7 @@ class StreamLoop {
|
|
|
4683
4702
|
? this.adapter.formatTools(toolkit, formattedFormat)
|
|
4684
4703
|
: undefined;
|
|
4685
4704
|
return {
|
|
4705
|
+
consecutiveToolErrors: 0,
|
|
4686
4706
|
currentInput: processedInput.history,
|
|
4687
4707
|
currentTurn: 0,
|
|
4688
4708
|
formattedFormat,
|
|
@@ -4876,6 +4896,8 @@ class StreamLoop {
|
|
|
4876
4896
|
result,
|
|
4877
4897
|
toolName: toolCall.name,
|
|
4878
4898
|
});
|
|
4899
|
+
// Reset consecutive error counter on success
|
|
4900
|
+
state.consecutiveToolErrors = 0;
|
|
4879
4901
|
// Yield tool result chunk
|
|
4880
4902
|
yield {
|
|
4881
4903
|
type: exports.LlmStreamChunkType.ToolResult,
|
|
@@ -4928,6 +4950,21 @@ class StreamLoop {
|
|
|
4928
4950
|
});
|
|
4929
4951
|
log$1.error(`Error executing function call ${toolCall.name}`);
|
|
4930
4952
|
log$1.var({ error });
|
|
4953
|
+
// Track consecutive errors and stop if threshold reached
|
|
4954
|
+
state.consecutiveToolErrors++;
|
|
4955
|
+
if (state.consecutiveToolErrors >= MAX_CONSECUTIVE_TOOL_ERRORS) {
|
|
4956
|
+
const stopDetail = `Stopped after ${MAX_CONSECUTIVE_TOOL_ERRORS} consecutive tool errors`;
|
|
4957
|
+
log$1.warn(stopDetail);
|
|
4958
|
+
yield {
|
|
4959
|
+
type: exports.LlmStreamChunkType.Error,
|
|
4960
|
+
error: {
|
|
4961
|
+
detail: stopDetail,
|
|
4962
|
+
status: 502,
|
|
4963
|
+
title: ERROR.BAD_FUNCTION_CALL,
|
|
4964
|
+
},
|
|
4965
|
+
};
|
|
4966
|
+
return; // Stop processing tools
|
|
4967
|
+
}
|
|
4931
4968
|
}
|
|
4932
4969
|
}
|
|
4933
4970
|
}
|