Tawa docs
Guides

Policy rules

Add per-request rules that contribute directives to a scan's verdict, on top of built-in detection.

Every scan method accepts policy_overrides — additive rules evaluated on top of your app's saved policy, not a replacement for it. A matched rule contributes directives to the result's policy field; your application decides what to actually do with them, the same way it decides what to do with action.

result = client.analyze(
    user_input,
    policy_overrides=[
        PolicyRuleOverride(
            id="block-finance-tool-for-guests",
            when={"tool_name": "transfer_funds", "caller_role": "guest"},
            directives=["block"],
        )
    ],
)

print(result.policy.directives)       # e.g. ["block"]
print(result.policy.matched_rule_ids)  # ["block-finance-tool-for-guests"]

See Policy rules in the API Reference for the full rule schema, every matchable key, and directives with built-in meaning — this page only covers the Python override syntax.

Acting on the verdict

A matched rule's directives are a signal, not an automatic decision — see Enforcing a policy for the exact pattern in the raw SDK and the OpenAI Agents SDK.

Your own vocabulary of directive strings ("strip_system_prompt", "require_human_review", ...) is branched on wherever you enforce the policy, the same way the agent protection cookbook does for "disable_tools:".

On this page