(request: pytest.FixtureRequest)
| 141 | |
| 142 | @pytest.mark.asyncio |
| 143 | async def test_resume_async(request: pytest.FixtureRequest): |
| 144 | agent_1 = _TestingAgent(name=f'{request.function.__name__}_test_agent_1') |
| 145 | agent_2 = _TestingAgent(name=f'{request.function.__name__}_test_agent_2') |
| 146 | loop_agent = LoopAgent( |
| 147 | name=f'{request.function.__name__}_test_loop_agent', |
| 148 | max_iterations=2, |
| 149 | sub_agents=[ |
| 150 | agent_1, |
| 151 | agent_2, |
| 152 | ], |
| 153 | ) |
| 154 | parent_ctx = await _create_parent_invocation_context( |
| 155 | request.function.__name__, loop_agent, resumable=True |
| 156 | ) |
| 157 | parent_ctx.agent_states[loop_agent.name] = LoopAgentState( |
| 158 | current_sub_agent=agent_2.name, times_looped=1 |
| 159 | ).model_dump(mode='json') |
| 160 | |
| 161 | events = [e async for e in loop_agent.run_async(parent_ctx)] |
| 162 | |
| 163 | simplified_events = testing_utils.simplify_resumable_app_events(events) |
| 164 | expected_events = [ |
| 165 | (agent_2.name, f'Hello, async {agent_2.name}!'), |
| 166 | (loop_agent.name, END_OF_AGENT), |
| 167 | ] |
| 168 | assert simplified_events == expected_events |
| 169 | |
| 170 | |
| 171 | @pytest.mark.asyncio |
nothing calls this directly
no test coverage detected