diff --git a/python/src/uagents/communication.py b/python/src/uagents/communication.py index b2433285..a1f7cc64 100644 --- a/python/src/uagents/communication.py +++ b/python/src/uagents/communication.py @@ -163,10 +163,17 @@ async def send_exchange_envelope( success = resp.status == 200 if success: if sync: - # If the message is synchronous but not verified, return the envelope env = Envelope.model_validate(await resp.json()) - if env.signature is None: - return env + if env.signature: + verified = False + try: + verified = env.verify() + except Exception as ex: + errors.append( + f"Received response envelope that failed verification: {ex}" + ) + if not verified: + continue return await dispatch_sync_response_envelope(env) return MsgStatus( status=DeliveryStatus.DELIVERED, @@ -365,7 +372,7 @@ async def send_sync_message( def enclose_response( message: Model, sender: str, session: UUID4, target: str = "" -) -> str: +) -> JsonStr: """ Enclose a response message within an envelope. @@ -390,7 +397,7 @@ def enclose_response_raw( sender: str, session: UUID4, target: str = "", -) -> str: +) -> JsonStr: """ Enclose a raw response message within an envelope. diff --git a/python/src/uagents/resolver.py b/python/src/uagents/resolver.py index 271ca526..6247adcd 100644 --- a/python/src/uagents/resolver.py +++ b/python/src/uagents/resolver.py @@ -281,9 +281,9 @@ async def _api_resolve(self, destination: str) -> Tuple[Optional[str], List[str] if response.status_code != 200: if response.status_code != 404: - LOGGER.warning( - f"Failed to resolve agent {address} from {self._almanac_api_url}," - f"querying Almanac contract..." + LOGGER.debug( + f"Failed to resolve agent {address} from {self._almanac_api_url}, " + f"resolving via Almanac contract..." ) return None, [] diff --git a/python/tests/test_server.py b/python/tests/test_server.py index 7d600ec1..7a819f41 100644 --- a/python/tests/test_server.py +++ b/python/tests/test_server.py @@ -116,7 +116,7 @@ async def test_message_success_unsigned(self): ] ) - async def test_message_success_sync(self): + async def test_message_success_sync_unsigned(self): message = Message(message="hello") reply = Message(message="hey") user = generate_user_address()