JSONPath in checks
Built-in checks like Groundedness, StringMatching, and LessThan accept path parameters such as target_key, context_key, and question_key that point into the trace. This page covers the syntax.
The trace. Prefix
Section titled “The trace. Prefix”All paths must start with trace.:
# CorrectGroundedness(target_key="trace.last.outputs.answer", ...)
# Wrong — raises an errorGroundedness(target_key="last.outputs.answer", ...)trace.last
Section titled “trace.last”trace.last is shorthand for trace.interactions[-1] — the most recent interaction. Use an explicit index to reference earlier turns in multi-turn scenarios:
target_key = "trace.last.outputs" # most recenttarget_key = "trace.interactions[0].outputs" # first interactiontarget_key = "trace.interactions[-1].outputs" # same as trace.last.outputsCommon Patterns
Section titled “Common Patterns”| Path | What it accesses |
|---|---|
trace.last.inputs | Last interaction inputs |
trace.last.outputs | Last interaction outputs |
trace.last.outputs.answer | Nested field in output dict |
trace.last.outputs.confidence | Numeric field in output dict |
trace.last.metadata.model | Metadata field |
trace.interactions[0].inputs | First interaction inputs |
NoMatch
Section titled “NoMatch”When a path can’t be resolved, the resolver returns a NoMatch sentinel instead of raising an exception. Every built-in check turns NoMatch into CheckResult.error, not a failure, with a message naming the path it could not resolve.
The distinction matters when you read results. A failure means the check ran and your agent did not meet the bar. An error means the check could not run at all, usually because you typed the path wrong or the output shape changed.
Follow the same convention in custom checks:
from giskard.checks.core.extraction import resolve, NoMatch
value = resolve(trace, self.field_path)if isinstance(value, NoMatch): return CheckResult.error(message=f"No value at '{self.field_path}'")Paths in Jinja2 Templates
Section titled “Paths in Jinja2 Templates”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 }}