Skip to content

API Reference parrot.security.groundedness.evidence

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.security.groundedness.evidence

View source

Per-turn evidence index for groundedness scoring.

Builds an :class:EvidenceIndex from a turn's ToolCall.result payloads (FEAT-398, spec §3 Module 2): an exact-match hash-set per atom kind, plus a flat numeric list (money/percent/number) consumed by the scorer's precision-aware tolerance and contradicted-band checks.

Alias Atom

Re-exported from parrot.security.groundedness.models.Atom.

Alias AtomKind

Re-exported from parrot.security.groundedness.models.AtomKind.

Class EvidenceIndex

Per-turn evidence extracted from tool-call results.

Attributes:

Attribute Type Description
by_kind dict[AtomKind, set] Exact-match sets of normalized atom values, keyed by :class:AtomKind.
numeric_by_kind dict[AtomKind, list[tuple[float, str]]] Per-kind (normalized_value, raw) pairs for money/percent/number atoms found in evidence, used by the scorer's precision-aware tolerance and contradicted-band checks. Kept separate per :class:AtomKind so a money claim is never matched against percent/number evidence extracted from text that happens to share the same numeric value. Raw JSON int/float scalars (no surrounding text, no kind signal) are the deliberate exception — they populate all three lists.
tool_call_count int Number of tool calls the index was built from. 0 means the turn had no tool results — the scorer's no_evidence case.
evidence_truncated bool True once max_evidence_bytes was hit while building the index.

Method EvidenceIndex.from_tool_calls

Build an :class:EvidenceIndex from a turn's tool-call results.

Recursively traverses dict/list ToolCall.result payloads (both keys and values), extracting atoms from every string encountered and indexing every raw int/float scalar directly (see add_raw_numeric_scalar), capped by policy.max_evidence_bytes.

from_tool_calls(tool_calls: list[ToolCall], policy: GroundednessPolicy, user_prompt: str | None = None) -> EvidenceIndex

Parameter Type Default Description
tool_calls list[ToolCall] The turn's aggregated tool calls (AIMessage.tool_calls).
policy GroundednessPolicy The active :class:GroundednessPolicy.
user_prompt str | None None The user's turn prompt. Folded in as additional evidence when policy.include_user_prompt_as_evidence is True (the agent legitimately echoing a user-stated figure should not be flagged unsupported).

Returns: EvidenceIndex — The populated :class:EvidenceIndex.

Alias GroundednessPolicy

Re-exported from parrot.security.groundedness.policy.GroundednessPolicy.

Alias ToolCall

Re-exported from parrot.models.basic.ToolCall.

Alias extract_atoms

Re-exported from parrot.security.groundedness.extractors.extract_atoms.

Attribute logger

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally