fix(a2a): add A2A Python SDK as project dependency #3178

Merged
freemo merged 1 commits from fix/a2a-python-sdk-dependency into master 2026-04-05 21:09:56 +00:00
4 changed files with 3907 additions and 0 deletions
@@ -0,0 +1,87 @@
"""Step definitions for TDD issue #2922: A2A Python SDK dependency."""
from __future__ import annotations
import importlib
import tomllib
from pathlib import Path
from typing import Any
from behave import given, then, when
from behave.runner import Context
@given('the pyproject.toml file exists at "{path}"')
def step_pyproject_exists(context: Context, path: str) -> None:
"""Verify pyproject.toml exists at the given path."""
pyproject_path = Path(path)
assert pyproject_path.exists(), f"pyproject.toml not found at {path}"
context.pyproject_path = pyproject_path
@when("I read the project dependencies from pyproject.toml")
def step_read_project_dependencies(context: Context) -> None:
"""Read the [project.dependencies] list from pyproject.toml."""
content = context.pyproject_path.read_bytes()
data: dict[str, Any] = tomllib.loads(content.decode("utf-8"))
context.project_dependencies = data.get("project", {}).get("dependencies", [])
@then(
'the dependency list should include a package that provides the "{module}" module'
)
def step_dependency_provides_module(context: Context, module: str) -> None:
"""Assert that a dependency providing the given module is listed."""
deps: list[str] = context.project_dependencies
# The a2a-sdk package installs as the 'a2a' module.
# Accept either 'a2a-sdk' or 'a2a' as the package name.
found = any(
dep.lower().startswith("a2a-sdk") or dep.lower().startswith("a2a>=")
for dep in deps
)
assert found, (
f"No dependency providing the '{module}' module found in "
f"[project.dependencies]. Current deps: {deps}"
)
@when('I attempt to import the "{module_name}" module')
def step_attempt_import(context: Context, module_name: str) -> None:
"""Attempt to import the given module and record the result."""
try:
context.imported_module = importlib.import_module(module_name)
context.import_error = None
except ImportError as exc:
context.imported_module = None
context.import_error = exc
@then("the import should succeed without errors")
def step_import_succeeded(context: Context) -> None:
"""Assert that the previous import attempt succeeded."""
assert context.import_error is None, f"Import failed with: {context.import_error}"
assert context.imported_module is not None, "Module was not imported"
@when('I import "{module_path}" and access "{attr_name}"')
def step_import_and_access(context: Context, module_path: str, attr_name: str) -> None:
"""Import a module and access a named attribute."""
try:
mod = importlib.import_module(module_path)
context.accessed_attr = getattr(mod, attr_name, None)
context.access_error = None
except ImportError as exc:
context.accessed_attr = None
context.access_error = exc
@then('the "{attr_name}" class should be available')
def step_class_available(context: Context, attr_name: str) -> None:
"""Assert that the accessed attribute is a class."""
assert context.access_error is None, f"Import failed with: {context.access_error}"
assert context.accessed_attr is not None, (
f"Attribute '{attr_name}' not found in module"
)
assert isinstance(context.accessed_attr, type), (
f"'{attr_name}' is not a class, got {type(context.accessed_attr)}"
)
+20
View File
@@ -0,0 +1,20 @@
@tdd_issue @tdd_issue_2922
Feature: A2A Python SDK is a declared project dependency
As a CleverAgents developer
I want the A2A Python SDK to be listed in pyproject.toml dependencies
So that the SDK is always installed and importable in any project environment
Background:
Given the pyproject.toml file exists at "pyproject.toml"
Scenario: a2a-sdk is listed in project dependencies
When I read the project dependencies from pyproject.toml
Then the dependency list should include a package that provides the "a2a" module
Scenario: a2a module is importable as a project dependency
When I attempt to import the "a2a" module
Then the import should succeed without errors
Scenario: a2a SDK provides the A2AClient class
When I import "a2a.client" and access "A2AClient"
Then the "A2AClient" class should be available
+1
View File
@@ -48,6 +48,7 @@ dependencies = [
"tomlkit>=0.13.0", # TOML writing with comment preservation for config CLI
"tenacity>=8.2.0", # Retry framework for service layer resilience
"aiohttp>=3.13.4", # CVE-2026-34515 mitigation: open redirect vulnerability
"a2a-sdk>=0.3.0", # A2A Python SDK — required transport for local (stdio) and server (HTTP) modes (ADR-047)
]
[project.optional-dependencies]
Generated
+3799
View File
File diff suppressed because it is too large Load Diff