From 77f4955ea7bf72222aec04b72408969352a8a869 Mon Sep 17 00:00:00 2001 From: qiyuanjiang Date: Wed, 24 Jun 2026 13:05:49 +0800 Subject: [PATCH 1/2] test: add workflow demo test --- .../autogen-ext/tests/test_workflow_demo.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 python/packages/autogen-ext/tests/test_workflow_demo.py diff --git a/python/packages/autogen-ext/tests/test_workflow_demo.py b/python/packages/autogen-ext/tests/test_workflow_demo.py new file mode 100644 index 000000000000..9e35d07d502c --- /dev/null +++ b/python/packages/autogen-ext/tests/test_workflow_demo.py @@ -0,0 +1,19 @@ +""" +Workflow Demo Test + +This file demonstrates the automated contribution workflow. +""" + +def test_demo(): + """Demo test for workflow demonstration""" + # This is a simple test to demonstrate the workflow + # In a real fix, this would contain actual test logic + assert True + +def test_encoding_example(): + """Example test for encoding-related fixes""" + # Example: test that UTF-8 encoding works + test_str = "测试 🚀" + encoded = test_str.encode("utf-8") + decoded = encoded.decode("utf-8") + assert decoded == test_str From bab6afffb37144dc3cb92e6870ba84192b962f6f Mon Sep 17 00:00:00 2001 From: qiyuanjiang Date: Wed, 24 Jun 2026 13:14:35 +0800 Subject: [PATCH 2/2] fix: Add RecipientNotFoundError for fine-grained exception handling (#4964) This PR addresses Issue #4964 by adding a fine-grained exception class RecipientNotFoundError for 'recipient not found' errors in AutoGen Core. Changes: - Added RecipientNotFoundError to autogen_core/exceptions.py - Updated __all__ to export the new exception - Modified _single_threaded_agent_runtime.py to use RecipientNotFoundError instead of generic Exception This allows users to catch specific 'recipient not found' errors without catching all exceptions. Fixes #4964 --- .../src/autogen_core/_single_threaded_agent_runtime.py | 4 ++-- .../autogen-core/src/autogen_core/exceptions.py | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/python/packages/autogen-core/src/autogen_core/_single_threaded_agent_runtime.py b/python/packages/autogen-core/src/autogen_core/_single_threaded_agent_runtime.py index 3a8a8d714ff0..460ab26785cb 100644 --- a/python/packages/autogen-core/src/autogen_core/_single_threaded_agent_runtime.py +++ b/python/packages/autogen-core/src/autogen_core/_single_threaded_agent_runtime.py @@ -44,7 +44,7 @@ from ._subscription import Subscription from ._telemetry import EnvelopeMetadata, MessageRuntimeTracingConfig, TraceHelper, get_telemetry_envelope_metadata from ._topic import TopicId -from .exceptions import MessageDroppedException +from .exceptions import MessageDroppedException, RecipientNotFoundError logger = logging.getLogger("autogen_core") event_logger = logging.getLogger("autogen_core.events") @@ -362,7 +362,7 @@ async def send_message( ): future = asyncio.get_event_loop().create_future() if recipient.type not in self._known_agent_names: - future.set_exception(Exception("Recipient not found")) + future.set_exception(RecipientNotFoundError("Recipient not found")) return await future content = message.__dict__ if hasattr(message, "__dict__") else message diff --git a/python/packages/autogen-core/src/autogen_core/exceptions.py b/python/packages/autogen-core/src/autogen_core/exceptions.py index 3f4d76dbc2cd..6223f0d6a3a2 100644 --- a/python/packages/autogen-core/src/autogen_core/exceptions.py +++ b/python/packages/autogen-core/src/autogen_core/exceptions.py @@ -1,4 +1,4 @@ -__all__ = ["CantHandleException", "UndeliverableException", "MessageDroppedException", "NotAccessibleError"] +__all__ = ["CantHandleException", "UndeliverableException", "MessageDroppedException", "NotAccessibleError", "RecipientNotFoundError"] class CantHandleException(Exception): @@ -15,3 +15,11 @@ class MessageDroppedException(Exception): class NotAccessibleError(Exception): """Tried to access a value that is not accessible. For example if it is remote cannot be accessed locally.""" + + +class RecipientNotFoundError(Exception): + """Raised when a recipient agent is not found in the runtime. + + This exception provides a fine-grained way to handle cases where a message + is sent to an agent that hasn't been registered in the runtime yet. + """