Skip to content

simulatecraft.planning

simulatecraft.planning

Goal plans and replan heuristics for LLM agents.

Planner

Planner(generator: PlanGenerator, *, replan_checker: ReplanChecker | None = None)

Holds the current plan; delegates generation/checking to injected policies.

Source code in src/simulatecraft/planning/planner.py
def __init__(
    self,
    generator: PlanGenerator,
    *,
    replan_checker: ReplanChecker | None = None,
) -> None:
    self.generator = generator
    self.replan_checker = replan_checker
    self.current_plan: Plan | None = None

maybe_replan async

maybe_replan(observation_summary: str) -> bool

True when the checker says reality contradicts the plan.

Source code in src/simulatecraft/planning/planner.py
async def maybe_replan(self, observation_summary: str) -> bool:
    """True when the checker says reality contradicts the plan."""
    if self.current_plan is None:
        return False
    if self.replan_checker is None:
        heuristic = self.current_plan.done()
        if heuristic:
            self.current_plan = None
        return heuristic
    contradicted = await _maybe_await(
        self.replan_checker(observation_summary, self.current_plan)
    )
    if contradicted:
        self.current_plan = None
    return contradicted