@kenkaiiii/gg-agent 5.44.1 → 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 +15 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +15 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -140,7 +140,7 @@ interface AgentTurnBudgetExtendedEvent {
|
|
|
140
140
|
*/
|
|
141
141
|
interface AgentTruncatedEvent {
|
|
142
142
|
type: "truncated";
|
|
143
|
-
reason: "max_tokens" | "refusal" | "provider_error";
|
|
143
|
+
reason: "max_tokens" | "refusal" | "provider_error" | "empty_response";
|
|
144
144
|
/** True when the loop injected a continuation and will keep going. */
|
|
145
145
|
continued: boolean;
|
|
146
146
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -140,7 +140,7 @@ interface AgentTurnBudgetExtendedEvent {
|
|
|
140
140
|
*/
|
|
141
141
|
interface AgentTruncatedEvent {
|
|
142
142
|
type: "truncated";
|
|
143
|
-
reason: "max_tokens" | "refusal" | "provider_error";
|
|
143
|
+
reason: "max_tokens" | "refusal" | "provider_error" | "empty_response";
|
|
144
144
|
/** True when the loop injected a continuation and will keep going. */
|
|
145
145
|
continued: boolean;
|
|
146
146
|
}
|
package/dist/index.js
CHANGED
|
@@ -864,6 +864,7 @@ async function* agentLoop(messages, options) {
|
|
|
864
864
|
continue;
|
|
865
865
|
}
|
|
866
866
|
}
|
|
867
|
+
const emptyExhausted = !hasActionableContent;
|
|
867
868
|
emptyResponseRetries = 0;
|
|
868
869
|
useNonStreamingFallback = false;
|
|
869
870
|
totalUsage.inputTokens += response.usage.inputTokens;
|
|
@@ -877,9 +878,11 @@ async function* agentLoop(messages, options) {
|
|
|
877
878
|
if (response.usage.cacheWrite) {
|
|
878
879
|
totalUsage.cacheWrite = (totalUsage.cacheWrite ?? 0) + response.usage.cacheWrite;
|
|
879
880
|
}
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
881
|
+
if (!emptyExhausted) {
|
|
882
|
+
messages.push(response.message);
|
|
883
|
+
latestProviderUsage = response.usage;
|
|
884
|
+
usageAnchorIndex = messages.length - 1;
|
|
885
|
+
}
|
|
883
886
|
const completedAt = Date.now();
|
|
884
887
|
const outputTokensPerSecond = providerDurationMs > 0 && response.usage.outputTokens > 0 ? response.usage.outputTokens / (providerDurationMs / 1e3) : void 0;
|
|
885
888
|
const timing = {
|
|
@@ -911,8 +914,15 @@ async function* agentLoop(messages, options) {
|
|
|
911
914
|
}
|
|
912
915
|
consecutivePauses = 0;
|
|
913
916
|
const allToolCalls = extractToolCalls(response.message.content);
|
|
914
|
-
if (response.stopReason !== "tool_use" && allToolCalls.length === 0) {
|
|
915
|
-
if (
|
|
917
|
+
if (emptyExhausted || response.stopReason !== "tool_use" && allToolCalls.length === 0) {
|
|
918
|
+
if (emptyExhausted) {
|
|
919
|
+
diag("empty_response_exhausted", {
|
|
920
|
+
provider: options.provider,
|
|
921
|
+
model: options.model,
|
|
922
|
+
stopReason: response.stopReason
|
|
923
|
+
});
|
|
924
|
+
yield { type: "truncated", reason: "empty_response", continued: false };
|
|
925
|
+
} else if (response.stopReason === "max_tokens") {
|
|
916
926
|
if (maxTokensContinuations < MAX_OUTPUT_CONTINUATIONS) {
|
|
917
927
|
maxTokensContinuations++;
|
|
918
928
|
diag("max_tokens_continuation", {
|