Open
Description
In the tutorial on Agent Team, I discovered a condition :
if event.content and event.content.parts
. The class definition of google.genai.Content is as follows (as of 20 June 2025 IST):
class Content(_common.BaseModel):
"""Contains the multi-part content of a message."""
parts: Optional[list[Part]] = Field(
default=None,
description="""List of parts that constitute a single message. Each part may have
a different IANA MIME type.""",
)
role: Optional[str] = Field(
default=None,
description="""Optional. The producer of the content. Must be either 'user' or
'model'. Useful to set for multi-turn conversations, otherwise can be
empty. If role is not specified, SDK will determine the role.""",
)
There is not a separate validation, but it is safe to assume that there will not be any response which has a role
, but no parts
.
Now even if you do encounter a possibility where out of user
or model
(as role
field) , only role
is set, then is not it a vague design from the genai repo? I mean there is a role but empty list as output. Do you think a model_after_validator
is required either in event
, or in google.genai.types.Content
?