langgoap.FunctionalGuard

langgoap.FunctionalGuard#

class FunctionalGuard(name, fn, severity=GuardSeverity.WARN)[source]#

Wraps a callable into an ActionGuard.

Parameters:
  • name (str) – Human-readable guard name.

  • fn (Callable[[ActionSpec, dict[str, Any]], GuardResult]) – A callable (action, world_state) -> GuardResult.

  • severity (GuardSeverity) – Default severity applied when constructing failure results inside fn. This attribute is informational — fn is responsible for embedding severity in the GuardResult it returns.

Example:

guard = FunctionalGuard(
    "budget_check",
    lambda action, ws: GuardResult(
        passed=ws.get("budget", 0) > 0,
        message="Insufficient budget",
        severity=GuardSeverity.BLOCK,
    ),
)
__init__(name, fn, severity=GuardSeverity.WARN)[source]#
Parameters:
Return type:

None

Methods

__init__(name, fn[, severity])

check(action, world_state)

Attributes

name