It's for that reason that all governments are overdue on penning up agreements with friendly countries to lessen the chance of a cyberattack. Nonetheless, it's being reported that President Obama is going to be taking some important steps in this when he meets with Chinese resident Xi Jinping during a state visit. These are going to be early discussions, though, and unfortunately will not cover all of the important ground.
What this agreement could prevent are attacks on things like hospitals and communications; what it wouldn't prevent against are attacks that are not deemed of critical importance. Earlier this year, it was found that China was responsible for a breach of a federal employee data; that is an example of an attack that would not be prevented under this particular agreement. The same goes for an attack like the one Sony dealt with late last year (although that was reportedly perpetrated by North Korea).
While it'd be reassuring to know that our utilities are largely safe, China has been responsible for some attacks that are still quite brutal from a user perspective. This past spring, it was suggested that China was responsible for an attack on GitHub - one that cost the service tens of thousands per day - all because it hosted the source code for software that would allow users to circumvent the "Great Firewall of China".
If these talks are successful, then it's expected that other countries will be invited to share the same agreements. One that would give the US some comfort would be Russia, as that country has been responsible for cyberattacks even recently.