langgoap.planner.astar.plan

Contents

langgoap.planner.astar.plan#

plan(start, goal, actions, blacklisted_actions=None, *, time_budget_ms=None, tracer=None, record_expansions=False)[source]#

Find an optimal action sequence from start to goal using A*.

Parameters:
  • start (PlanningState | dict[str, Any]) – Current world state. Accepts a plain dict for convenience; it will be coerced to PlanningState internally.

  • goal (GoalSpec) – Goal specification with target conditions.

  • actions (list[ActionSpec]) – Available actions to choose from.

  • blacklisted_actions (list[str] | None) – Action names to exclude from planning. If filtering makes the goal unreachable, the planner retries with all actions (graceful degradation: an unreachable goal from the filtered set is preferred over returning None when a plan through the full action set still exists).

  • time_budget_ms (float | None) – Optional wall-clock budget in milliseconds. When set, the search returns the best complete plan found within the budget rather than running until exhaustion. None (the default) means no limit — original behaviour.

  • tracer (Any) – Optional PlanningTracer that receives per-expansion, dead-end, and completion events when record_expansions is also True.

  • record_expansions (bool) – Opt-in gate for the search-tree firehose. Off by default so production planning stays zero-overhead.

Returns:

A Plan if a path exists, None if the goal is unreachable.

Return type:

Plan | None