@paean-ai/adk 0.2.24 → 0.2.26
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/agents/functions.js +13 -1
- package/dist/cjs/agents/llm_agent.js +33 -5
- package/dist/cjs/index.js +12 -12
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs/models/google_llm.js +56 -10
- package/dist/cjs/models/llm_response.js +7 -0
- package/dist/esm/agents/functions.js +13 -1
- package/dist/esm/agents/llm_agent.js +33 -5
- package/dist/esm/index.js +12 -12
- package/dist/esm/index.js.map +3 -3
- package/dist/esm/models/google_llm.js +56 -10
- package/dist/esm/models/llm_response.js +7 -0
- package/dist/types/models/google_llm.d.ts +4 -0
- package/dist/web/agents/functions.js +13 -1
- package/dist/web/agents/llm_agent.js +33 -5
- package/dist/web/index.js +1 -1
- package/dist/web/index.js.map +3 -3
- package/dist/web/models/google_llm.js +58 -12
- package/dist/web/models/llm_response.js +7 -0
- package/package.json +1 -1
|
@@ -129,6 +129,9 @@ function generateAuthEvent(invocationContext, functionResponseEvent) {
|
|
|
129
129
|
longRunningToolIds.add(requestEucFunctionCall.id);
|
|
130
130
|
parts.push({ functionCall: requestEucFunctionCall });
|
|
131
131
|
}
|
|
132
|
+
if (parts.length === 0) {
|
|
133
|
+
return void 0;
|
|
134
|
+
}
|
|
132
135
|
return (0, import_event.createEvent)({
|
|
133
136
|
invocationId: invocationContext.invocationId,
|
|
134
137
|
author: invocationContext.agent.name,
|
|
@@ -170,6 +173,9 @@ function generateRequestConfirmationEvent({
|
|
|
170
173
|
longRunningToolIds.add(requestConfirmationFunctionCall.id);
|
|
171
174
|
parts.push({ functionCall: requestConfirmationFunctionCall });
|
|
172
175
|
}
|
|
176
|
+
if (parts.length === 0) {
|
|
177
|
+
return void 0;
|
|
178
|
+
}
|
|
173
179
|
return (0, import_event.createEvent)({
|
|
174
180
|
invocationId: invocationContext.invocationId,
|
|
175
181
|
author: invocationContext.agent.name,
|
|
@@ -233,8 +239,9 @@ async function handleFunctionCallList({
|
|
|
233
239
|
}
|
|
234
240
|
);
|
|
235
241
|
if (!toolAndContext) {
|
|
242
|
+
const argsPreview = functionCall.args ? JSON.stringify(functionCall.args).substring(0, 300) : "(none)";
|
|
236
243
|
import_logger.logger.warn(
|
|
237
|
-
`Function "${functionCall.name}" not found in toolsDict (${Object.keys(toolsDict).length} tools registered)
|
|
244
|
+
`Function "${functionCall.name}" not found in toolsDict (${Object.keys(toolsDict).length} tools registered). Args: ${argsPreview}`
|
|
238
245
|
);
|
|
239
246
|
const errorResponseEvent = (0, import_event.createEvent)({
|
|
240
247
|
invocationId: invocationContext.invocationId,
|
|
@@ -283,6 +290,10 @@ async function handleFunctionCallList({
|
|
|
283
290
|
toolContext
|
|
284
291
|
);
|
|
285
292
|
} catch (e) {
|
|
293
|
+
const argsPreview = JSON.stringify(functionArgs).substring(0, 500);
|
|
294
|
+
import_logger.logger.error(
|
|
295
|
+
`Tool execution error: "${tool.name}" threw ${e instanceof Error ? e.message : String(e)}. Args: ${argsPreview}`
|
|
296
|
+
);
|
|
286
297
|
if (e instanceof Error) {
|
|
287
298
|
const onToolErrorResponse = await invocationContext.pluginManager.runOnToolErrorCallback(
|
|
288
299
|
{
|
|
@@ -400,6 +411,7 @@ function mergeParallelFunctionResponseEvents(functionResponseEvents) {
|
|
|
400
411
|
const actionsList = functionResponseEvents.map((event) => event.actions || {});
|
|
401
412
|
const mergedActions = (0, import_event_actions.mergeEventActions)(actionsList);
|
|
402
413
|
return (0, import_event.createEvent)({
|
|
414
|
+
invocationId: baseEvent.invocationId,
|
|
403
415
|
author: baseEvent.author,
|
|
404
416
|
branch: baseEvent.branch,
|
|
405
417
|
content: { role: "user", parts: mergedParts },
|
|
@@ -930,12 +930,12 @@ const _LlmAgent = class _LlmAgent extends import_base_agent.BaseAgent {
|
|
|
930
930
|
consecutiveErrors++;
|
|
931
931
|
if (consecutiveErrors <= _LlmAgent.MAX_AGENT_LOOP_ERROR_RETRIES) {
|
|
932
932
|
import_logger.logger.warn(
|
|
933
|
-
`[runAsyncImpl] Error event (${lastEvent.errorCode}), retrying agent loop (${consecutiveErrors}/${_LlmAgent.MAX_AGENT_LOOP_ERROR_RETRIES})`
|
|
933
|
+
`[runAsyncImpl] Error event (${lastEvent.errorCode}: ${lastEvent.errorMessage || "no message"}), retrying agent loop (${consecutiveErrors}/${_LlmAgent.MAX_AGENT_LOOP_ERROR_RETRIES})`
|
|
934
934
|
);
|
|
935
935
|
continue;
|
|
936
936
|
}
|
|
937
937
|
import_logger.logger.error(
|
|
938
|
-
`[runAsyncImpl] Max agent-loop error retries exhausted for ${lastEvent.errorCode}`
|
|
938
|
+
`[runAsyncImpl] Max agent-loop error retries exhausted for ${lastEvent.errorCode}: ${lastEvent.errorMessage || "no message"}`
|
|
939
939
|
);
|
|
940
940
|
break;
|
|
941
941
|
}
|
|
@@ -1024,7 +1024,7 @@ const _LlmAgent = class _LlmAgent extends import_base_agent.BaseAgent {
|
|
|
1024
1024
|
}
|
|
1025
1025
|
}
|
|
1026
1026
|
async *postprocess(invocationContext, llmRequest, llmResponse, modelResponseEvent) {
|
|
1027
|
-
var _a, _b;
|
|
1027
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
1028
1028
|
for (const processor of this.responseProcessors) {
|
|
1029
1029
|
for await (const event of processor.runAsync(invocationContext, llmResponse)) {
|
|
1030
1030
|
yield event;
|
|
@@ -1033,6 +1033,28 @@ const _LlmAgent = class _LlmAgent extends import_base_agent.BaseAgent {
|
|
|
1033
1033
|
if (!llmResponse.content && !llmResponse.errorCode && !llmResponse.interrupted) {
|
|
1034
1034
|
return;
|
|
1035
1035
|
}
|
|
1036
|
+
if (llmResponse.content && !llmResponse.errorCode) {
|
|
1037
|
+
if (!llmResponse.content.parts || llmResponse.content.parts.length === 0) {
|
|
1038
|
+
import_logger.logger.debug(
|
|
1039
|
+
`[postprocess] Skipping LLM response with no parts (role=${llmResponse.content.role})`
|
|
1040
|
+
);
|
|
1041
|
+
return;
|
|
1042
|
+
}
|
|
1043
|
+
const allEmpty = llmResponse.content.parts.every(
|
|
1044
|
+
(p) => {
|
|
1045
|
+
if (p.functionCall || p.functionResponse || p.executableCode || p.codeExecutionResult) return false;
|
|
1046
|
+
if (p.inlineData || p.fileData) return false;
|
|
1047
|
+
if ("text" in p && typeof p.text === "string" && p.text.length > 0) return false;
|
|
1048
|
+
return true;
|
|
1049
|
+
}
|
|
1050
|
+
);
|
|
1051
|
+
if (allEmpty) {
|
|
1052
|
+
import_logger.logger.debug(
|
|
1053
|
+
`[postprocess] Skipping empty-content LLM response (${llmResponse.content.parts.length} empty parts)`
|
|
1054
|
+
);
|
|
1055
|
+
return;
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1036
1058
|
const mergedEvent = (0, import_event.createEvent)({
|
|
1037
1059
|
...modelResponseEvent,
|
|
1038
1060
|
...llmResponse
|
|
@@ -1054,8 +1076,11 @@ const _LlmAgent = class _LlmAgent extends import_base_agent.BaseAgent {
|
|
|
1054
1076
|
}
|
|
1055
1077
|
}
|
|
1056
1078
|
}
|
|
1079
|
+
import_logger.logger.debug(
|
|
1080
|
+
`[postprocess] Yielding mergedEvent: role=${(_b = mergedEvent.content) == null ? void 0 : _b.role}, parts=${(_d = (_c = mergedEvent.content) == null ? void 0 : _c.parts) == null ? void 0 : _d.length}, hasFCs=${((_e = (0, import_event.getFunctionCalls)(mergedEvent)) == null ? void 0 : _e.length) || 0}, partial=${mergedEvent.partial}`
|
|
1081
|
+
);
|
|
1057
1082
|
yield mergedEvent;
|
|
1058
|
-
if (!((
|
|
1083
|
+
if (!((_f = (0, import_event.getFunctionCalls)(mergedEvent)) == null ? void 0 : _f.length)) {
|
|
1059
1084
|
return;
|
|
1060
1085
|
}
|
|
1061
1086
|
const functionResponseEvent = await (0, import_functions.handleFunctionCallsAsync)({
|
|
@@ -1080,6 +1105,9 @@ const _LlmAgent = class _LlmAgent extends import_base_agent.BaseAgent {
|
|
|
1080
1105
|
if (toolConfirmationEvent) {
|
|
1081
1106
|
yield toolConfirmationEvent;
|
|
1082
1107
|
}
|
|
1108
|
+
import_logger.logger.debug(
|
|
1109
|
+
`[postprocess] Yielding functionResponseEvent: role=${(_g = functionResponseEvent.content) == null ? void 0 : _g.role}, parts=${(_i = (_h = functionResponseEvent.content) == null ? void 0 : _h.parts) == null ? void 0 : _i.length}`
|
|
1110
|
+
);
|
|
1083
1111
|
yield functionResponseEvent;
|
|
1084
1112
|
const nextAgentName = functionResponseEvent.actions.transferToAgent;
|
|
1085
1113
|
if (nextAgentName) {
|
|
@@ -1161,7 +1189,7 @@ const _LlmAgent = class _LlmAgent extends import_base_agent.BaseAgent {
|
|
|
1161
1189
|
if (llmResponse.errorCode && _LlmAgent.LLM_RETRYABLE_ERROR_CODES.has(llmResponse.errorCode) && !contentYielded && attempt < maxRetries) {
|
|
1162
1190
|
shouldRetry = true;
|
|
1163
1191
|
import_logger.logger.warn(
|
|
1164
|
-
`[callLlmAsync] Transient LLM error: ${llmResponse.errorCode}, usage: ${JSON.stringify(llmResponse.usageMetadata)}`
|
|
1192
|
+
`[callLlmAsync] Transient LLM error: ${llmResponse.errorCode}${llmResponse.errorMessage ? ": " + llmResponse.errorMessage : ""}, finishReason: ${llmResponse.finishReason || "none"}, usage: ${JSON.stringify(llmResponse.usageMetadata)}`
|
|
1165
1193
|
);
|
|
1166
1194
|
break;
|
|
1167
1195
|
}
|