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 policyOverrides — 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.

const result = await tawa.analyze(userInput, {
  policyOverrides: [
    {
      id: "block-finance-tool-for-guests",
      when: { tool_name: "transfer_funds", caller_role: "guest" },
      directives: ["block"],
    },
  ],
});

console.log(result.policy?.directives); // e.g. ["block"]
console.log(result.policy?.matchedRuleIds); // ["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 TypeScript 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 Vercel AI 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