Skip to content

feat: Add support for more Task Message and Artifact fields in the Vertex Task Store#908

Draft
gaborfeher wants to merge 2 commits intoa2aproject:mainfrom
gaborfeher:gaborfeher-metadata
Draft

feat: Add support for more Task Message and Artifact fields in the Vertex Task Store#908
gaborfeher wants to merge 2 commits intoa2aproject:mainfrom
gaborfeher:gaborfeher-metadata

Conversation

@gaborfeher
Copy link
Collaborator

WIP

For #751

@github-actions
Copy link

🧪 Code Coverage (vs main)

⬇️ Download Full Report

Base PR Delta
src/a2a/contrib/tasks/vertex_task_converter.py 96.36% 90.91% 🔴 -5.45%
Total 91.73% 91.65% 🔴 -0.08%

Generated by coverage-comment.yml

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances the Vertex AI task converter by implementing comprehensive metadata handling and message conversion logic. It introduces versioned metadata packing/unpacking and updates artifact and task conversion to include fields such as name, description, and status details. Review feedback highlights a potential Pydantic validation error when handling invalid roles in to_sdk_message and suggests improving naming consistency for reference task IDs within the metadata dictionary.

Comment on lines +267 to +273
role = None
if stored_msg.role:
try:
role = Role(stored_msg.role)
except ValueError:
role = None

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The role field in the Message model is required, but this logic allows role to be None if stored_msg.role is invalid, not present, or an empty string. This will cause a pydantic.ValidationError at runtime when Message is instantiated. The # type: ignore on line 276 suppresses the static type error, but hides this potential runtime crash.

To ensure type safety and prevent runtime errors, you should handle the case where a valid Role cannot be determined more explicitly by raising a ValueError.

    try:
        role = Role(stored_msg.role)
    except (ValueError, TypeError) as e:
        raise ValueError(f"Invalid or missing role in stored message: {stored_msg.role!r}") from e
References
  1. For unsupported input values, fail explicitly by raising an error instead of silently falling back to a default value.

return {
'original_metadata': stored_metadata.get(_ORIGINAL_METADATA_KEY),
'extensions': stored_metadata.get(_EXTENSIONS_KEY),
'reference_tasks': stored_metadata.get(_REFERENCE_TASK_IDS_KEY),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

For consistency with the Message model's field name (reference_task_ids), it would be clearer to use 'reference_task_ids' as the key here. This would improve readability and reduce potential confusion.

This change would also require updating the key used in to_sdk_message on line 278 from 'reference_tasks' to 'reference_task_ids'.

Suggested change
'reference_tasks': stored_metadata.get(_REFERENCE_TASK_IDS_KEY),
'reference_task_ids': stored_metadata.get(_REFERENCE_TASK_IDS_KEY),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant