Skip to content
GitHubDiscord

JSONPath in checks

Built-in checks like Groundedness, StringMatching, and LesserThan accept path parameters (key, answer_key, text_key) that point into the trace. This page covers the syntax.

All paths must start with trace.:

# Correct
Groundedness(answer_key="trace.last.outputs.answer", ...)
# Wrong — raises an error
Groundedness(answer_key="last.outputs.answer", ...)

trace.last is shorthand for trace.interactions[-1] — the most recent interaction. Use an explicit index to reference earlier turns in multi-turn scenarios:

key = "trace.last.outputs" # most recent
key = "trace.interactions[0].outputs" # first interaction
key = "trace.interactions[-1].outputs" # same as trace.last.outputs
PathWhat it accesses
trace.last.inputsLast interaction inputs
trace.last.outputsLast interaction outputs
trace.last.outputs.answerNested field in output dict
trace.last.outputs.confidenceNumeric field in output dict
trace.last.metadata.modelMetadata field
trace.interactions[0].inputsFirst interaction inputs

When a path can’t be resolved, the resolver returns a NoMatch sentinel instead of raising an exception. Built-in checks treat NoMatch as a failure with a descriptive message. In custom checks, handle it explicitly:

from giskard.checks.core.extraction import resolve, NoMatch
value = resolve(trace, self.field_path)
if isinstance(value, NoMatch):
return CheckResult.failure(message=f"No value at '{self.field_path}'")

LLM-based check prompts use Jinja2. Inside a template, trace is a variable — use the same dot notation without quoting:

User: {{ trace.last.inputs }}
Response: {{ trace.last.outputs }}
Turn 1: {{ trace.interactions[0].outputs }}