As a general rule of thumb, according to this article in the NY Times, when working in another country you should stay less than 6 months to avoid having to file a tax return in both countries. Some countries have visa programs that allow you to stay for 6 months or more without becoming subject to local taxes (Bermuda, Estonia, Iceland, Costa Rica, and more).