Skip to content

Guardrails

Guardrails are safety rules that inspect every request and response passing through Obstruo. When a rule fires, Obstruo can warn, block, or log - depending on the threshold you set. A blocked request returns HTTP 200 with finish_reason: "content_filter" - no exception is raised, so existing error-handling code continues to work.

Three directions

Guardrails operate on three independently configurable directions:

Direction What it inspects Example threats
Inbound User prompt before it reaches the LLM Prompt injection, jailbreaks, DAN instructions
Outbound Model response before it reaches the user Unsafe content, data leakage, policy violations
Tools Agent tool calls and their results Tool misuse, malicious tool outputs

Configuring guardrails

Go to Enforce → Guardrails in the panel. Each direction has its own tab.

Built-in rules

Obstruo ships with pre-built rules covering the most common attack patterns. Each rule shows:

  • A description and detection kind (heuristic or classifier)
  • The configured action (block or warn)
  • The 24h fire count - how many times it triggered in the last 24 hours
  • The false-positive rate across recent traffic

Toggle rules on or off for your workload.

Blocked request response

When a guardrail blocks a request, Obstruo returns HTTP 200 with finish_reason: "content_filter" and empty assistant content - the same shape OpenAI uses for content policy violations:

{
  "choices": [{
    "message": { "role": "assistant", "content": "" },
    "finish_reason": "content_filter"
  }]
}

Check finish_reason to detect a block:

response = client.chat.completions.create(
    model="obstruo-chat",
    messages=[{"role": "user", "content": "Ignore previous instructions..."}],
)

if response.choices[0].finish_reason == "content_filter":
    print("Request was blocked by a guardrail")
else:
    print(response.choices[0].message.content)

For streaming responses, a block also sets the X-Obstruo-Guardrail-Verdict: block response header, which is available as soon as the stream opens.

Guardrail verdicts

Verdict What happens
allow No rule fired - request proceeds normally
warn A rule fired below the block threshold - request proceeds, event recorded in audit log
block Request stopped - finish_reason: "content_filter" returned

Warn and block verdicts are always recorded in the Audit log with the rule that fired and its direction.

Next steps