new feature: External guardrails/judges

This commit is contained in:
2026-08-24 11:49:29 -03:00
parent fd37138c4f
commit 4b3e4d44e8

View File

@@ -1,12 +1,44 @@
"""Deprecated compatibility shim. """Deprecated lazy compatibility shim for agent-owned contestation validation.
Business-specific contestation validation moved to the Contas agent. New agents The generic framework no longer contains TIM/Contas business policy. The
must keep equivalent policy in their own domain package. legacy symbol remains importable so existing agents do not fail merely by
importing :mod:`agent_framework.guardrails.calibrated`. Resolution of the
domain implementation is delayed until the function is actually invoked.
""" """
from __future__ import annotations from __future__ import annotations
import importlib
import warnings import warnings
warnings.warn("agent_framework.guardrails.calibrated.contestation_validation is deprecated; use the agent-owned domain validator", DeprecationWarning, stacklevel=2) from typing import Any
try:
from app.domain.contas.contestation_validation import * # compatibility for migrated Contas only
except ImportError as exc: def _load_domain_validator():
raise ImportError("No domain contestation validator is installed. The generic framework does not provide TIM/Contas contestation policy.") from exc warnings.warn(
"agent_framework.guardrails.calibrated.contestation_validation is "
"deprecated; use the agent-owned domain validator",
DeprecationWarning,
stacklevel=3,
)
try:
module = importlib.import_module("app.domain.contas.contestation_validation")
validator = getattr(module, "validate_contestation_items")
except (ImportError, AttributeError) as exc:
raise RuntimeError(
"No domain contestation validator is installed. The generic "
"framework does not provide TIM/Contas contestation policy. "
"Install/implement app.domain.contas.contestation_validation or "
"call the agent-owned validator directly."
) from exc
return validator
def validate_contestation_items(*args: Any, **kwargs: Any):
"""Invoke the legacy Contas validator lazily.
Keeping this proxy import-safe preserves compatibility for older agents
while avoiding any dependency from the framework startup on ``app.domain``.
"""
return _load_domain_validator()(*args, **kwargs)
__all__ = ["validate_contestation_items"]