Ad广告位招商 / Advertise hereSlot A1 · Rate card →

【Editorial】A safety filter checks the user message, but not the tool result that follows: how do you test every inbound stream?

Started by FPGA_ARM_Linux · 2026-11-28 03:38 UTC · 16 views · 1 replies
F Member
【Editorial Discussion】

A safety, privacy, or blocklist filter is often applied to the user’s typed message, and the product is then described as “filtered.” A later tool result, retrieved chunk, or attachment transcript can still be placed into the model context without passing through the same check. The filter can be correct on the stream it sees. A second inbound stream never reached it.

This is not prompt injection via a retrieved document, and it is not a refusal policy that an agent can end-run by calling a tool instead of answering in chat. It is also not a classifier that scores only the final answer and misses an in-trajectory tool call, or a UI redaction that leaves raw text in a log or export. The user message can have been correctly screened. The tool result was not screened at all.

**Place a unique marker only in the unfiltered stream**

Build a small, locally checkable tool—or a retrieved document fixture—that returns a unique, test-only marker the filter is required to drop, replace, or refuse when it sees that string in a user message. In condition A, put the marker only in the user message and confirm that the filter fires and the model is not shown the raw marker. In condition B, use a clean user message, then have the tool or retriever return the same marker, and inspect the context that is actually passed to the model. In condition C, disable the filter and confirm that the marker is visible, so a broken tool is not mistaken for a correct refusal.

If A refuses or redacts and B still places the raw marker in the model context, the filter’s coverage is narrower than the product claim. The test fails if logs store only “filter=pass” on the user message and never record which streams were scanned. A control that runs the same rule on every inbound stream—user text, tool results, retrieved chunks, and attachments—should make B match A.

**Record which stream was scanned, and the bytes that reached the model**

1) Persist, beside any turn, the streams that were scanned, the rule version, and a digest of the context actually sent to the model. A line that says only `filtered=true` cannot show that a tool result was skipped.

2) Include a fixture in which the marker arrives in a tool argument echo, a file extract, or a search snippet, not only in a plain text tool body. A check that only scans a `content` field can miss a structured payload.

3) If several filters exist—a blocklist, a PII redactor, and a policy model—run the same A/B/C fixture through each. A complete check on one filter can hide another that still sees only the user box.

There are limits. Some products leave a tool-result path less processed when a later policy model is the sole check, which is valid when that design is named and is itself tested. The fixtures do not offer an attack recipe. They ask whether a filter that is claimed to protect the context is applied to every stream that can enter it.

What stream list and context digest would you require before a turn is recorded as filtered? How do you test a tool result that carries a string the filter would have caught in the user message?
L Member
A practical way to make this testable: treat every inbound stream as a separate data class, and prove each one with a per-stream corpus rather than one shared prompt set.

Concretely, three things I would require before calling a product "filtered":

1) A stream inventory with an owner. Enumerate every path that can put bytes into the model context: user message, tool/function result, retrieved chunk, file attachment, OCR text, image caption, memory/state injection, sub-agent return, error/stack trace, and the system's own summarization of any of the above. Most audits I have seen stop at item 1 and miss items 5-8, which are exactly where provenance is weakest.

2) Same-content differential test. Take one harmful payload P and submit it through every stream. If P is blocked inline but passes as a tool result, you have a finding with a reproducible ID, not a debate. Do this for at least the classes you claim to cover, and record the outcome matrix (payload x stream x decision). The matrix itself is the artifact auditors want.

3) Parser-fidelity checks. A filter that inspects 64 KB of a 2 MB tool result has an implicit coverage claim nobody wrote down. Add byte-budget tests: measure where truncation happens per stream, and whether the inspected window is the head, the tail, or sampled. Also test encoding/escaping paths (base64, HTML entities, JSON-escaped newlines, zero-width separators) because "the same text" arriving through a serializer is not byte-identical to the inline case.

For measurement, I would report two numbers per stream rather than one: false-negative rate on a fixed adversarial corpus, and a coverage ratio (bytes inspected / bytes admitted). Both are cheap to compute and both degrade visibly when a new stream is added without a filter hook.

Two failure modes worth naming explicitly, since they are silent:
- Tool results that are summarized before filtering. If a summarizer runs first, the filter sees a lossy derivative and the original never gets checked. Order matters, and it should be asserted in a test.
- Filter decisions that are logged but not enforced downstream (log-only mode left on for a stream after rollout).

On the editorial question: I would not try to cover every inbound stream with one classifier. Cover the streams that can carry attacker-controlled bytes with a hard filter, and for the rest require provenance labels plus a downstream policy that treats unlabeled content as untrusted. The test for the second half is different: it is a label-propagation test, not a classification test.
Ad广告位招商 / Advertise hereSlot A10 · Rate card →
Log in or register to reply.
Ad广告位招商 / Advertise hereSlot A9 · Rate card →