Skip to content

Commit 7758ea5

Browse files
authored
fix(cloudapp): fix cloudapp message_send result class for both Task and Message (#314)
* fix(cloudapp): fix cloudapp message_send result class for both Task and Message * fix(cloudapp): fix for UniTest * fix import bug * back to origin * fix * fix import * fix import unitest * fix for unitest
1 parent 956a395 commit 7758ea5

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

veadk/cloud/cloud_app.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,26 @@ async def message_send(
422422

423423
# we ignore type checking here, because the response
424424
# from CloudApp will not be `Task` type
425-
return res.root.result # type: ignore
425+
result = res.root.result # type: ignore
426+
try:
427+
from a2a.types import Task
428+
except ImportError:
429+
return result
430+
431+
if isinstance(result, Task):
432+
if result.history: # type: ignore
433+
return next(
434+
(
435+
msg
436+
for msg in reversed(result.history) # type: ignore
437+
if msg.role == "agent"
438+
),
439+
None,
440+
)
441+
else:
442+
return None
443+
else:
444+
return result
426445
except Exception as e:
427446
logger.error(f"Failed to send message to cloud app. Error: {e}")
428447
return None

0 commit comments

Comments
 (0)