Suppose the courts set a precedent by interpreting ambiguous law in a way that negatively affects one of the parties of a case. When deciding on remedies, damages, or a criminal sentence, will courts sometime show any consideration for the losing party since they could not know how the law would be interpreted?
This answer is under United States law.
Usually, when a court interprets the law in a way that was previously ambiguous, parties are not given any leniency for not knowing in advance how an issue will be resolved.
Sometimes, when a court overrules prior precedent with a new precedent the court will grant some leniency, if there is an easy way to do so.
For example, in the Colorado case of Warne v. Hall, 2016 CO 50, the Colorado Supreme Court made the level of detail required in documents commencing civil lawsuits in the state was made much more strict, reversing long standing prior binding precedents in the state on the issue. The U.S. Supreme Court had done the same thing in federal cases, but the Colorado Court of Appeals at the time had repeatedly declined to apply the federal standard to state court cases. In Warne, the party whose legal documents were held to be insufficiently detailed was allowed, on remand to the trial court for further proceedings, to try to amend those documents to meet the new standard (for what it is worth, he didn't succeed on remand).
This is usually not done, however, in "writing on the wall" situations where the new decision overruling prior law was obvious from an amendment to the statute that an older case interpreted, or from a previous new court precedent that overruled prior law in some circumstances and made it very likely that addition related binding case law would also be overruled, even if the previous landmark precedent didn't necessarily have that result.
An exception applies in cases where a law enforcement officer is accused of violating someone's civil rights. In those cases, liability is only imposed on the officer if the fact that the conduct violated the plaintiff's legal rights was "clearly established" by statutes and case law at the time that the law enforcement officer took the action giving rise to the lawsuit, under a doctrine known as "qualified immunity". If the law was ambiguous at the time that the law enforcement officer took action, "qualified immunity" bars the lawsuit.
Similar considerations apply in favor of the government in some habeas corpus litigation in federal court (where a state court conviction is collaterally attacked after direct appeals are exhausted).