Skip to content

feat(guardrails): add LLMJudgeValidator#1714

Open
valentinabojan wants to merge 3 commits into
mainfrom
valentinabojan/new-guardrail-validator
Open

feat(guardrails): add LLMJudgeValidator#1714
valentinabojan wants to merge 3 commits into
mainfrom
valentinabojan/new-guardrail-validator

Conversation

@valentinabojan

Copy link
Copy Markdown
Contributor

Summary

  • Adds a new LLMJudgeValidator built-in guardrail validator that evaluates data against free-form natural-language criteria via the UiPath Guardrails API (validator_type="llm_judge").
  • Validator takes criteria (str), model (str, default gpt-4o-mini), and threshold (float in [0, 1], default 0.5). Supported at all execution stages.
  • Adds a generic StringParameterValue to the validator parameter discriminated union so string-typed parameters can be passed to built-in validators.
  • Exports LLMJudgeValidator from uipath.platform.guardrails.decorators alongside the other validators.

Usage

from uipath.platform.guardrails.decorators import (
    BlockAction,
    GuardrailExecutionStage,
    LLMJudgeValidator,
    guardrail,
)

@guardrail(
    name="output-must-be-json",
    validator=LLMJudgeValidator(
        criteria="The output must be a valid JSON object.",
        model="gpt-4o",
        threshold=0.8,
    ),
    stage=GuardrailExecutionStage.POST,
    action=BlockAction(),
)
def my_agent(prompt: str) -> str:
    ...

Test plan

  • pytest tests/services/test_guardrails_decorators.py — all 85 tests pass, including 8 new TestLLMJudgeValidator cases
  • pytest tests/services/test_guardrails_*.py tests/services/test_azure_guardrail_validators.py — 99 tests pass
  • ruff check . — all checks pass
  • ruff format --check . — 195/195 formatted
  • mypy src tests — no issues found

Adds an LLM-as-judge built-in guardrail validator that evaluates data
against free-form natural-language criteria via the UiPath Guardrails
API. Takes `criteria`, `model` (default gpt-4o-mini), and `threshold`
(default 0.5). Supported at all stages.

Also adds a generic `StringParameterValue` to the validator parameter
union so future validators can pass string-typed parameters.
Copilot AI review requested due to automatic review settings June 12, 2026 11:06
@github-actions github-actions Bot added test:uipath-langchain Triggers tests in the uipath-langchain-python repository test:uipath-integrations labels Jun 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new built-in guardrail validator, LLMJudgeValidator, which delegates validation to the UiPath Guardrails API using an LLM-as-judge mechanism (validator_type="llm_judge"). It also extends the guardrail parameter modeling to support string-typed validator parameters so the new validator can pass criteria/model settings to the API.

Changes:

  • Added LLMJudgeValidator built-in validator (criteria/model/threshold) and exported it via the decorators API.
  • Extended the validator-parameter discriminated union with a StringParameterValue model to support string parameters.
  • Added unit tests covering LLMJudgeValidator validation behavior and guardrail construction.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/uipath-platform/tests/services/test_guardrails_decorators.py Adds test coverage for LLMJudgeValidator validation and guardrail parameter construction.
packages/uipath-platform/src/uipath/platform/guardrails/guardrails.py Adds StringParameterValue and includes it in ValidatorParameter union for built-in validator parameters.
packages/uipath-platform/src/uipath/platform/guardrails/decorators/validators/llm_judge.py Implements the new LLMJudgeValidator and its guardrail payload construction.
packages/uipath-platform/src/uipath/platform/guardrails/decorators/validators/init.py Re-exports LLMJudgeValidator from the validators package.
packages/uipath-platform/src/uipath/platform/guardrails/decorators/init.py Re-exports LLMJudgeValidator from the public decorators module.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +39 to +45
if not criteria or not criteria.strip():
raise ValueError("criteria must be a non-empty string")
if not 0.0 <= threshold <= 1.0:
raise ValueError(f"threshold must be between 0.0 and 1.0, got {threshold}")
self.criteria = criteria
self.model = model
self.threshold = threshold
@github-actions

Copy link
Copy Markdown

🚨 Heads up: uipath-langchain cross-tests are FAILING 🚨

Your changes may break the uipath-langchain-python integration.

⚠️ These checks are NOT enforced by branch protection rules. Please review the failures before merging.

🔍 Inspect the failed run →

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:uipath-integrations test:uipath-langchain Triggers tests in the uipath-langchain-python repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants