fix(core): raise RecipientNotFoundError instead of generic Exception for unknown recipients - #8063
Open
Siddhesh Kabra (Xsidz) wants to merge 3 commits into
Open
Conversation
…for unknown recipients Fixes microsoft#4964 When send_message is called with an unregistered agent type, the runtime now raises RecipientNotFoundError (from autogen_core.exceptions) instead of a bare Exception, allowing callers to handle this case without matching on the error string.
Author
|
@microsoft-github-policy-service agree |
1 similar comment
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #4964
When
send_messageis called with an agent type that is not registered in the runtime, the runtime now raisesRecipientNotFoundErrorinstead of a bareException("Recipient not found"). This lets callers catch the specific error class rather than parsing the error message string.Changes:
RecipientNotFoundErrortoautogen_core/exceptions.pyRecipientNotFoundErrorfromautogen_core.__init__so it is accessible asfrom autogen_core import RecipientNotFoundError_single_threaded_agent_runtime.pyto raiseRecipientNotFoundErrorat the point where recipient lookup failstest_runtime.pythat verifiesRecipientNotFoundErroris raised for unregistered agent typesTest plan
test_send_message_to_unregistered_agent_raises_recipient_not_foundpassespackages/autogen-core/tests/suite passes (225 tests, 0 failures)RecipientNotFoundErroris importable directly fromautogen_coreRecipientNotFoundErroris also accessible viaautogen_core.exceptions.RecipientNotFoundError