﻿# A background classifier cannot gate bytes already returned to the client

A practical investigation of a background classifier cannot gate bytes already returned to the client, with explicit observations, control cases and evidence limits.

Author: Retrivium team
Updated: 2026-11-06
Canonical URL: https://retrivium.ai/journal/field-sovereign-fastapi-background-classifier-after-response-release/
Language: en

## The deployment scenario

A private document assistant returns an extracted answer immediately and attaches a background classifier to inspect it for sensitive content. The classifier later rejects the answer, but the client has already received the bytes. This is a placement error in the release protocol. A post-response observation can support review or another future action; it cannot serve as the permission gate for content already sent by that response.

## The data and control mechanism

FastAPI documents BackgroundTasks as running after a response is returned. The reviewed Starlette Response implementation sends the response start and body before invoking its attached background task. This timing is different from awaiting a required classifier before constructing or sending protected output. It is also different from returning an acceptance receipt and exposing results only through a later, separately gated retrieval operation.

## Define the intended boundary

Define which response contains protected content and which check must approve its release. Keep an accepted-for-processing receipt distinct from an approved final answer. For a mandatory gate, specify the outcomes of classifier denial, timeout and unavailable execution before any protected body is sent. A later background failure should not cause a system to relabel an already disclosed answer as never released or to claim that a rejected flag retroactively removed the exposure.

## A step-by-step review

First trace the actual response and task order, including middleware and streaming behavior. Use invented markers and a controlled classifier that can delay, deny or fail. Observe the client-visible body before and after the classifier completes. Compare a post-response background check with a deliberately awaited check or a receipt-only asynchronous workflow. The expected negative case must show that a late denial cannot prevent an earlier content-bearing response.

## Evidence required for acceptance

Acceptance evidence records the protected-output send point, classifier completion and explicit admission outcome. Preserve a case where the required checker is unavailable and no protected result is returned through the intended gated path. Distinguish diagnostic completion from release authorization. A successful classifier call or attached task object is insufficient; the evidence must establish ordering relative to the irreversible transmission being controlled, without using a real confidential document as a test marker.

## Failure cases and limits

This article does not claim background tasks are unsuitable for all processing or that every asynchronous workflow leaks data. They are appropriate when the client need not await that work, and receipt-only designs can defer a later gated result. Exact middleware and server behavior require review. The bounded conclusion concerns the selected response path: post-response classification is not a pre-release privacy gate and cannot retract bytes the recipient has already received.

## Primary references and related reading

A required output check must complete before protected content is sent; post-response tasks provide a different contract. [FastAPI response-after background task contract](https://fastapi.tiangolo.com/tutorial/background-tasks/); [Starlette response sends body before attached background task](https://raw.githubusercontent.com/Kludex/starlette/main/starlette/responses.py).

The proposed investigation of fastapi background classifier after response release is a proposed technical boundary review; no production workload or private data was used. Related reading: [LiteLLM guardrails: choosing where to inspect requests and responses](/journal/litellm-guardrails-boundary/); [Local fault injection: interrupting an upstream at a known stream boundary](/journal/provider-midstream-fault-injection-tests/).
