async def test_no_history_when_thread_not_found(self):
        """Test graceful handling when thread is not found"""

        # Note: After fixing the duplication bug, thread not found handling
        # happens in server.py:reconstruct_thread_context, not in tools/base.py
        # This test verifies tools don't try to handle missing threads themselves

        captured_prompt = None

        with patch.object(self.tool, "create_model") as mock_create_model:
            mock_model = Mock()
            mock_response = Mock()
            mock_response.candidates = [
                Mock(
                    content=Mock(parts=[Mock(text="Response without history")]),
                    finish_reason="STOP",
                )
            ]

            def capture_prompt(prompt):
                nonlocal captured_prompt
                captured_prompt = prompt
                return mock_response

            mock_model.generate_content.side_effect = capture_prompt
            mock_create_model.return_value = mock_model

            # Execute tool with continuation_id for non-existent thread
            # In the real flow, server.py would have already handled the missing thread
            arguments = {"prompt": "Test without history", "continuation_id": "non-existent-thread-id"}
            response = await self.tool.execute(arguments)

            # Should succeed since tools/base.py no longer handles missing threads
            response_data = json.loads(response[0].text)
            assert response_data["status"] == "success"

            # Verify the prompt does NOT include conversation history
            # (because tools/base.py no longer tries to add it)
            assert captured_prompt is not None
            assert "=== CONVERSATION HISTORY ===" not in captured_prompt
            assert "Test without history" in captured_prompt
Test graceful handling when thread is not found
tests/test_conversation_history_bug.py