# Enforcing a policy (/docs/python/guides/enforcing-policy)



Every scan already carries the [org's Policy Studio verdict](/docs/python/guides/policy-rules)
in `result.policy` — a matched rule's `directives`
(`"block"`, `"disable_tools"`, ...) and `matched_rule_ids`. Activating a
built-in template or a custom rule in the dashboard's Policy Studio changes
what that field contains on every future scan. It does not, by itself,
change what happens to the request.

<Callout type="warn">
  Tawa never blocks anything on its own. Every scan returns a verdict,
  including `result.policy` — but your code decides what happens next.
  Until your integration checks that field and acts on it, nothing about
  your traffic changes.
</Callout>

## Raw SDK [#raw-sdk]

Check `result.policy.directives` yourself after any
`analyze()`/`scan_context()`/`scan_chunk()`/`scan_tool_call()`/`scan_tool_output()`
call, the same way you'd check `result.action`:

```python
result = client.analyze(user_input)

if result.policy and "block" in result.policy.directives:
    raise RuntimeError("Blocked by policy")
```

## OpenAI Agents SDK [#openai-agents-sdk]

`tawa_input_guardrail()`/`tawa_output_guardrail()`'s `should_block` is a
plain callback (default: `default_should_block`, which only looks at
`result.action`). Pass your own to also check `result.policy`:

```python
from tawaguard.agents_sdk import default_should_block, tawa_input_guardrail

def policy_aware_should_block(result):
    if result.policy and "block" in result.policy.directives:
        return True
    return default_should_block(result)

agent = Agent(
    name="Assistant",
    instructions="You are a helpful assistant.",
    input_guardrails=[tawa_input_guardrail(tawa, should_block=policy_aware_should_block)],
)
```

Full reference: [OpenAI Agents SDK integration](/docs/python/integrations/openai-agents-sdk#policy-studio-integration).
