"""Create recovery_planner
Generated by Phi-Octopus Eden
2025-11-08 16:05:53.085347
"""

```python
from typing import Callable, Dict, Any


class RecoveryPlanner:
    """
    A class designed to handle limited error recovery by planning a sequence of actions.
    The planner can execute steps and recover from errors if they occur.

    Args:
        max_attempts: Maximum number of attempts before giving up on an action.
        error_handler: A callback function that handles the error when an action fails.
    """

    def __init__(self, max_attempts: int = 3, error_handler: Callable[[Exception], None] = print):
        self.max_attempts = max_attempts
        self.error_handler = error_handler

    def plan_and_execute(self, actions: Dict[str, Callable[[], Any]]) -> Dict[str, Any]:
        """
        Plan and execute a series of actions with limited error recovery.

        Args:
            actions: A dictionary where keys are action names and values are functions representing the actions.

        Returns:
            A dictionary mapping each action name to its result or an error message.
        """
        results = {}
        for action_name, action in actions.items():
            attempt = 1
            while attempt <= self.max_attempts:
                try:
                    results[action_name] = action()
                    break
                except Exception as e:
                    if attempt == self.max_attempts:
                        results[action_name] = f"Failed after {self.max_attempts} attempts: {str(e)}"
                        self.error_handler(results[action_name])
                    else:
                        attempt += 1
        return results


# Example usage

def action_a() -> int:
    import random
    if random.random() < 0.5:
        raise ValueError("Action A failed")
    return 42


def action_b() -> str:
    return "Hello, world!"


recovery_planner = RecoveryPlanner(max_attempts=3, error_handler=lambda x: print(f"Error caught: {x}"))
actions = {"A": action_a, "B": action_b}
results = recovery_planner.plan_and_execute(actions)
print(results)

```