-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Add ability to register Agent instances #6131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
peterychang
merged 23 commits into
microsoft:main
from
peterychang:register_agent_instances
May 12, 2025
Merged
Changes from 14 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
aff1d01
Add ability to register Agent instances
693cef8
Initialize agent from context if it exists
12d26c7
BaseAgent initializes with runtime and id
4ebad57
Fix example code
e0c6c5c
Merge branch 'main' into register_agent_instances
ekzhu 1076fd5
Revert design change. runtime and agent_id passed in register fn
edf4414
Merge branch 'register_agent_instances' of github.com:peterychang/aut…
4c67138
Merge branch 'main' into register_agent_instances
434f2a5
address PR comments, add test
4b4462e
fix test
b6d5ecd
Agent instances can only subscribe to a single subscription. Make tha…
8b4eb10
fix subscription behavior
b45a3be
add additional test case
8939fac
formatting
9bee1d8
address PR comments
2bdc4c2
update documentation
096790c
Merge branch 'main' into register_agent_instances
peterychang c6a1c1d
remove unnecessary code
5cbb7c2
missed change
771f2d5
update error message
eeb3488
Merge branch 'main' into register_agent_instances
peterychang 78672c4
Merge branch 'main' into register_agent_instances
peterychang f4614a8
formatting
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,15 @@ | ||
| import pytest | ||
peterychang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| from autogen_core import AgentId, AgentInstantiationContext, AgentRuntime | ||
| from autogen_test_utils import NoopAgent | ||
| from pytest_mock import MockerFixture | ||
| # import pytest | ||
| # from autogen_core import AgentId, AgentInstantiationContext, AgentRuntime | ||
| # from autogen_test_utils import NoopAgent | ||
| # from pytest_mock import MockerFixture | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_base_agent_create(mocker: MockerFixture) -> None: | ||
| runtime = mocker.Mock(spec=AgentRuntime) | ||
| # @pytest.mark.asyncio | ||
| # async def test_base_agent_create(mocker: MockerFixture) -> None: | ||
| # runtime = mocker.Mock(spec=AgentRuntime) | ||
|
|
||
| # Shows how to set the context for the agent instantiation in a test context | ||
| with AgentInstantiationContext.populate_context((runtime, AgentId("name", "namespace"))): | ||
| agent = NoopAgent() | ||
| assert agent.runtime == runtime | ||
| assert agent.id == AgentId("name", "namespace") | ||
| # # Shows how to set the context for the agent instantiation in a test context | ||
| # with AgentInstantiationContext.populate_context((runtime, AgentId("name2", "namespace2"))): | ||
| # agent2 = NoopAgent() | ||
| # assert agent2.runtime == runtime | ||
| # assert agent2.id == AgentId("name2", "namespace2") | ||
peterychang marked this conversation as resolved.
Show resolved
Hide resolved
|
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.