Skip to content

feat: intrinsic-backed Requirement subclass for Guardian safety validation in repair loops #1071

@planetf1

Description

@planetf1

Observed behaviour

GuardianCheck (deprecated since v0.4) implemented the Requirement.validate() interface, which meant it could be passed directly to RepairTemplateStrategy and m.validate() / m.instruct(..., requirements=[...]). Example from docs/examples/safety/repair_with_guardian.py:

guardian = GuardianCheck(GuardianRisk.FUNCTION_CALL, thinking=True, tools=tool_schemas)
result = m.instruct(prompt, requirements=[guardian], strategy=RepairTemplateStrategy(loop_budget=3))

The thinking=True mode also populated ValidationResult.reason with the Guardian chain-of-thought string, which RepairTemplateStrategy injected back into the repair prompt as targeted feedback.

Expected behaviour

A Requirement subclass backed by the Guardian Intrinsics API (guardian_check(), policy_guardrails()) that can be dropped into the same requirements= slot and used with RepairTemplateStrategy.

Why this gap exists

Guardian Intrinsics return a float score (0.0–1.0) with no reasoning string. There is no direct drop-in for the GuardianCheck-as-Requirement pattern. Because of this, the repair_with_guardian.py example was removed in #935 (Guardian docs migration) rather than migrated, and docs/examples/safety/README.md documents the gap explicitly.

A new Requirement subclass would need to:

  • Accept a criteria key (from CRITERIA_BANK or custom string), a threshold float, and a configured AdapterMixin backend
  • Call guardian_check() and return ValidationResult(result=score < threshold, ...)
  • Accept policy_guardrails() as an alternative path for policy compliance checks

The absence of a reasoning string means repair feedback will be less targeted than GuardianCheck(thinking=True) was — this is a known trade-off worth documenting.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions