@kenkaiiii/gg-agent 5.44.0 → 5.44.2
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/index.cjs +19 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +19 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -890,6 +890,7 @@ async function* agentLoop(messages, options) {
|
|
|
890
890
|
continue;
|
|
891
891
|
}
|
|
892
892
|
}
|
|
893
|
+
const emptyExhausted = !hasActionableContent;
|
|
893
894
|
emptyResponseRetries = 0;
|
|
894
895
|
useNonStreamingFallback = false;
|
|
895
896
|
totalUsage.inputTokens += response.usage.inputTokens;
|
|
@@ -903,9 +904,11 @@ async function* agentLoop(messages, options) {
|
|
|
903
904
|
if (response.usage.cacheWrite) {
|
|
904
905
|
totalUsage.cacheWrite = (totalUsage.cacheWrite ?? 0) + response.usage.cacheWrite;
|
|
905
906
|
}
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
907
|
+
if (!emptyExhausted) {
|
|
908
|
+
messages.push(response.message);
|
|
909
|
+
latestProviderUsage = response.usage;
|
|
910
|
+
usageAnchorIndex = messages.length - 1;
|
|
911
|
+
}
|
|
909
912
|
const completedAt = Date.now();
|
|
910
913
|
const outputTokensPerSecond = providerDurationMs > 0 && response.usage.outputTokens > 0 ? response.usage.outputTokens / (providerDurationMs / 1e3) : void 0;
|
|
911
914
|
const timing = {
|
|
@@ -937,8 +940,15 @@ async function* agentLoop(messages, options) {
|
|
|
937
940
|
}
|
|
938
941
|
consecutivePauses = 0;
|
|
939
942
|
const allToolCalls = extractToolCalls(response.message.content);
|
|
940
|
-
if (response.stopReason !== "tool_use" && allToolCalls.length === 0) {
|
|
941
|
-
if (
|
|
943
|
+
if (emptyExhausted || response.stopReason !== "tool_use" && allToolCalls.length === 0) {
|
|
944
|
+
if (emptyExhausted) {
|
|
945
|
+
diag("empty_response_exhausted", {
|
|
946
|
+
provider: options.provider,
|
|
947
|
+
model: options.model,
|
|
948
|
+
stopReason: response.stopReason
|
|
949
|
+
});
|
|
950
|
+
yield { type: "truncated", reason: "empty_response", continued: false };
|
|
951
|
+
} else if (response.stopReason === "max_tokens") {
|
|
942
952
|
if (maxTokensContinuations < MAX_OUTPUT_CONTINUATIONS) {
|
|
943
953
|
maxTokensContinuations++;
|
|
944
954
|
diag("max_tokens_continuation", {
|
|
@@ -1160,6 +1170,7 @@ async function executeSingleToolCall(toolCall, options, pushEvent) {
|
|
|
1160
1170
|
let resultContent;
|
|
1161
1171
|
let details;
|
|
1162
1172
|
let isError = false;
|
|
1173
|
+
let invalidArgAttempt;
|
|
1163
1174
|
const tool = options.toolMap.get(toolCall.name);
|
|
1164
1175
|
if (!tool) {
|
|
1165
1176
|
resultContent = `Unknown tool: ${toolCall.name}`;
|
|
@@ -1194,6 +1205,7 @@ async function executeSingleToolCall(toolCall, options, pushEvent) {
|
|
|
1194
1205
|
const failureKey = `${toolCall.name}:${prettyError}`;
|
|
1195
1206
|
const failureCount = (options.invalidToolArgumentCounts.get(failureKey) ?? 0) + 1;
|
|
1196
1207
|
options.invalidToolArgumentCounts.set(failureKey, failureCount);
|
|
1208
|
+
invalidArgAttempt = failureCount;
|
|
1197
1209
|
resultContent = `Invalid arguments for tool \`${toolCall.name}\`:
|
|
1198
1210
|
` + prettyError + "\nRe-issue the call with each field as the correct type.";
|
|
1199
1211
|
if (failureCount >= 3) {
|
|
@@ -1224,7 +1236,8 @@ async function executeSingleToolCall(toolCall, options, pushEvent) {
|
|
|
1224
1236
|
result: toolResultPreview(resultContent),
|
|
1225
1237
|
details,
|
|
1226
1238
|
isError,
|
|
1227
|
-
durationMs
|
|
1239
|
+
durationMs,
|
|
1240
|
+
...invalidArgAttempt === void 0 ? {} : { invalidArgAttempt }
|
|
1228
1241
|
});
|
|
1229
1242
|
return { toolCallId: toolCall.id, content: resultContent, isError };
|
|
1230
1243
|
}
|