Add AutoGen agent runner integration#306
Add AutoGen agent runner integration#306Bermpje wants to merge 12 commits intoopenagents-org:developfrom
Conversation
…in pyproject.toml - Introduced autogen-core and autogen-agentchat as optional dependencies for enhanced functionality. - Updated the 'all' optional dependencies list to include 'autogen' alongside existing packages.
- Added AutoGenAgentRunner for managing AutoGen entities within the OpenAgents framework. - Implemented conversion functions to facilitate interaction between OpenAgents tools and AutoGen tools. - Introduced unit tests for AutoGen agent integration, covering conversion and runner functionalities. - Updated __init__.py to include new AutoGen components in the public API.
…uctions - Introduced a code example for wrapping existing AutoGen agents or teams using AutoGenAgentRunner. - Added instructions for installing optional dependencies required for AutoGen integration. - Clarified the expectations for the AutoGen integration regarding live Python objects.
|
@Bermpje is attempting to deploy a commit to the Raphael's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
This PR adds an AutoGenAgentRunner integration so Microsoft AutoGen agents and teams can participate in OpenAgents networks, following the same integration-runner pattern already established for LangChain, LlamaIndex, CrewAI, and PydanticAI.
Changes:
- Added
src/openagents/agents/autogen_agent.pywithAutoGenAgentRunner,create_autogen_runner,openagents_tool_to_autogen, andautogen_tool_to_openagents— the core of the integration - Exported the new symbols from
src/openagents/agents/__init__.pyand added theautogenoptional extra topyproject.toml - Added regression test coverage in
tests/agents/test_autogen_agent.pyand a usage example in the docs
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/openagents/agents/autogen_agent.py |
Core AutoGen runner: tool converters, event filtering, streaming support, and schema-preserving tool adapter |
src/openagents/agents/__init__.py |
Exports four new AutoGen symbols for public API access |
pyproject.toml |
Adds autogen optional extra (autogen-core>=0.7.5, autogen-agentchat>=0.7.5) and includes it in openagents[all] |
tests/agents/test_autogen_agent.py |
Unit tests covering tool conversion, event filtering, streaming, error handling, and package exports |
docs/updates/2025-12-19-admin-dashboard.mdx |
Adds AutoGen integration usage example and install instructions to the docs |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| metadata = { | ||
| "source_id": context.incoming_event.source_id, | ||
| "thread_id": context.incoming_thread_id, | ||
| "event_id": context.incoming_event.event_id, | ||
| "event_name": context.incoming_event.event_name, | ||
| } | ||
| del metadata |
There was a problem hiding this comment.
The metadata dictionary is constructed and then immediately deleted via del metadata without ever being used. This is dead code that adds noise and may indicate an incomplete implementation — the context metadata (source_id, thread_id, event_id, event_name) is never passed to the AutoGen entity, meaning the invoked method has no way to correlate the call with the original OpenAgents event. The metadata dict should either be removed entirely, or used (for example, passed as context to the run call if the AutoGen API supports it).
There was a problem hiding this comment.
Removed the dead code. This was scaffolding for future context propagation but AutoGen's run() API doesn't have a standard metadata parameter to pass it to.
| args_model = autogen_tool.args_type() | ||
| args = args_model(**kwargs) |
There was a problem hiding this comment.
There is a two-step instantiation bug when building the args model. autogen_tool.args_type is a Pydantic model class. The code calls autogen_tool.args_type() with no arguments to get args_model, which produces an empty instance, and then calls args_model(**kwargs) on that instance, which will raise a TypeError because Pydantic model instances are not callable. The correct pattern is to call the class directly with the kwargs: args = autogen_tool.args_type(**kwargs), eliminating the intermediate args_model variable entirely.
There was a problem hiding this comment.
Valid bug — args_type is a Pydantic model class, so args_type() creates an empty instance which isn't callable with (**kwargs). Fixed to call the class directly: args = autogen_tool.args_type(**kwargs).
tests/agents/test_autogen_agent.py
Outdated
| """Test converting OpenAgents tool to AutoGen FunctionTool.""" | ||
| from openagents.agents.autogen_agent import openagents_tool_to_autogen | ||
|
|
||
| autogen_tool = openagents_tool_to_autogen(sample_openagents_tool) | ||
| assert autogen_tool is not None | ||
| assert isinstance(autogen_tool, FunctionTool) |
There was a problem hiding this comment.
The test docstring says "Test converting OpenAgents tool to AutoGen FunctionTool" and the assertion checks isinstance(autogen_tool, FunctionTool), but openagents_tool_to_autogen does not return a FunctionTool — it returns a custom OpenAgentsAutoGenTool that subclasses BaseTool directly. This isinstance check will fail when AutoGen is installed and the test runs, because OpenAgentsAutoGenTool is not derived from FunctionTool. The assertion should instead check for BaseTool, e.g., by importing BaseTool from autogen_core.tools and using isinstance(autogen_tool, BaseTool).
There was a problem hiding this comment.
Correct — openagents_tool_to_autogen returns OpenAgentsAutoGenTool which subclasses BaseTool, not FunctionTool. Fixed the assertion and docstring.
…text - Replaced binary file handling with text reading for pyproject.toml in the AutoGen agent tests. - Enhanced assertions to check for the presence of 'autogen' in the optional dependencies directly from the text content.
… connection handling - Implemented retry logic for network initialization to handle port conflicts. - Added health check for HTTP readiness after network startup. - Improved connection assertions for admin, developer, and user clients to ensure successful connections. - Added assertion for file upload response to verify successful uploads.
- Added installation of backend dependencies from requirements.txt to the pytest workflow for improved test environment setup.
- Updated the test for pyproject.toml to enhance the assertion for the presence of 'autogen' in the optional dependencies. - Replaced the previous assertion with a more robust check that retrieves the relevant line containing 'openagents[' and verifies 'autogen' is included.
…onnection handling - Implemented retry logic for network initialization to handle port conflicts. - Added health check for HTTP readiness after network startup. - Improved connection assertions for admin, analyst, and user clients to ensure successful connections.
…sertions - Replaced random port assignment with OS-assigned free ports to prevent conflicts. - Enhanced connection assertions for admin, developer, and user clients to ensure successful connections. - Added checks to verify that network clients are connected before sending events.
- Introduced a utility function to obtain free TCP ports, replacing random port assignment. - Updated network configuration to use loopback address (127.0.0.1) for consistency. - Removed retry logic for network initialization, simplifying the setup process.
- Remove unused metadata dict in _invoke_autogen (dead code) - Fix args_type() double-instantiation: call args_type(**kwargs) directly instead of args_type()(**kwargs) which creates an empty model first - Use BaseTool instead of FunctionTool in test isinstance check since openagents_tool_to_autogen may return any BaseTool subclass Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Closes #269
Summary
AutoGenAgentRunnerso AutoGen agents and teams can participate in OpenAgents networksWhat changed
src/openagents/agents/autogen_agent.pywith:AutoGenAgentRunnercreate_autogen_runner(...)openagents_tool_to_autogen(...)autogen_tool_to_openagents(...)src/openagents/agents/__init__.pyautogenoptional extra and included it inopenagents[all]tests/agents/test_autogen_agent.pyImplementation notes
This follows the existing integration-runner pattern used for other frameworks, while aligning the AutoGen wrapper with documented AutoGen 0.7.5 behavior:
**kwargswrapperrun_stream()is consumed as an async generator and uses the terminalTaskResultTaskResult.messagesThe current integration expects a live AutoGen entity object to be passed into the runner from Python code. It does not add YAML/factory-based AutoGen loading.
Validation
Automated:
pytest tests/agents/test_autogen_agent.py -vpytest tests/agents/test_langchain_agent.py -vpytest tests/agents -vflake8 src/openagents/agents/autogen_agent.py tests/agents/test_autogen_agent.pyManual:
AutoGenAgentRunnerRelated issue