guardTool() wraps a tool function with a local policy check. The policy runs before the tool call. If the policy blocks, the tool function is not executed.
Policy decisions
beforeCall can return these actions:
| Action | Behavior |
|---|---|
ALLOW | Run the tool. |
WARN | Run the tool and record the warning. |
BLOCK | Block the tool and throw LynxPolicyError. |
REQUIRE_APPROVAL | Block the tool and throw LynxPolicyError. |
REDACT | Record the decision. Apply redaction in your policy callback before allowing the tool. |
MODIFY | Record the decision. Apply modifications in your policy callback before allowing the tool. |
Failure modes
If policy evaluation itself throws,failureMode decides what happens.
| Failure mode | Behavior |
|---|---|
FAIL_OPEN | Allow the tool call and record a policy error. |
FAIL_CLOSED | Block the tool call. |
REQUIRE_APPROVAL | Block with REQUIRE_APPROVAL. |