Class GuardrailRegistry

java.lang.Object
com.tnsai.quality.tracing.guardrail.GuardrailRegistry

public final class GuardrailRegistry extends Object
Registry for pre-response and post-response guardrails.

Pre-response guardrails run on the input before the agent processes it. Post-response guardrails run on the input+output after the agent responds.

Thread-safe.

  • Constructor Details

    • GuardrailRegistry

      public GuardrailRegistry()
  • Method Details

    • registerPreResponse

      public void registerPreResponse(Guardrail guardrail)
      Registers a pre-response guardrail (runs on input before processing).
    • registerPostResponse

      public void registerPostResponse(Guardrail guardrail)
      Registers a post-response guardrail (runs on input+output after processing).
    • preResponseGuardrails

      public List<Guardrail> preResponseGuardrails()
      Returns all pre-response guardrails.
    • postResponseGuardrails

      public List<Guardrail> postResponseGuardrails()
      Returns all post-response guardrails.
    • get

      public Guardrail get(String name)
      Looks up a guardrail by name.
      Returns:
      the guardrail, or null if not found
    • evaluatePreResponse

      public List<GuardrailResult> evaluatePreResponse(String input)
      Runs all pre-response guardrails on the given input.
      Parameters:
      input - the input text
      Returns:
      list of results, one per guardrail
    • evaluatePostResponse

      public List<GuardrailResult> evaluatePostResponse(String input, String output)
      Runs all post-response guardrails on the given input/output pair.
      Parameters:
      input - the input text
      output - the output text
      Returns:
      list of results, one per guardrail
    • allPreResponsePass

      public boolean allPreResponsePass(String input)
      Returns true if all pre-response guardrails pass for the given input.
    • allPostResponsePass

      public boolean allPostResponsePass(String input, String output)
      Returns true if all post-response guardrails pass for the given input/output.