@paean-ai/adk 0.2.23 → 0.2.25

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.
@@ -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
  {
@@ -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,27 @@ 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 ("text" in p && typeof p.text === "string" && p.text.length > 0) return false;
1047
+ return true;
1048
+ }
1049
+ );
1050
+ if (allEmpty) {
1051
+ import_logger.logger.debug(
1052
+ `[postprocess] Skipping empty-content LLM response (${llmResponse.content.parts.length} empty parts)`
1053
+ );
1054
+ return;
1055
+ }
1056
+ }
1036
1057
  const mergedEvent = (0, import_event.createEvent)({
1037
1058
  ...modelResponseEvent,
1038
1059
  ...llmResponse
@@ -1054,8 +1075,11 @@ const _LlmAgent = class _LlmAgent extends import_base_agent.BaseAgent {
1054
1075
  }
1055
1076
  }
1056
1077
  }
1078
+ import_logger.logger.debug(
1079
+ `[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}`
1080
+ );
1057
1081
  yield mergedEvent;
1058
- if (!((_b = (0, import_event.getFunctionCalls)(mergedEvent)) == null ? void 0 : _b.length)) {
1082
+ if (!((_f = (0, import_event.getFunctionCalls)(mergedEvent)) == null ? void 0 : _f.length)) {
1059
1083
  return;
1060
1084
  }
1061
1085
  const functionResponseEvent = await (0, import_functions.handleFunctionCallsAsync)({
@@ -1080,6 +1104,9 @@ const _LlmAgent = class _LlmAgent extends import_base_agent.BaseAgent {
1080
1104
  if (toolConfirmationEvent) {
1081
1105
  yield toolConfirmationEvent;
1082
1106
  }
1107
+ import_logger.logger.debug(
1108
+ `[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}`
1109
+ );
1083
1110
  yield functionResponseEvent;
1084
1111
  const nextAgentName = functionResponseEvent.actions.transferToAgent;
1085
1112
  if (nextAgentName) {
@@ -1161,7 +1188,7 @@ const _LlmAgent = class _LlmAgent extends import_base_agent.BaseAgent {
1161
1188
  if (llmResponse.errorCode && _LlmAgent.LLM_RETRYABLE_ERROR_CODES.has(llmResponse.errorCode) && !contentYielded && attempt < maxRetries) {
1162
1189
  shouldRetry = true;
1163
1190
  import_logger.logger.warn(
1164
- `[callLlmAsync] Transient LLM error: ${llmResponse.errorCode}, usage: ${JSON.stringify(llmResponse.usageMetadata)}`
1191
+ `[callLlmAsync] Transient LLM error: ${llmResponse.errorCode}${llmResponse.errorMessage ? ": " + llmResponse.errorMessage : ""}, finishReason: ${llmResponse.finishReason || "none"}, usage: ${JSON.stringify(llmResponse.usageMetadata)}`
1165
1192
  );
1166
1193
  break;
1167
1194
  }
@@ -40,7 +40,7 @@ var import_event_actions = require("./event_actions.js");
40
40
  * SPDX-License-Identifier: Apache-2.0
41
41
  */
42
42
  function createEvent(params = {}) {
43
- return {
43
+ const event = {
44
44
  ...params,
45
45
  id: params.id || createNewEventId(),
46
46
  invocationId: params.invocationId || "",
@@ -50,6 +50,7 @@ function createEvent(params = {}) {
50
50
  branch: params.branch,
51
51
  timestamp: params.timestamp || Date.now()
52
52
  };
53
+ return event;
53
54
  }
54
55
  function isFinalResponse(event) {
55
56
  if (event.actions.skipSummarization || event.longRunningToolIds && event.longRunningToolIds.length > 0) {