@kenkaiiii/gg-agent 5.4.2 → 5.4.3
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 +17 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -60,6 +60,18 @@ interface AgentDoneEvent {
|
|
|
60
60
|
totalTurns: number;
|
|
61
61
|
totalUsage: Usage;
|
|
62
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Terminal signal emitted when the loop stops because it exhausted its turn
|
|
65
|
+
* budget (`maxTurns`) mid-task — i.e. the model still wanted to run tools but
|
|
66
|
+
* ran out of turns. Distinguishes a hard cut-off from a clean completion so
|
|
67
|
+
* callers (e.g. the subagent spawner) can tell the parent the output may be
|
|
68
|
+
* incomplete. Yielded immediately before the final `agent_done`.
|
|
69
|
+
*/
|
|
70
|
+
interface AgentMaxTurnsEvent {
|
|
71
|
+
type: "max_turns";
|
|
72
|
+
totalTurns: number;
|
|
73
|
+
maxTurns: number;
|
|
74
|
+
}
|
|
63
75
|
interface AgentRetryEvent {
|
|
64
76
|
type: "retry";
|
|
65
77
|
reason: "overloaded" | "rate_limit" | "provider_error" | "empty_response" | "stream_stall" | "overflow_compact" | "tool_argument_glitch";
|
|
@@ -101,7 +113,7 @@ interface AgentFollowUpMessageEvent {
|
|
|
101
113
|
type: "follow_up_message";
|
|
102
114
|
content: Message["content"];
|
|
103
115
|
}
|
|
104
|
-
type AgentEvent = AgentTextDeltaEvent | AgentThinkingDeltaEvent | AgentToolCallStartEvent | AgentToolCallUpdateEvent | AgentToolCallEndEvent | AgentToolCallDeltaEvent | AgentServerToolCallEvent | AgentServerToolResultEvent | AgentSteeringMessageEvent | AgentFollowUpMessageEvent | AgentRetryEvent | AgentTurnEndEvent | AgentDoneEvent | AgentErrorEvent;
|
|
116
|
+
type AgentEvent = AgentTextDeltaEvent | AgentThinkingDeltaEvent | AgentToolCallStartEvent | AgentToolCallUpdateEvent | AgentToolCallEndEvent | AgentToolCallDeltaEvent | AgentServerToolCallEvent | AgentServerToolResultEvent | AgentSteeringMessageEvent | AgentFollowUpMessageEvent | AgentRetryEvent | AgentTurnEndEvent | AgentDoneEvent | AgentMaxTurnsEvent | AgentErrorEvent;
|
|
105
117
|
interface AgentOptions {
|
|
106
118
|
provider: StreamOptions["provider"];
|
|
107
119
|
model: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -60,6 +60,18 @@ interface AgentDoneEvent {
|
|
|
60
60
|
totalTurns: number;
|
|
61
61
|
totalUsage: Usage;
|
|
62
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Terminal signal emitted when the loop stops because it exhausted its turn
|
|
65
|
+
* budget (`maxTurns`) mid-task — i.e. the model still wanted to run tools but
|
|
66
|
+
* ran out of turns. Distinguishes a hard cut-off from a clean completion so
|
|
67
|
+
* callers (e.g. the subagent spawner) can tell the parent the output may be
|
|
68
|
+
* incomplete. Yielded immediately before the final `agent_done`.
|
|
69
|
+
*/
|
|
70
|
+
interface AgentMaxTurnsEvent {
|
|
71
|
+
type: "max_turns";
|
|
72
|
+
totalTurns: number;
|
|
73
|
+
maxTurns: number;
|
|
74
|
+
}
|
|
63
75
|
interface AgentRetryEvent {
|
|
64
76
|
type: "retry";
|
|
65
77
|
reason: "overloaded" | "rate_limit" | "provider_error" | "empty_response" | "stream_stall" | "overflow_compact" | "tool_argument_glitch";
|
|
@@ -101,7 +113,7 @@ interface AgentFollowUpMessageEvent {
|
|
|
101
113
|
type: "follow_up_message";
|
|
102
114
|
content: Message["content"];
|
|
103
115
|
}
|
|
104
|
-
type AgentEvent = AgentTextDeltaEvent | AgentThinkingDeltaEvent | AgentToolCallStartEvent | AgentToolCallUpdateEvent | AgentToolCallEndEvent | AgentToolCallDeltaEvent | AgentServerToolCallEvent | AgentServerToolResultEvent | AgentSteeringMessageEvent | AgentFollowUpMessageEvent | AgentRetryEvent | AgentTurnEndEvent | AgentDoneEvent | AgentErrorEvent;
|
|
116
|
+
type AgentEvent = AgentTextDeltaEvent | AgentThinkingDeltaEvent | AgentToolCallStartEvent | AgentToolCallUpdateEvent | AgentToolCallEndEvent | AgentToolCallDeltaEvent | AgentServerToolCallEvent | AgentServerToolResultEvent | AgentSteeringMessageEvent | AgentFollowUpMessageEvent | AgentRetryEvent | AgentTurnEndEvent | AgentDoneEvent | AgentMaxTurnsEvent | AgentErrorEvent;
|
|
105
117
|
interface AgentOptions {
|
|
106
118
|
provider: StreamOptions["provider"];
|
|
107
119
|
model: string;
|
package/dist/index.js
CHANGED
|
@@ -189,6 +189,7 @@ async function* agentLoop(messages, options) {
|
|
|
189
189
|
const toolMap = new Map((options.tools ?? []).map((t) => [t.name, t]));
|
|
190
190
|
const totalUsage = { inputTokens: 0, outputTokens: 0 };
|
|
191
191
|
let turn = 0;
|
|
192
|
+
let hitMaxTurns = false;
|
|
192
193
|
let firstTurn = true;
|
|
193
194
|
let consecutivePauses = 0;
|
|
194
195
|
let toolPairingRepaired = false;
|
|
@@ -816,6 +817,9 @@ async function* agentLoop(messages, options) {
|
|
|
816
817
|
}
|
|
817
818
|
}
|
|
818
819
|
}
|
|
820
|
+
if (turn >= maxTurns) {
|
|
821
|
+
hitMaxTurns = true;
|
|
822
|
+
}
|
|
819
823
|
}
|
|
820
824
|
} finally {
|
|
821
825
|
sanitizeOrphanedServerTools(messages);
|
|
@@ -827,6 +831,19 @@ async function* agentLoop(messages, options) {
|
|
|
827
831
|
break;
|
|
828
832
|
}
|
|
829
833
|
}
|
|
834
|
+
if (hitMaxTurns) {
|
|
835
|
+
diag("max_turns_reached", {
|
|
836
|
+
turn,
|
|
837
|
+
maxTurns,
|
|
838
|
+
provider: options.provider,
|
|
839
|
+
model: options.model
|
|
840
|
+
});
|
|
841
|
+
yield {
|
|
842
|
+
type: "max_turns",
|
|
843
|
+
totalTurns: turn,
|
|
844
|
+
maxTurns
|
|
845
|
+
};
|
|
846
|
+
}
|
|
830
847
|
yield {
|
|
831
848
|
type: "agent_done",
|
|
832
849
|
totalTurns: turn,
|