Loop captures the last assistant response from history.
(self)
| 115 | |
| 116 | @pytest.mark.asyncio |
| 117 | async def test_captures_last_response(self): |
| 118 | """Loop captures the last assistant response from history.""" |
| 119 | ctx = _make_context() |
| 120 | ctx.conversation_history = [ |
| 121 | {"role": "user", "content": "hi"}, |
| 122 | {"role": "assistant", "content": "Hello there!"}, |
| 123 | ] |
| 124 | ui = _make_ui() |
| 125 | q: asyncio.Queue = asyncio.Queue() |
| 126 | done = asyncio.Event() |
| 127 | |
| 128 | await q.put("hi") |
| 129 | await q.put("exit") |
| 130 | |
| 131 | mock_convo = MagicMock() |
| 132 | mock_convo.process_conversation = AsyncMock() |
| 133 | |
| 134 | with patch( |
| 135 | "mcp_cli.chat.conversation.ConversationProcessor", |
| 136 | return_value=mock_convo, |
| 137 | ): |
| 138 | result = await run_agent_loop(ctx, ui, q, done) |
| 139 | |
| 140 | assert "Hello there!" in result |
| 141 | |
| 142 | @pytest.mark.asyncio |
| 143 | async def test_handles_cancellation(self): |
nothing calls this directly
no test coverage detected