Skip to content

test: updated the testcases to the latest agent framework. Dev v4 to main#866

Open
Dhruvkumar-Microsoft wants to merge 4 commits intomainfrom
dev-v4
Open

test: updated the testcases to the latest agent framework. Dev v4 to main#866
Dhruvkumar-Microsoft wants to merge 4 commits intomainfrom
dev-v4

Conversation

@Dhruvkumar-Microsoft
Copy link
Collaborator

Purpose

This pull request updates the backend and test suite to support breaking changes in the agent-framework ecosystem, especially the move to rc4 versions and the removal of the HostedCodeInterpreterTool in favor of server-side code interpreter handling. It also updates dependencies to specific versions and adjusts test mocks and logic to match the new agent framework APIs.

Key changes include:

Dependency and agent framework updates:

  • Updated requirements.txt to pin all dependencies to specific versions, upgrade core Azure and OpenAI libraries, and switch to agent-framework-azure-ai, agent-framework-core, and agent-framework-orchestrations release candidates. Added new dependencies required by the updated agent framework and removed semantic-kernel.

Test suite and mocking adjustments for agent framework v1.0.0rc4:

  • Overhauled agent framework mocks in conftest.py to include new classes (Agent, Message, etc.), submodules, and attributes required by the updated agent framework, and added mocks for the new agent_framework_orchestrations modules. [1] [2]
  • Updated test imports and mocks to use Agent and Message instead of ChatAgent and ChatMessage, reflecting the new agent framework API. Adjusted test assertions and patching accordingly. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]
  • Modified test logic for code interpreter tool collection: removed local instantiation of HostedCodeInterpreterTool and updated assertions to expect server-side handling, per the new framework behavior. [1] [2] [3]

Other test and mock improvements:

  • Added missing mocks for azure.identity.aio and common.config.app_config to avoid import errors in tests.
  • Updated test logic to use agent.client instead of agent.chat_client to align with new agent interface. [1] [2]

These changes ensure compatibility with the latest agent framework APIs and maintain test reliability as the backend migrates to the new orchestration and agent management model.

Does this introduce a breaking change?

  • Yes
  • No

How to Test

  • Get the code
git clone [repo-address]
cd [repo-name]
git checkout [branch-name]
npm install
  • Test the code

What to Check

Verify that the following are valid

  • ...

Other Information

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the backend dependency pins and refactors the v4 backend test suite/mocks to align with breaking API changes in the agent-framework ecosystem (notably workflow.run(..., stream=True), Agent/Message, and new agent_framework_orchestrations import paths).

Changes:

  • Pinned/updated backend Python dependencies and migrated agent-framework packages to rc/beta versions.
  • Updated orchestration tests to reflect event dispatch via event.type strings and streaming via workflow.run(..., stream=True).
  • Refreshed test mocks (including agent_framework_orchestrations) and adjusted Foundry agent tests for server-side Code Interpreter handling.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/tests/backend/v4/orchestration/test_orchestration_manager.py Updates orchestration mocks/tests for workflow.run(..., stream=True) and event.type dispatch.
src/tests/backend/v4/orchestration/test_human_approval_manager.py Adds agent_framework_orchestrations mocks and updates agent framework symbols.
src/tests/backend/v4/magentic_agents/test_foundry_agent.py Migrates tests from ChatAgent/ChatMessage to Agent/Message and removes Hosted Code Interpreter tool expectations.
src/tests/backend/v4/magentic_agents/common/test_lifecycle.py Updates lifecycle tests for agent.client (replacing agent.chat_client).
src/tests/backend/v4/callbacks/test_response_handlers.py Updates response handler tests to use Message for isinstance checks.
src/tests/backend/conftest.py Expands global agent framework/orchestrations module stubs for import compatibility.
src/backend/requirements.txt Pins and updates backend dependencies to targeted versions (including agent-framework rc/beta).
Comments suppressed due to low confidence (1)

src/tests/backend/v4/orchestration/test_orchestration_manager.py:781

  • test_run_orchestration_event_processing_error no longer exercises the intended error-handling path: the only event emitted is MockMagenticAgentDeltaEvent() which has no .type, so the production code treats it as an unknown event type and never calls streaming_agent_response_callback (meaning the injected side_effect is unused). Update the test to emit an event object with type="output", a non-null executor_id, and data that is an AgentResponseUpdate instance so the streaming callback is invoked and its exception is caught/logged.
    async def test_run_orchestration_event_processing_error(self):
        """Test handling of errors during event processing."""
        # Set up workflow with events that cause processing errors
        mock_workflow = Mock()
        mock_events = [MockMagenticAgentDeltaEvent()]
        mock_workflow.run = AsyncGeneratorMock(mock_events)
        mock_workflow.executors = {}
        
        # Make streaming callback raise exception
        streaming_agent_response_callback.side_effect = Exception("Callback error")
        

💡 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants