Skip to content

fix: migrate to a2a-sdk v1.0 protobuf types#59

Merged
beonde merged 1 commit into
mainfrom
fix/a2a-sdk-v1-migration
May 3, 2026
Merged

fix: migrate to a2a-sdk v1.0 protobuf types#59
beonde merged 1 commit into
mainfrom
fix/a2a-sdk-v1-migration

Conversation

@beonde
Copy link
Copy Markdown
Member

@beonde beonde commented May 3, 2026

Summary

Migrates all code from a2a-sdk v0.x Pydantic models to v1.0 protobuf-generated types. This fixes the Cross-Product E2E Tests CI failure that has been failing on every main branch commit:

ImportError: cannot import name 'TextPart' from 'a2a.types'

Changes

Type Migration (tests/integration/test_real_executor.py)

v0.x (removed) v1.0 (new)
TextPart(text=...) Part(text=...)
FilePart(file=FileWithBytes(...)) Part(raw=..., media_type=..., filename=...)
FilePart(file=FileWithUri(...)) Part(url=..., media_type=..., filename=...)
DataPart(data={...}) Part(data=Value()) via ParseDict
MessageSendParams(message=msg) SendMessageRequest(message=msg)
Role.user / Role.agent Role.ROLE_USER / Role.ROLE_AGENT
new_agent_text_message(text) Message(role=ROLE_AGENT, parts=[Part(text=...)])
RequestContext(request=params) RequestContext(call_context=ServerCallContext(), request=params)

SDK Compatibility (capiscio_sdk/executor.py)

  • Added protobuf MessageToDict support for message-to-dict conversion
  • Previously only supported Pydantic model_dump(), falling back to {} for protobuf messages
  • Now properly serializes protobuf Message objects for validation

Dependency Update (pyproject.toml)

  • a2a-sdk>=0.1.0a2a-sdk>=1.0.0

Examples (examples/simple_agent/)

  • Updated agent_executor.py and test_client.py for v1.0 types

Testing

  • All 20+ integration tests in test_real_executor.py updated
  • CI should now pass the Cross-Product E2E Tests job

BREAKING: Updates all code from a2a-sdk v0.x Pydantic models to v1.0
protobuf-generated types:

- TextPart/FilePart/DataPart → unified Part with text/raw/url/data fields
- MessageSendParams → SendMessageRequest
- Role.user/Role.agent → Role.ROLE_USER/Role.ROLE_AGENT
- FileWithBytes/FileWithUri → Part(raw=...) / Part(url=...)
- new_agent_text_message() → construct Message directly
- RequestContext now requires ServerCallContext
- Message metadata now uses protobuf Struct
- DataPart data field now uses protobuf Value

Also updates:
- capiscio_sdk executor to handle protobuf Message serialization
  via MessageToDict (was model_dump() only)
- pyproject.toml dependency: a2a-sdk>=1.0.0
- examples/simple_agent for v1.0 compatibility

Fixes cross-product E2E test ImportError:
  cannot import name 'TextPart' from 'a2a.types'
Copilot AI review requested due to automatic review settings May 3, 2026 04:45
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 3, 2026

✅ Documentation validation passed!

Unified docs will be deployed from capiscio-docs repo.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 3, 2026

✅ All checks passed! Ready for review.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 3, 2026

Codecov Report

❌ Patch coverage is 27.27273% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
capiscio_sdk/executor.py 27.27% 8 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 3, 2026

✅ SDK server contract tests passed (test_server_integration.py). Cross-product scenarios are validated in capiscio-e2e-tests.

@beonde beonde merged commit 1fa41ce into main May 3, 2026
16 of 17 checks passed
@beonde beonde deleted the fix/a2a-sdk-v1-migration branch May 3, 2026 04:49
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Migrates the SDK integration points from a2a-sdk v0.x Pydantic models to v1.0 protobuf-generated types, updating tests and examples accordingly and adjusting message serialization in the security executor.

Changes:

  • Updated integration tests to construct a2a.types.Message/Part/... protobuf types (incl. SendMessageRequest, ServerCallContext, Struct/Value).
  • Updated CapiscioSecurityExecutor to serialize protobuf messages via google.protobuf.json_format.MessageToDict.
  • Bumped dependency constraint to a2a-sdk>=1.0.0 and refreshed simple-agent examples.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/integration/test_real_executor.py Migrates integration tests to protobuf A2A types and updates request/response message construction.
capiscio_sdk/executor.py Adds protobuf message-to-dict conversion path for validation.
examples/simple_agent/test_client.py Switches example client request payload serialization to protobuf MessageToDict.
examples/simple_agent/agent_executor.py Updates example agent executor to emit protobuf Message events instead of helper constructors.
pyproject.toml Updates dependency to a2a-sdk>=1.0.0.
Comments suppressed due to low confidence (1)

capiscio_sdk/executor.py:105

  • identifier = message_dict.get("message_id") ... assumes snake_case keys. If the message dict is produced via protobuf JSON mapping (or Pydantic aliases), the key may be messageId, which would make rate limiting/caching identifiers inconsistent. Consider checking both message_id and messageId (or deriving the identifier directly from the message object) to keep behavior consistent across model types.
        # Extract identifier for rate limiting
        identifier = message_dict.get("message_id") or message.message_id
        

@@ -13,9 +13,11 @@
import pytest
import base64
Comment thread capiscio_sdk/executor.py
Comment on lines +96 to +101
if hasattr(message, 'model_dump'):
message_dict = message.model_dump()
elif ProtobufMessage is not None and isinstance(message, ProtobufMessage):
message_dict = MessageToDict(message, preserving_proto_field_name=True)
else:
message_dict = {}
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.

2 participants