The US is reportedly in talks with China on an agreement that will prevent the two countries from attacking each other’s cyberspace and other critical infrastructure during peacetime.

The agreement is expected to be announced after Chinese President Xi Jinping arrives in Washington on a state visit on Thursday.

The agreement will protect both the countries against attacks on power stations, banking systems, cellphone networks and hospitals.

It will also address the issues related to widespread poaching of intellectual property and the theft of millions of government employees’ personal data that China has been accused of hacking.

In April, China was suspected of hacking into the Office of Personnel Management, where attackers stole personal records of as many as four million people.

Even US Democratic presidential candidate Hillary Clinton during a presidential campaign in New Hampshire accused China of hacking into American systems and stealing commercial secrets.

President Barack Obama also called for an international framework to prevent the internet from being used as a tool of national aggression, and highlighted that cyber security will be a key topic of discussion with Xi.

The New York Times reported an unnamed senior administration official involved in the discussions as saying that any statement made between Obama and Xi may not contain "a specific, detailed mention" of a prohibition on attacking critical infrastructure.

It is likely to revolve around "generic embrace" of a code of conduct adopted recently by a working group at the United Nations.

Apart from the attack on the Office of Personnel Management, China was also accused of the attack on Sony Pictures that exposed personal emails of executives but later the fingers pointed towards North Korea.

China meanwhile accuses the US of false flagging and hypocrisy.