Skip to main content
LLM-as-a-judge scorer prompts support mustache templating. The variables available depend on whether the scorer is scoped to a Span or a Trace.

Span-level variables

Available in any scorer with Scope: Span. Each matching span is scored independently. Example prompt:

Trace-level variables

Available in scorers with Scope: Trace. The scorer runs once per trace and has access to the full conversation thread. The four span-level variables (input, output, expected, metadata) are also available here and are populated from the root span of the trace.

{{thread}}

{{thread}} renders the entire conversation as formatted text, ready to pass directly to a judge model. It’s the simplest way to give the scorer full conversation context. Example prompt:

{{thread_with_system}}

For scorers, {{thread}} excludes system messages so the judge rubric isn’t polluted by your application’s system prompt. Use {{thread_with_system}} to render the full conversation including system messages, ready to pass directly to a judge model. For non-scorer prompts, {{thread}} and {{thread_with_system}} are equivalent because both include system messages.

{{human_ai_pairs}}

For Nunjucks prompts, {{human_ai_pairs}} lets you iterate over matched turn pairs:
Pairs are matched by index (first user message with first assistant message, etc.). If the counts are unequal, only the matched pairs are included.

{{user_messages}} and {{assistant_messages}}

These filter the thread to a single role. Useful if you only need one side of the conversation:

SDK requirements for trace-level scoring

Trace-level scorers require:
  • TypeScript SDK v2.2.1+
  • Python SDK v0.5.6+
  • Java SDK v0.3.8+
  • Ruby SDK v0.2.1+
  • C# SDK v0.2.3+

Setting up multi-turn conversation scoring

If your application creates a new trace per turn (common for chatbots), the easiest way to make {{thread}} work is to route all turns under a single root span using span.export(): Python:
TypeScript:
Once all turns share a root trace, a Trace-scoped LLM-as-a-judge scorer with {{thread}} in the prompt will receive the full conversation.