MCPcopy Create free account
hub / github.com/IBM/mcp-cli / test_captures_last_response

Method test_captures_last_response

tests/agents/test_loop.py:117–140  ·  view source on GitHub ↗

Loop captures the last assistant response from history.

(self)

Source from the content-addressed store, hash-verified

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):

Callers

nothing calls this directly

Calls 3

run_agent_loopFunction · 0.90
_make_contextFunction · 0.70
_make_uiFunction · 0.70

Tested by

no test coverage detected