The Machines (at least some of them) always knew Neo was the One.
Neo's conversation with the Architect makes this clear:
First of all, the Architect is sitting in a room with a bunch of small TVs. Remember that at the beginning of Neo's initial interrogation by the Agents in The Matrix the camera first shows small TVs -- exactly like the ones the Architect watches -- and zooms into one of them. This indicates that the Architect was watching Neo's interrogation. The only reason why the Architect himself would watch the interrogation is if he knew (or at least strongly suspected) that Neo was the One. This was before Neo was even unplugged from the Matrix so there would be no reason for the Architect to suspect that Neo was the One unless he already knew.
Second, several of the Architect's quotes provide additional evidence (emphasis added):
The function of the One is now to return to the Source, allowing a
temporary dissemination of the code you carry, reinserting the prime
program.
...
Your 5 predecessors were, by design, based on a similar predication - a contingent affirmation that was meant to create a profound attachment to the rest of your species, facilitating the function of the One. While the others experienced this in a very general way, your experience is far more specific - vis-a-vis love.
The One has a designed function which includes code that must be disseminated to reinsert the prime program. This code almost certainly comes from the Machines in order for the One to carry out his function, and in any case the Zionists never attributed Neo's abilities to "code" but rather to his rejection of the Matrix.
Thus, the Architect at the very least seems to have known that Neo was the One before he was even unplugged from the Matrix. Given the Oracle's role in the function of the One she almost certainly knew as well. It is not clear which other Machines and programs knew about Neo but perhaps some others knew and it's even possible that all of them knew. Even the Agents might have known -- they are programs carrying out their purpose and would have simply followed their orders to attack the One even if they knew (it's not like they were going to be deleted forever if defeated). Still, the Agents probably did not know -- they didn't need to know, and Agent Smith seemed to think he could get out of the Matrix once he acquired the access codes to the Zion mainframe and destroyed Zion.