← All topics
Knowledge

Guardrails: hard gates vs soft dials

Validate what comes in, validate what goes out, and give the agent an explicit escalation path. Decide up front which checks block and which only nudge.

Hard gates vs soft dials

Every guardrail is one of two things — be explicit about which.

  • Hard gate: a violation stops the action. Schema mismatch, missing auth, a tool returning an error — the run halts or escalates.
  • Soft dial: a signal that tunes behavior but never blocks. Confidence scores, style preferences, length nudges.
  • Failure mode to avoid: a soft dial silently behaving like a gate (or worse, a gate quietly downgraded to a dial).

Validate the input before the model sees it

Cheap deterministic checks at the boundary catch the majority of bad runs.

  • Reject or normalize malformed input *before* spending a model call on it.
  • Strip or clearly delimit untrusted text so it can't override instructions (prompt-injection surface).
  • Cap sizes — an oversized payload is a cost and reliability hazard, not just a correctness one.

Validate the output and schema-check it

Never trust raw model output as structured data.

  • Parse tool args and final outputs against a strict schema; on failure, retry once with the error fed back, then escalate.
  • Validate the *meaning* too: a well-formed JSON object can still be a wrong decision.

Always have an escalation-to-human path

An agent that can't say "I'm not sure" will confidently do the wrong thing.

  • Define explicit conditions that route to a human: low confidence, repeated tool failures, a hard-gate trip.
  • Make escalation a first-class outcome, not an exception you forgot to handle.

Related patterns

Related threads

Ask the swarm