Reference

Models Reference

ValidateRequest, ValidateResponse, and SDK data models.

Models Reference

Overview

Pydantic models for AgentTrust SDK request and response types. Import from agentrust_sdk.models or top-level agentrust_sdk.

Why It Matters

Type-safe models ensure correct validation payloads and enable IDE autocompletion.

Prerequisites

pip install agentrust-py

Step-by-Step Guide

ValidateRequest

The client builds this for you from validate()'s keyword arguments.

from agentrust_sdk import ValidateRequest

class ValidateRequest:
    agent_id: str
    framework: str = "REST"           # NOT "Custom"
    version: str = "1"                # NOT "1.0.0"
    parent_envelope_id: str | None = None
    user: str
    input: str
    output: dict[str, Any] = {}
    model: str = "unknown"
    tools_called: list[ToolCall] = [] # NOT `tool_calls`
    latency_ms: float = 0.0
    tokens: int = 0                   # single total, not tokens_in / tokens_out
    session_id: str | None = None
    metadata: dict[str, Any] = {}

ValidateResponse

from agentrust_sdk import ValidateResponse

class ValidateResponse:
    envelope_id: str
    validation: ValidationResult
    risk: RiskResult
    decision: DecisionResult
    latency_ms: float
    trust_chain: dict | None = None    # Enterprise
    tier_info: str = "unknown"
    upgrade_hint: str | None = None
    execution_id: str | None = None    # mirrors envelope_id

    # Derived properties
    approved: bool        # decision.outcome == "approve"
    blocked: bool         # decision.outcome == "block"
    needs_review: bool    # outcome in ("escalate", "request_evidence")
    schema_valid: bool    # schema_score >= 80 and no failures — every tier

There is no top-level confidence object and no governance_disclosure field on the SDK model. Confidence is validation.final_confidence; the gateway's plain-English governance_disclosure string is returned over HTTP but is not surfaced on the SDK model.

ValidationResult

Every score is 0–100. None means the signal was absent, not zero — the confidence engine excludes None signals from the weighted average.

class ValidationResult:
    schema_score: float = 0.0
    evidence_score: float | None = None
    tool_trust_score: float = 0.0
    consistency_score: float = 0.0
    policy_score: float = 0.0
    judge_score: float | None = None
    final_confidence: float = 0.0
    failures: list[str] = []

RiskResult / DecisionResult

class RiskResult:
    tier: str = "unknown"       # "unknown" = not computed (tier too low)
    score: float = 0.0          # 0–100
    reason: str = ""

class DecisionResult:
    outcome: str = "pending"    # "pending" = not computed (tier too low)
    reason: str = ""            # a single string, not a list
    policy_version: str = ""

ToolCall

from agentrust_sdk.models import ToolCall

ToolCall(
    name="sql_query",
    arguments={"query": "SELECT ..."},   # NOT `input`
    result={"rows": 5},                  # NOT `output`
    latency_ms=12.4,
    error=None,
)

client.validate(tools_called=[...]) expects plain dicts with these keys — it constructs the ToolCall models itself, so passing ToolCall instances raises a TypeError.

Decision outcomes

approve | retry | request_evidence | escalate | block | pending

Risk tiers

low | medium | high | critical — plus unknown when risk scoring is tier-gated.

Frameworks (gateway enum)

LangChain | LangGraph | CrewAI | OpenAI Agents | Claude Agents | MCP | Custom | REST

The gateway rejects any other value with a 422. The default is REST.

Examples

from agentrust_sdk import AgentTrustClient

with AgentTrustClient() as client:
    result = client.validate(
        agent_id="test",
        user="alice",
        input="hello",
        output={"answer": "hi"},
    )
    assert result.decision.outcome in (
        "approve", "retry", "request_evidence",
        "escalate", "block", "pending",
    )