"""Create recovery_planner
Generated by Phi-Octopus Eden
2025-11-05 21:57:28.649885
"""

```python
from typing import Any


class RecoveryPlanner:
    """
    A class for creating a limited error recovery plan.
    
    This planner helps to handle exceptions in a specific context by defining a set of fallback actions.
    """

    def __init__(self, max_attempts: int = 3):
        self.max_attempts = max_attempts
        self.attempt_count = 0

    def plan_recovery(self, function_to_recover: Any) -> Any:
        """
        Plan the recovery for a given function.

        :param function_to_recover: The function that might fail and needs to be recovered.
        :return: A wrapper function with recovery logic.
        """
        attempts_left = self.max_attempts

        def recoverable_function(*args, **kwargs):
            nonlocal attempts_left
            while attempts_left > 0:
                try:
                    result = function_to_recover(*args, **kwargs)
                    return result
                except Exception as e:
                    print(f"Exception occurred: {e}, attempts left: {attempts_left}")
                    self.attempt_count += 1
                    attempts_left -= 1
            raise RuntimeError("Max number of recovery attempts reached.")

        return recoverable_function


# Example usage

def risky_function(x):
    import random
    if random.random() < 0.5:
        print(f"Function failed with x={x}")
        return "Failure"
    else:
        print(f"Function succeeded with x={x}")
        return f"Success: {x}"


recovery_plan = RecoveryPlanner()
safe_function = recovery_plan.plan_recovery(risky_function)

# Test the safe function
print(safe_function(10))
print(safe_function(20))
```