Skip to content

Commit 8700c28

Browse files
committed
Fixes for tool comments
1 parent 2e0aba9 commit 8700c28

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

src/a2a/client/auth/interceptor.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ async def intercept(
3333
context: ClientCallContext | None,
3434
) -> tuple[dict[str, Any], dict[str, Any]]:
3535
"""Applies authentication headers to the request if credentials are available."""
36-
if not all(
37-
(agent_card, agent_card.security, agent_card.securitySchemes)
36+
if (
37+
agent_card is None
38+
or agent_card.security is None
39+
or agent_card.securitySchemes is None
3840
):
3941
return request_payload, http_kwargs
4042

src/a2a/client/client.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ async def send_message(
248248
context,
249249
)
250250
response_data = await self._send_request(payload, modified_kwargs)
251-
return SendMessageResponse(response_data)
251+
return SendMessageResponse.model_validate(response_data)
252252

253253
async def send_message_streaming(
254254
self,
@@ -297,7 +297,9 @@ async def send_message_streaming(
297297
) as event_source:
298298
try:
299299
async for sse in event_source.aiter_sse():
300-
yield SendStreamingMessageResponse(json.loads(sse.data))
300+
yield SendStreamingMessageResponse.model_validate(
301+
json.loads(sse.data)
302+
)
301303
except SSEError as e:
302304
raise A2AClientHTTPError(
303305
400,
@@ -377,14 +379,7 @@ async def get_task(
377379
context,
378380
)
379381
response_data = await self._send_request(payload, modified_kwargs)
380-
return GetTaskResponse(response_data)
381-
382-
return GetTaskResponse(
383-
**await self._send_request(
384-
request.model_dump(mode='json', exclude_none=True),
385-
http_kwargs,
386-
)
387-
)
382+
return GetTaskResponse.model_validate(response_data)
388383

389384
async def cancel_task(
390385
self,
@@ -419,7 +414,7 @@ async def cancel_task(
419414
context,
420415
)
421416
response_data = await self._send_request(payload, modified_kwargs)
422-
return CancelTaskResponse(response_data)
417+
return CancelTaskResponse.model_validate(response_data)
423418

424419
async def set_task_callback(
425420
self,
@@ -454,7 +449,9 @@ async def set_task_callback(
454449
context,
455450
)
456451
response_data = await self._send_request(payload, modified_kwargs)
457-
return SetTaskPushNotificationConfigResponse(response_data)
452+
return SetTaskPushNotificationConfigResponse.model_validate(
453+
response_data
454+
)
458455

459456
async def get_task_callback(
460457
self,
@@ -489,4 +486,6 @@ async def get_task_callback(
489486
context,
490487
)
491488
response_data = await self._send_request(payload, modified_kwargs)
492-
return GetTaskPushNotificationConfigResponse(response_data)
489+
return GetTaskPushNotificationConfigResponse.model_validate(
490+
response_data
491+
)

0 commit comments

Comments
 (0)