Skip to content

Commit 184f8d5

Browse files
committed
TMP
1 parent 0259343 commit 184f8d5

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

src/a2a/utils/helpers.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,27 @@ def async_gen_wrapper(
389389

390390
return cast('F', async_gen_wrapper)
391391

392+
if inspect.iscoroutinefunction(inspect.unwrap(func)):
393+
394+
@functools.wraps(func)
395+
async def async_wrapper(self: Any, *args: Any, **kwargs: Any) -> Any:
396+
actual_version = _get_actual_version(args, kwargs)
397+
if not _is_version_compatible(actual_version):
398+
logger.warning(
399+
"Version mismatch: actual='%s', expected='%s'",
400+
actual_version,
401+
expected_version,
402+
)
403+
raise VersionNotSupportedError(
404+
message=f"A2A version '{actual_version}' is not supported by this handler. "
405+
f"Expected version '{expected_version}'."
406+
)
407+
return await func(self, *args, **kwargs)
408+
409+
return cast('F', async_wrapper)
410+
392411
@functools.wraps(func)
393-
async def async_wrapper(self: Any, *args: Any, **kwargs: Any) -> Any:
412+
def sync_wrapper(self: Any, *args: Any, **kwargs: Any) -> Any:
394413
actual_version = _get_actual_version(args, kwargs)
395414
if not _is_version_compatible(actual_version):
396415
logger.warning(
@@ -402,8 +421,8 @@ async def async_wrapper(self: Any, *args: Any, **kwargs: Any) -> Any:
402421
message=f"A2A version '{actual_version}' is not supported by this handler. "
403422
f"Expected version '{expected_version}'."
404423
)
405-
return await func(self, *args, **kwargs)
424+
return func(self, *args, **kwargs)
406425

407-
return cast('F', async_wrapper)
426+
return cast('F', sync_wrapper)
408427

409428
return decorator

0 commit comments

Comments
 (0)