langgoap.GoalPolicy#

class GoalPolicy(replan_strategy=ReplanStrategy.ON_DEVIATION, priority=0, max_replans=10, on_infeasible='fail', blacklist_fallback=False)[source]#

Replanning + multi-goal-priority policy for a GoalSpec.

Grouping these three orthogonal-to-the-conditions knobs into a sub-dataclass keeps the GoalSpec constructor focused on what the goal is, not how the planner should chase it.

Parameters:
  • replan_strategy (ReplanStrategy)

  • priority (int)

  • max_replans (int)

  • on_infeasible (Literal['fail', 'execute'])

  • blacklist_fallback (bool)

replan_strategy#

When the observer should trigger replanning during execution.

Type:

langgoap.types.ReplanStrategy

priority#

Multi-goal scenarios use this to break ties when MultiGoal chooses the next sub-goal. Higher = more important.

Type:

int

max_replans#

Maximum number of replanning cycles before the observer gives up. Guards against infinite replan loops when an action keeps failing or the world state never converges. Set to 0 to disable the limit.

Type:

int

on_infeasible#

What the planner does when the best plan it can find violates a hard constraint (CSP status INFEASIBLE). "fail" (default) rejects the plan: the run ends with status="no_plan" and a no_plan_explanation carrying the resource shortfalls, so stuck handlers can relax the constraint. "execute" keeps the pre-0.2 advisory behaviour and runs the plan anyway; the violation stays visible in plan.metadata.csp.

Type:

Literal[‘fail’, ‘execute’]

blacklist_fallback#

When every path to the goal needs a blacklisted action, True lets the planner retry with the full action set (re-admitting the failed action) and clear the blacklist. False (default) reports no_plan so a permanently failing, human-denied, or guard-blocked action is never re-run; use ActionSpec.max_retries or an ActionQos for transient failures.

Type:

bool

__init__(replan_strategy=ReplanStrategy.ON_DEVIATION, priority=0, max_replans=10, on_infeasible='fail', blacklist_fallback=False)#
Parameters:
  • replan_strategy (ReplanStrategy)

  • priority (int)

  • max_replans (int)

  • on_infeasible (Literal['fail', 'execute'])

  • blacklist_fallback (bool)

Return type:

None

Methods

__init__([replan_strategy, priority, ...])

from_dict(data)

Reconstruct from the dict produced by to_dict().

to_dict()

Serialise to a JSON-native dict (inverse of from_dict()).

Attributes