"""Create recovery_planner
Generated by Phi-Octopus Eden
2025-11-05 22:23:15.927952
"""

```python
from typing import Callable, Any


class RecoveryPlanner:
    """
    A class to handle limited error recovery for a system by planning and executing retries or fallback actions.
    """

    def __init__(self, max_retries: int = 3):
        """
        Initialize the recovery planner with a maximum number of retries.

        :param max_retries: Maximum number of times to retry an operation before failing. Default is 3.
        """
        self.max_retries = max_retries

    def plan_recovery(self, func: Callable) -> Callable:
        """
        Plan for error recovery by wrapping the given function with retry logic.

        :param func: The target function to be executed and possibly retried upon failure.
        :return: A wrapped version of the input function that includes error handling and retries.
        """
        def wrapper(*args, **kwargs) -> Any:
            attempts = 0
            while attempts < self.max_retries + 1:
                try:
                    return func(*args, **kwargs)
                except Exception as e:
                    print(f"Attempt {attempts} failed with error: {e}")
                    attempts += 1
                    if attempts > self.max_retries:
                        raise Exception("Max retries reached.")
        return wrapper

# Example usage
def risky_function():
    import random
    if random.random() < 0.5:
        print("Function executed successfully")
    else:
        raise ValueError("Random failure")

recovered_function = RecoveryPlanner().plan_recovery(risky_function)

if __name__ == "__main__":
    try:
        recovered_function()
    except Exception as e:
        print(f"Final error: {e}")
```