|
28 | 28 | Plan, |
29 | 29 | ActionRequest, |
30 | 30 | ) |
31 | | -from autogen_core.base import AgentInstantiationContext, AgentRuntime |
| 31 | +from autogen_core.base import MessageContext, AgentInstantiationContext, AgentRuntime |
32 | 32 | from autogen_core.components.models import AzureOpenAIChatCompletionClient |
33 | 33 | from src.backend.context.cosmos_memory import CosmosBufferedChatCompletionContext |
34 | 34 | from autogen_core.base import AgentId |
@@ -102,91 +102,6 @@ async def test_update_step_status(mock_track_event, setup_group_chat_manager): |
102 | 102 | ) |
103 | 103 |
|
104 | 104 |
|
105 | | -@pytest.mark.asyncio |
106 | | -@patch("src.backend.agents.group_chat_manager.track_event_if_configured") |
107 | | -async def test_execute_step(mock_track_event, setup_group_chat_manager): |
108 | | - """ |
109 | | - Test the `_execute_step` method. |
110 | | - """ |
111 | | - group_chat_manager, mock_memory, session_id, user_id, mock_agent_ids = setup_group_chat_manager |
112 | | - |
113 | | - # Create a mock Step |
114 | | - step = Step( |
115 | | - id="test_step_id", |
116 | | - session_id=session_id, |
117 | | - plan_id="test_plan_id", |
118 | | - user_id=user_id, |
119 | | - action="Test Action", |
120 | | - agent=BAgentType.planner_agent, |
121 | | - status=StepStatus.planned, |
122 | | - ) |
123 | | - |
124 | | - # Mock memory responses |
125 | | - mock_plan = Plan( |
126 | | - id="test_plan_id", |
127 | | - session_id=session_id, |
128 | | - user_id=user_id, |
129 | | - summary="Test Plan Summary", |
130 | | - initial_goal="Test Initial Goal", |
131 | | - ) |
132 | | - mock_memory.get_plan_by_session.return_value = mock_plan |
133 | | - mock_memory.get_steps_by_plan.return_value = [step] |
134 | | - |
135 | | - # Mock helper methods |
136 | | - group_chat_manager.send_message = AsyncMock() |
137 | | - |
138 | | - # Call the method |
139 | | - await group_chat_manager._execute_step(session_id, step) |
140 | | - |
141 | | - # Assertions |
142 | | - step.status = StepStatus.action_requested |
143 | | - mock_memory.update_step.assert_called_once_with(step) |
144 | | - |
145 | | - mock_track_event.assert_has_calls([ |
146 | | - call( |
147 | | - "Group Chat Manager - Update step to action_requested and updated into the cosmos", |
148 | | - { |
149 | | - "status": step.status, |
150 | | - "session_id": step.session_id, |
151 | | - "user_id": user_id, |
152 | | - "source": step.agent, |
153 | | - }, |
154 | | - ), |
155 | | - call( |
156 | | - "Group Chat Manager - Requesting Planneragent to perform the action and added into the cosmos", |
157 | | - { |
158 | | - "session_id": session_id, |
159 | | - "user_id": user_id, |
160 | | - "plan_id": "test_plan_id", |
161 | | - "content": f"Requesting Planneragent to perform action: {step.action}", |
162 | | - "source": "GroupChatManager", |
163 | | - "step_id": step.id, |
164 | | - }, |
165 | | - ), |
166 | | - ]) |
167 | | - |
168 | | - # Adjusted expected ActionRequest |
169 | | - expected_action_request = ActionRequest( |
170 | | - step_id="test_step_id", |
171 | | - plan_id="test_plan_id", |
172 | | - session_id="test_session_id", |
173 | | - action=( |
174 | | - "<conversation_history>Here is the conversation history so far for the current plan. " |
175 | | - "This information may or may not be relevant to the step you have been asked to execute." |
176 | | - "The user's task was:\nTest Plan Summary\n\n" |
177 | | - "The conversation between the previous agents so far is below:\n<conversation_history \\>. " |
178 | | - "Here is the step to action: Test Action. ONLY perform the steps and actions required to complete this specific step, " |
179 | | - "the other steps have already been completed. Only use the conversational history for additional information, " |
180 | | - "if it's required to complete the step you have been assigned." |
181 | | - ), |
182 | | - agent=BAgentType.planner_agent, |
183 | | - ) |
184 | | - |
185 | | - group_chat_manager.send_message.assert_called_once_with( |
186 | | - expected_action_request, mock_agent_ids[BAgentType.planner_agent] |
187 | | - ) |
188 | | - |
189 | | - |
190 | 105 | @pytest.mark.asyncio |
191 | 106 | async def test_update_step_invalid_feedback_status(setup_group_chat_manager): |
192 | 107 | """ |
|
0 commit comments