# Scanning and blocking (/docs/proxy/configure/scanning-and-blocking)



## Mode [#mode]

Mode is a setting of the app, in **App settings**, **Scanning and blocking**.

* **Monitoring.** The proxy forwards every request and response untouched.
  Scans run in the background and nothing is held back, so Monitoring adds no
  latency. Requests that would have been blocked are not blocked.
* **Blocking.** A request, tool call or response with a blocking decision is
  stopped and the client receives an error.

The blocking decisions are Block, Hard block and Sandbox. Review and all other
decisions are forwarded.

A new app is in Monitoring until you switch it to Blocking.

<Callout type="info">
  Start in Monitoring, check what would have been blocked, then switch the app to
  Blocking.
</Callout>

## Fallback [#fallback]

Fallback decides what happens when the proxy cannot get a scan result, or
cannot read the content to scan.

| Setting                                         | Behaviour                                                      |
| ----------------------------------------------- | -------------------------------------------------------------- |
| Forward the request unscanned (`open`, default) | The request or response goes through.                          |
| Return an error (`closed`)                      | The client receives a `502` with code `tawa_scan_unavailable`. |

Content the proxy cannot read is treated the same way: a compressed request
body (`Content-Encoding` other than `identity`), or a non-streaming response
larger than 16 MiB. In Monitoring these are always forwarded.

Fallback does not apply to token checks. If a token cannot be verified and the
proxy has no recent answer for it, the request is refused with a `503`.

## Stages [#stages]

Stages belong to each token. They are set when you create the token, or by
editing it under **API keys**, **Proxy tokens**.

| Stage         | Scanned                        | Notes                                                                                                                     |
| ------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------- |
| `prompt`      | The newest user message        | On by default                                                                                                             |
| `tool-output` | The newest run of tool results | On by default                                                                                                             |
| `tool-call`   | Tool calls in the model reply  | On by default. A streamed tool call is held until it is complete, then scanned.                                           |
| `response`    | Model reply text               | Off by default. Uses more of your allowance and can add delay. Streamed text is scanned in checkpoints of 400 characters. |

Each token needs at least one stage. When a request ends with tool results it
is scanned as `tool-output`; otherwise the final user message is scanned as
`prompt`.

Only the newest content of a request is scanned, so the cost of a request stays
flat as a conversation grows. Reasoning text from a model is not scanned.

## What a blocked request looks like [#what-a-blocked-request-looks-like]

A blocked request returns `400` in the provider's own error format, with the
code `tawa_blocked` and the header `x-tawa-blocked-stage` naming the stage that
blocked it. A response blocked after a stream has started ends the stream with
an error event, because the status is already `200`. See
[Error codes](/docs/proxy/reference/error-codes).
