langgoap.plan

Contents

langgoap.plan#

plan(start, goal, actions, blacklisted_actions=None, *, time_budget_ms=None, tracer=None, record_expansions=False, blacklist_fallback=None)[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.

  • blacklist_fallback (bool | None) – When the blacklist makes the goal unreachable, True retries with the full action set (re-admitting the blacklisted actions) instead of returning None. None (default) reads goal.policy.blacklist_fallback, which is False unless the caller opted in: a permanently failing, human-denied, or guard-blocked action must not be re-run just because it is the only path (issue #15).

  • time_budget_ms (float | None) – Optional wall-clock budget in milliseconds. When set, the search is anytime: weighted A* runs with the tightening schedule ANYTIME_WEIGHTS, so a complete (bounded-suboptimal) plan is available early and is improved while the budget lasts; the final iteration is optimal A*. On expiry the best complete plan found so far is returned, or None when not even the loosest iteration finished. None (the default) means no limit — plain optimal A*.

  • 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