Both of your examples are grammatical, but what could run you into trouble is when the prepositional phrase only applies to the subject of a passive sentence. For instance:
[A] The problem was found by Vasya in the city.
In this sentence, the prepositional phrase is modifying Vasya so that it tells us that Vasya was in the city when the problem was found. This does not necessarily mean that the problem came from the city. (Think, for instance, of the problem as something that could be photographed. Vasya could be anywhere she wants to be when she solves this problem.)
[B] The problem was found in the city by Vasya.
In this sentence, however, the problem came from the city and Vasya was the one to figure it out.
So in some instances, putting the prepositional phrase before the agent can avoid ambiguity.
1. This still confuses me. I understand [A] to mean that the problem may or may NOT be related to the city (eg an abstract math problem). Vasya might've just found this (math) problem while in the city.
2. Solely based on the sentence alone, and no other context, how can you determine that [B] implies the bolded? Please correct my misinterpretation that [B] simply reorganises [A], with no change in meaning?