Skip to content

Commit 76fb0fb

Browse files
Autumnclaude
authored andcommitted
fix(evaluation): skip invocations without user events to prevent ValidationError
EvaluationGenerator.convert_events_to_eval_invocations previously initialized user_content as Content(parts=[]) for invocations without user-authored events. While this is a valid Content object, creating an Invocation with no meaningful user content is semantically incorrect and can cause issues downstream in the evaluation pipeline. This fix initializes user_content = None and skips the invocation if no user event is found, emitting a debug log message for diagnostics. Fixes #3760 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 4006fe4 commit 76fb0fb

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/google/adk/evaluation/evaluation_generator.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ def convert_events_to_eval_invocations(
627627
for invocation_id, events in events_by_invocation_id.items():
628628
final_response = None
629629
final_event = None
630-
user_content = Content(parts=[])
630+
user_content = None
631631
invocation_timestamp = 0
632632
app_details = None
633633
if (
@@ -663,6 +663,18 @@ def convert_events_to_eval_invocations(
663663
events_to_add.append(event)
664664
break
665665

666+
if user_content is None:
667+
# Skip invocations that have no user-authored event. Such invocations
668+
# arise from internal/system-driven turns (e.g., background agent tasks)
669+
# and are not meaningful for evaluation purposes. Including them would
670+
# also cause a Pydantic ValidationError because Invocation.user_content
671+
# requires a Content object.
672+
logger.debug(
673+
"Skipping invocation %s: no user-authored event found.",
674+
invocation_id,
675+
)
676+
continue
677+
666678
invocation_events = [
667679
InvocationEvent(author=e.author, content=e.content)
668680
for e in events_to_add

0 commit comments

Comments
 (0)