datadog-labs/agent-observability-eval-bootstrap
Bootstrap evaluators from production traces — by default propose online LLM-judge evaluators and, after you confirm, create them in Datadog as disabled drafts (never auto-enabled); on request emit Python SDK code or a framework-agnostic JSON spec instead. Use when user says "bootstrap evaluators", "generate evaluators", "create evals from traces", "eval bootstrap", "write evaluators", "build eval suite", "publish evaluators", or wants to generate BaseEvaluator/LLMJudge code or online judge configs from production LLM trace data. Works with ml_app and optional RCA report or failure hypothesis.
npx skills add https://github.com/datadog-labs/agent-skills --skill agent-observability-eval-bootstrap
Detection — At the start of every invocation, before taking any action, determine which backend to use:
--backend pup anywhere in their invocation → use pup mode immediately, regardless of whether MCP tools are present. Skip steps 2–4.mcp__datadog-llmo-mcp__list_llmobs_evals appears in your available tools.pup is executable: run pup --version via Bash. A JSON response containing "version" confirms pup is available.> "Neither the Datadog MCP server nor the pup CLI is available. Connect the MCP server (claude mcp add --scope user --transport http datadog-llmo-mcp 'https://mcp.datadoghq.com/api/unstable/mcp-server/mcp?toolsets=llmobs') or install pup."
--backend pup is accepted anywhere in the invocation arguments and is stripped before passing remaining args to the skill logic.
pup invocation rules:
pup llm-obs <subcommand> [flags][{"type": "text", "text": "<json>"}]).pup auth login and stop.1h, 7d, 30m) and RFC3339 timestamps. Do not use now--prefixed strings — strip the prefix when converting from a skill --timeframe argument: now-7d → 7d, now-24h → 24h, now-30d → 30d.--summary on pup llm-obs spans search strips payload fields to essential metadata only. Use it in bulk/search phases where content is not needed.Invocation ID: At the very start of each invocation, before any MCP tool call, generate an 8-character hex invocation ID (e.g., 3a9f1c2b). Keep it constant for the entire invocation.
Intent tagging: On every MCP tool call, prefix telemetry.intent with skill:agent-observability-eval-bootstrap[<inv_id>] — followed by a description of why the tool is being called. On the first MCP tool call only, use skill:agent-observability-eval-bootstrap:start[<inv_id>] — instead (note the :start suffix). Example first call: skill:agent-observability-eval-bootstrap:start[3a9f1c2b] — Phase 0: map existing eval coverage for task-cruncher
Given a sample of production LLM traces, analyze input/output patterns and quality dimensions, then propose a ready-to-use evaluator suite. Four output modes — online evaluators are the default; SDK code, the JSON spec, and the dataset-emit mode are produced on request:
publish *(default)* — propose online LLM-judge evaluators, then — only after you confirm the suite — write them to Datadog via create_or_update_llmobs_evaluator as disabled drafts (enabled: false). Nothing is created until you confirm at the Phase 2 checkpoint, and nothing scores any spans until you enable it in the UI — the skill never auto-publishes a live evaluator. Once you enable a draft, it runs automatically on matching production spans, traces, or sessions (no dataset, no task function). The skill auto-classifies each proposed evaluator as span-scoped, trace-scoped, or session-scoped based on what the judgment requires (a per-LLM-call tone check vs. an agent goal completion that needs the whole trace vs. user satisfaction across a whole multi-trace conversation) — you accept or override the classification at that checkpoint. Session-scoped evaluators are only proposed when the app's spans carry a session_id (verified by a probe in Phase 1).sdk_code *(on request — --sdk-code, or ask after a publish run)* — Python .py file using the Datadog Evals SDK (BaseEvaluator / LLMJudge) for offline experiments.data_only *(on request — --data-only)* — self-contained JSON spec, framework-agnostic.emit_dataset *(on request — --emit-dataset <path>)* — sample production traces and write a DatasetRecordRaw[] JSON file shaped for LLMObs.create_dataset(records=...). Skips evaluator proposal and generation entirely — this mode produces a dataset, not evaluators. Used by agent-observability-eval-pipeline (Phase 4) to seed an experiment dataset from production behavior.After a publish run, if the user wants the same suite as offline code or a portable spec, they just ask — the skill regenerates the already-confirmed suite in sdk_code / data_only mode without re-exploring (see "On-request code generation" in Phase 3). The emit_dataset mode is independent of the evaluator workflow and never re-uses a prior proposal — it always re-samples traces.
/eval-bootstrap <ml_app> [--timeframe <window>] [--sdk-code | --data-only | --emit-dataset <path>] [--trace-limit <N>]
Arguments: $ARGUMENTS
| Input | Required | Default | Description |
|-------|----------|---------|-------------|
| ml_app | Yes | — | ML application to scope traces |
| timeframe | No | now-7d | How far back to look |
| rca_report | No | — | Failure taxonomy from eval-trace-rca skill, or a free-text failure hypothesis |
| --sdk-code | No | off | Emit a Python SDK .py file for offline experiments instead of publishing online. Mutually exclusive with --data-only and --emit-dataset. |
| --data-only | No | off | Emit a self-contained JSON spec file instead of publishing online. Mutually exclusive with --sdk-code and --emit-dataset. |
| --emit-dataset <path> | No | off | Dataset-only mode. Sample production traces and write a DatasetRecordRaw[] JSON to <path>. Skips the evaluator workflow entirely. Mutually exclusive with --sdk-code and --data-only. |
| --trace-limit | No | 20 (cap 50) | Max traces to sample in emit_dataset mode |
If ml_app is missing, ask the user before proceeding. With no mode flag, the skill defaults to publish — it proposes online evaluators and, only after you confirm, creates them as disabled drafts (it never auto-enables them). If more than one of --sdk-code, --data-only, --emit-dataset is supplied, error out and ask which mode the user wants.
| Tool | Purpose |
|------|---------|
| search_llmobs_spans | Find spans by eval presence, tags, span kind, query syntax. Paginate with cursor. |
| get_llmobs_span_details | Metadata, evaluations (scores, labels, reasoning), and content_info map showing available fields + sizes. |
| get_llmobs_span_content | Actual content for a span field. Supports JSONPath via path param for targeted extraction. |
| get_llmobs_trace | Full trace hierarchy as span tree with span counts by kind. |
| get_llmobs_agent_loop | Chronological agent execution timeline (LLM calls, tool invocations, decisions). |
| list_llmobs_evals | List every evaluator configured for the caller's org across all ml_apps, with enabled status and ml_app per result. Call once in Phase 0 to map existing coverage before proposing new evaluators — filter the result by ml_app client-side. |
| get_llmobs_evaluator | Fetch the full persisted evaluator config by name (target ml_app + sampling + filter, provider, prompt template, parsing type, output schema, assessment criteria). Use in Phase 0 to understand what each existing custom eval measures, and (in publish mode) before any update — create_or_update_llmobs_evaluator is full-replace, so you must round-trip the full config to avoid clobbering fields. Not all evaluators have a stored config (notably source=ootb); a not-found error there is expected — skip those. |
| create_or_update_llmobs_evaluator | *(publish mode)* Write an LLM-judge evaluator config to Datadog. Full-replace semantics: any omitted optional field resets to its default. See "Publishing Conventions" for required fields and structured output → JSON schema mapping. |
| delete_llmobs_evaluator | *(publish mode)* Only used if the user explicitly asks to remove an evaluator. Never invoke speculatively. |
get_llmobs_span_content PatternsUse the path parameter to extract targeted data without fetching full payloads:
| Field | Path | What you get |
|-------|------|-------------|
| messages | $.messages[0] | System prompt (first message, usually system role) |
| messages | $.messages[-1] | Last assistant response |
| messages | *(no path)* | Full conversation including tool calls |
| input / output | — | Span I/O |
| documents | — | Retrieved documents (RAG apps) |
| metadata | — | Custom metadata (prompt versions, feature flags, user segments) |
search_llmobs_spansAdditional filters combine with space (AND): @status:error @ml_app:my-app. Dedicated params (span_kind, root_spans_only, ml_app) work alongside query, but query takes precedence over tags.
To find spans with a specific eval: @evaluations.custom.<eval_name>:* — you can only query for eval *presence*, not specific results.
To detect whether the app uses sessions: session_id:* matches any span carrying a session_id (session_id is a first-class field — no @ prefix). The Phase 1 session probe uses this to gate session-scope evaluators.
get_llmobs_span_details: Group span_ids by trace_id. One call per trace_id with ALL its span_ids. Issue ALL calls for a page in a single message.get_llmobs_span_content: Each call is independent — always issue ALL in a single message.get_llmobs_trace / get_llmobs_agent_loop: Parallelize across different traces in a single message.get_llmobs_span_details for page 1 results immediately — don't wait to collect all pages.> Applies to sdk_code mode only. In data_only mode, use this section as domain context when writing rubric prompts — no SDK classes are emitted.
# Core classes
from ddtrace.llmobs._experiment import BaseEvaluator, EvaluatorContext, EvaluatorResult
# LLM-as-judge
from ddtrace.llmobs._evaluators.llm_judge import (
LLMJudge,
BooleanStructuredOutput,
ScoreStructuredOutput,
CategoricalStructuredOutput,
)
# Built-in evaluators (use only if needed)
from ddtrace.llmobs._evaluators.format import JSONEvaluator, LengthEvaluator
from ddtrace.llmobs._evaluators.string_matching import StringCheckEvaluator, RegexMatchEvaluator
Only import what the generated file actually uses.
evaluate() receives)@dataclass(frozen=True)
class EvaluatorContext:
input_data: dict[str, Any] # Task inputs (from dataset record, NOT from span)
output_data: Any # Task output (from task function return, NOT from span)
expected_output: Optional[JSONType] = None # Ground truth (if available)
metadata: dict[str, Any] = {} # Additional metadata
span_id: Optional[str] = None # LLMObs span ID
trace_id: Optional[str] = None # LLMObs trace ID
Important — span data vs evaluator data: When exploring production traces, you see span I/O (e.g., input.value, output.messages). But evaluators run in offline experiments where input_data and output_data come from the user's dataset records and task function, not from spans. The dataset schema is user-defined and may not match span structure. Write evaluator prompts with generic {{input_data}} / {{output_data}} placeholders and add comments describing what data the evaluator was designed for, so the user can adapt to their dataset shape.
evaluate() returns)EvaluatorResult(
value=..., # Required. JSONType (str, int, float, bool, None, list, dict)
reasoning="...", # Optional. Explanation string
assessment="pass" or "fail", # Optional. Pass/fail assessment
metadata={...}, # Optional. Evaluation metadata dict
tags={...}, # Optional. Tags dict
)
judge = LLMJudge(
user_prompt="...", # Required. Supports {{template_vars}}
system_prompt="...", # Optional. Does NOT support template vars
structured_output=..., # Optional. Boolean/Score/Categorical output, or a dict for custom JSON schema
provider="openai", # "openai" | "anthropic" | "azure_openai" | "vertexai" | "bedrock"
model="gpt-4o", # Model identifier
model_params={"temperature": 0.0}, # Optional. Passed to LLM API
name="eval_name", # Optional. Must match ^[a-zA-Z0-9_-]+$
)
Template variables in user_prompt: {{input_data}}, {{output_data}}, {{expected_output}}, {{metadata.key}} — resolved from EvaluatorContext fields via dot-path into nested dicts.
Boolean — true/false with optional pass/fail:
BooleanStructuredOutput(
description="Whether the response is factually accurate",
reasoning=True, # Include reasoning field in LLM response
reasoning_description=None, # Optional custom description for reasoning field
pass_when=True, # True → pass when true, False → pass when false, None → no assessment
)
Score — numeric within a range with optional thresholds:
ScoreStructuredOutput(
description="Helpfulness score",
min_score=1, # Minimum possible score
max_score=10, # Maximum possible score
reasoning=True,
reasoning_description=None,
min_threshold=7, # Scores >= 7 pass (optional)
max_threshold=None, # Scores <= N pass (optional)
)
Categorical — select from predefined categories:
CategoricalStructuredOutput(
categories={
"correct": "The response correctly answers the question",
"partially_correct": "The response is partially correct but missing key information",
"incorrect": "The response is factually wrong or irrelevant",
},
reasoning=True,
reasoning_description=None,
pass_values=["correct"], # Which categories count as passing (optional)
)
Custom JSON schema — arbitrary structured responses for multi-dimensional evals:
# Pass a raw dict as structured_output — used as the JSON schema directly
structured_output={
"type": "object",
"properties": {
"relevance": {"type": "boolean", "description": "Whether the response addresses the question"},
"confidence": {"type": "number", "description": "Confidence score (0.0 to 1.0)"},
"reasoning": {"type": "string", "description": "Explanation for the evaluation"},
},
"required": ["relevance", "confidence", "reasoning"],
"additionalProperties": False,
}
Always write standard JSON schema — the SDK adapts it per provider automatically (e.g., Anthropic doesn't support minimum/maximum on number fields, so the SDK moves range constraints into the description; Vertex AI converts const/anyOf to enum). The full parsed JSON dict becomes the eval value; a "reasoning" key (if present) is automatically extracted. No automatic pass/fail assessment.
The structured_output parameter enforces the response format via JSON schema. Do not prescribe the format in the prompt (no "Answer YES/NO", "Rate 1-10", etc.). Instead, describe the evaluation criteria and let the structured output handle the format.
{{input_data}} / {{output_data}}, then describe what good vs. bad looks like for this dimension.For deterministic checks that do not need LLM judgment:
class MyEvaluator(BaseEvaluator):
def __init__(self, name=None, ...custom_params...):
super().__init__(name=name)
self._param = ... # Store config as private attrs
def evaluate(self, context: EvaluatorContext) -> EvaluatorResult:
# Access: context.input_data, context.output_data, context.expected_output, context.metadata
# Must NOT modify self attributes (thread safety)
passed = ... # Your logic here
return EvaluatorResult(
value=passed,
reasoning="...",
assessment="pass" if passed else "fail",
)
# Validate JSON syntax + optional required keys
JSONEvaluator(required_keys=["name", "age"], output_extractor=None, name=None)
# Validate length (characters, words, or lines)
LengthEvaluator(count_by="words", min_length=10, max_length=500, output_extractor=None, name=None)
# count_by: "characters" | "words" | "lines"
# String matching
StringCheckEvaluator(operation="contains", expected="success", case_sensitive=False, name=None)
# operation: "eq" | "ne" | "contains" | "icontains"
# Regex matching
RegexMatchEvaluator(pattern=r"\d{4}-\d{2}-\d{2}", match_mode="search", name=None)
# match_mode: "search" | "match" | "fullmatch"
| Signal | Evaluator Type |
|--------|---------------|
| Output must be valid JSON | JSONEvaluator |
| Output must match a regex pattern | RegexMatchEvaluator |
| Output has length constraints | LengthEvaluator |
| Output must contain/not contain specific strings | StringCheckEvaluator |
| Semantic quality judgment (tone, accuracy, completeness) | LLMJudge + BooleanStructuredOutput |
| Graded quality on a scale | LLMJudge + ScoreStructuredOutput |
| Classification into categories | LLMJudge + CategoricalStructuredOutput |
| Multi-dimensional judgment (evaluate several aspects at once) | LLMJudge + custom JSON schema dict |
| Complex domain logic combining multiple checks | BaseEvaluator subclass |
If you have access to dd-trace-py locally, verify the API surface by reading the corresponding modules:
ddtrace.llmobs._evaluators.llm_judge — LLMJudge, BooleanStructuredOutput, ScoreStructuredOutput, CategoricalStructuredOutputddtrace.llmobs._experiment — BaseEvaluator, EvaluatorContext, EvaluatorResultddtrace.llmobs._evaluators.format — JSONEvaluator, LengthEvaluatorddtrace.llmobs._evaluators.string_matching — StringCheckEvaluator, RegexMatchEvaluatorEntry mode detection:
| Mode | Signal | Behavior |
|------|--------|----------|
| Cold Start | Only ml_app provided (no RCA, no hypothesis) | Full open discovery — understand what the app does, identify quality dimensions worth measuring, propose evals for coverage |
| From RCA | Conversation contains an RCA report or user provides a failure hypothesis | Skip open discovery — use existing failure taxonomy as eval targets |
Parse arguments: Extract ml_app (first non-flag argument), --timeframe (default now-7d), --trace-limit (default 20), --sdk-code, --data-only, and --emit-dataset <path> flags. Set output_mode as follows (at most one of the three mode flags may be set; error if more than one is present):
--emit-dataset <path> set → output_mode = emit_dataset. Skip the rest of the workflow entry-mode logic and jump directly to Phase 3D below.--sdk-code set → output_mode = sdk_code.--data-only set → output_mode = data_only.output_mode = publish (the default — propose online evaluators, gated on user confirmation, created as disabled drafts).Resolution steps:
ml_app not provided → ask the user.from_rca. Extract the taxonomy.from_rca. Use the hypothesis as the starting eval target.cold_start.timeframe not provided → default to now-7d.output_mode = data_only (there is no Datadog eval project to check coverage against): Call list_llmobs_evals (org-wide; filter the result client-side to entries where ml_app == <ml_app>). Then, for each eval with source=custom, call get_llmobs_evaluator(eval_name=...) to inspect its prompt template, target, sampling, and filter, and infer which quality dimension it covers. Issue all evaluator calls in a single message (parallelize). Skip source=ootb evals — their names are self-describing and they may not have a fetchable config.By the end of this step you have a complete coverage map: {eval_name → source, enabled, dimension}. Carry this into Phase 2 for deduplication.
In publish mode, also note any template-variable convention the existing custom evaluators already use (so a new suite reads consistently). Online evaluator templates resolve against the full span JSON, not against EvaluatorContext. See the "Online Template Variables" section under "Publishing Conventions" for the supported syntax ({{span_input}}, {{span_output}}, dot-paths, array selectors, filter accessors).
/eval-trace-rca (pattern: https://app.datadoghq.com/notebook/{numeric-id}). If found, store it as rca_notebook_url and extract the numeric ID as rca_notebook_id. This is used after Phase 3 to offer appending the evaluator suite to that notebook instead of creating a new one.Goal: Sample production traces, understand what the app does, and identify quality dimensions worth measuring.
search_llmobs_spans(query="@ml_app:\"<ml_app>\" @status:ok", root_spans_only=true, limit=50, from=<timeframe>). Filter by @status:ok — error spans have no output to evaluate.Session probe *(gates session-scope proposals; publish mode)*: in the same message, also call search_llmobs_spans(query="@ml_app:\"<ml_app>\" session_id:*", limit=20, from=<timeframe>).
sessions_present = true. Note the distinct session_id values and, critically, whether the same session_id appears across multiple trace_ids — that cross-trace span is the real signal that a session carries context worth a session-scope evaluator. (A session_id that only ever maps to one trace adds nothing over trace scope.)sessions_present = false. Do not propose any session-scope evaluator; record a one-line "session scope skipped — no session_id on sampled spans" note for the proposal.get_llmobs_span_details for span_ids grouped by trace_id. Inspect content_info to classify:| Signal | App Profile |
|--------|------------|
| content_info has messages | LLM/chat app |
| content_info has documents | RAG app |
| Spans include agent kind | Agent app |
| content_info has metadata | Has custom metadata |
| Multiple span kinds in one trace (agent + tool / retrieval + llm from get_llmobs_trace) | Multi-step app — at least one trace-scope evaluator likely belongs in the suite (publish mode) |
| Same session_id across multiple trace_ids (from the session probe) | Multi-trace sessions — at least one session-scope evaluator likely belongs in the suite (publish mode, gated on sessions_present) |
For agent/multi-step apps, also call get_llmobs_trace on 2-3 traces to see the full span hierarchy. Compare content_info between the root span and its sub-spans. Then ask two questions for each candidate quality dimension, in this order:
retrieval span's documents AND an llm span's answer; goal completion depends on the chain of tool calls AND the final response.) If yes → trace scope in publish mode. Don't try to compress this into a single span.Record the span-kind histogram (agent + tool + llm + retrieval) — multiple kinds under one root is a strong signal you'll have at least one trace-scope evaluator in the suite. See Phase 2's "Span vs. Trace vs. Session Scope Classification" for the mandatory walk-through of canonical trace-scope use cases (and, when sessions_present, the canonical session-scope use cases).
get_llmobs_span_content for representative spans. Fetch fields based on app profile:| App Profile | Fields to Fetch |
|------------|----------------|
| LLM/chat | messages (path=$.messages[0] for system prompt), output |
| RAG | documents, input, output |
| Agent | get_llmobs_agent_loop for the agent span, then messages for detail |
| Any with metadata | metadata |
Issue all calls in a single message. As you read, capture two streams of signal:
Generic quality signals — what does "success" look like? What variance exists across outputs? Each observed quality dimension becomes a candidate evaluator, with the traces you've just read as evidence. Also look for safety signals (scope violations, sensitive data in outputs, out-of-character responses) and add a safety evaluator if you find them.
Domain signals — these become the *domain-specific evaluator* category in Phase 2 (the highest-leverage category). For every 5–10 traces, write down:
applying for benefit X, comparing flight options, summarizing a policy, creating a widget)Don't try to enumerate domain signals exhaustively before reading traces — let the patterns surface as you read. The goal is breadth in the eventual proposal, not completeness in this exploration step.
query="session_id:*") to set sessions_present — a failure that only manifests across a multi-trace conversation (lost context, repeated mistakes, mounting frustration) is a session-scope target.Instrumentation Deficiency, Harness Deficiency, Runtime Error, Upstream Data Issue, or any other root cause that points to infrastructure/environment rather than model behavior. If any are present, pause and ask:> "Some failure modes were diagnosed as infrastructure or instrumentation issues rather than model behavior (e.g., {list the infra root causes}). Evaluators can be designed two ways:
> - Behavior-targeted (recommended for ongoing quality): measure whether the model produces correct, specific output — useful once the infrastructure is fixed and you want to track real quality
> - Artifact-targeted (useful as regression guard): detect the specific broken output observed (e.g., generic placeholder responses) — catches regressions if the infrastructure breaks again
>
> Which approach do you want, or both?"
expected_output / gold-standard examples as the quality bar.StringCheckEvaluator for a known bad string, LLMJudge that checks for generic placeholders).If all root causes are behavioral (System Prompt Deficiency, Tool Gap, Tool Misuse, Retrieval Failure, etc.) → skip this step and proceed directly.
get_llmobs_span_content to understand the concrete pattern.Goal: Present a concrete evaluator proposal for user confirmation.
In sdk_code / data_only mode — and for eval_scope: span in publish mode — each evaluator judges one data point: input and output for a single record/span, not a full trace or batch. In publish mode, eval_scope: trace judges a whole trace and eval_scope: session a whole multi-trace session — design those against the trace / session payload instead (see "Span vs. Trace vs. Session Scope Classification" below). Design evaluators accordingly for their scope.
Targeting depends on output_mode:
sdk_code / data_only → offline experiments. Template variables use EvaluatorContext fields ({{input_data}}, {{output_data}}). The actual data shape depends on the user's dataset and task function (see EvaluatorContext note in SDK Reference).publish → online evaluation on production spans. Template variables resolve against the full span JSON via dot-paths ({{meta.input.value}}, {{meta.output.messages[*].content}}, …) or the built-in span-kind-aware aliases ({{span_input}}, {{span_output}}). For eval_scope: trace and eval_scope: session, templates resolve against the trace payload ({{spans[...]}}) or the session payload ({{traces[*].spans[...]}}) instead. See "Online Template Variables" under Publishing Conventions for the full syntax. Each evaluator also needs eval_scope, sampling_percentage, and (optionally) filter — surface these in the proposal table so the user can confirm before publishing. Session scope is only used when the Phase 1 probe set sessions_present.Order proposals from broadest signal to most granular. Propose broadly, let the user curate — see "How many evaluators to propose" below.
intent_classification or intent_handling_correctness evaluator scoped to the dominant intents.cited_url_is_real, agency_name_matches_request, monetary_amount_is_consistent_with_input).tool spans. Propose a per-tool argument-correctness evaluator for the tools with non-trivial schemas (e.g., search_flights_args_match_user_request, update_dashboard_widget_targets_correct_widget).cites_a_source, refuses_medical_advice, tone_matches_brand).Name each evaluator after the *user-facing concern*, not the technical check (agency_url_is_real over regex_url_match). Use the trace IDs you read in Phase 1 as evidence — at least one passing case and one failing case per evaluator if you saw both.
task_completion, answer_correctness, response_groundednessvalid_json_output, response_length, citation_formatno_pii_leakage, scope_adherence, no_hallucinationThe default 4-6 cap from the older skill version was too tight — it pushed the skill toward generic evaluators only and left domain signals on the table. Updated guidance:
response_quality") if you don't have evidence for them.In data_only mode: skip this section entirely (coverage map was not built in Phase 0). Proceed directly to the proposal table.
Before building the proposal, apply the coverage map from Phase 0. Coverage is keyed on (dimension, scope) — not on dimension alone: every OOTB evaluator runs at span scope, and an enabled OOTB eval does NOT preclude proposing a trace-scope or session-scope evaluator for the same dimension. The three scopes answer different questions.
Goal Completeness evaluates each LLM span in isolation; this trace-scope goal_completion checks whether the agent's full sequence of steps achieved the user's request, and a session-scope session_goal_completion checks it across the whole conversation — three different questions."> hallucination (ootb, disabled) — consider enabling in Datadog UI (Evaluations → Configure) instead of creating a custom span-scope eval. (A trace-scope rag_faithfulness is still in scope and covers a different question.)
For each proposed evaluator:
^[a-zA-Z0-9_-]+$ (alphanumeric, underscore, hyphen only)LLMJudge (Boolean/Score/Categorical/custom JSON schema), built-in (JSONEvaluator, RegexMatchEvaluator, etc.), or BaseEvaluator subclass. *In publish mode, only LLM-judge evaluators are supported by the MCP tool — code-based checks must NOT be silently dropped. List them in the same proposal table with Type set to the code-based class, mark them under a "Not publishable in this mode" subsection of the proposal, and tell the user they can get them as offline code on request (--sdk-code, or ask after the publish run) or as a --data-only spec. Treat the code-based proposals as part of the suite for counting and coverage purposes.*anthropic.request", "all llm spans"). If the root span's I/O is too lossy for the quality dimension (e.g., tool call results aren't visible), note this and specify which sub-span has the signal. *In publish mode this maps to a combination of eval_scope (span/trace/session), root_spans_only, and the EVP filter query (e.g. @meta.span.kind:llm or service:web).*pass_when=True, min_threshold=7, pass_values=["correct"], or "no automatic assessment" for custom JSON schemainput_data, output_data, expected_output, metadata.* it uses (offline) — or which span paths / aliases it pulls from (publish mode: {{span_input}}, {{span_output}}, {{meta.input.messages[*].content}}, {{meta.metadata.<key>}}, etc.)publish mode)*: integration_provider (default openai), model_name (default gpt-5.4-mini), sampling_percentage (default 10), eval_scope (default span), and any filter query needed to scope to the right spans. Surface defaults in the proposal so the user can override before publishing.integration_account_id *(only in publish mode)*: the integration account the judge LLM is called through. Auto-detected from existing evaluators in the same ml_app (Phase 0 coverage map). Never asked from the user as a raw UUID. If no existing evaluator has one, the field is omitted and the user picks an account in the UI before activating. All evaluators are published with enabled: false regardless — see "Always publish as draft" in Phase 3C for the full activation workflow.publish mode)Don't ask the user; classify per evaluator and let them override at the checkpoint.
If Phase 1 found multi-step traces (≥ 2 span kinds, or any tool / retrieval / workflow span under an agent root), you MUST walk through the four canonical trace-scope use cases below before finalizing the suite. For each, decide explicitly: applies (include with eval_scope: trace) or does not apply (record a one-line reason in a "Skipped trace-scope candidates" subsection of the proposal). Skipping all four without per-item justification is a sign you've over-anchored on span scope — re-check.
| Canonical use case | Triggers when |
|---|---|
| goal_completion — did the agent finish the user's request? | Any agent / multi-step app. Almost always applies. |
| tool_use_correctness — right tool with right arguments? | Trace contains tool kind spans. |
| rag_faithfulness — answer grounded in retrieved documents? | Trace contains retrieval kind spans. |
| conversation_quality — coherence across multi-turn LLM calls? | Trace contains ≥ 2 llm spans, or app instruments multi-turn sessions. |
sessions_present)Gate: perform this walk-through only if the Phase 1 session probe set sessions_present = true. If sessions are absent, skip session scope entirely and note "session scope skipped — no session_id on sampled spans" in the proposal.
When sessions_present, you MUST walk through the four canonical session-scope use cases below. For each, decide explicitly: applies (include with eval_scope: session) or does not apply (one-line reason in a "Skipped session-scope candidates" subsection). Session scope answers questions that span more than one trace under the same session_id — a single trace cannot see prior or later turns.
| Canonical session use case | Triggers when |
|---|---|
| session_goal_completion — were the user's goals met across the whole session? | A session_id spans ≥ 2 traces. Almost always applies for multi-trace sessions. |
| multi_turn_conversation_quality — coherence, memory, and consistent tone across turns | Multi-trace chat / assistant sessions. |
| user_frustration_signals — frustration, confusion, repetition, or abandonment over the session | Any multi-turn session (repeated or rephrased asks across traces). |
| agent_consistency_across_session — did the agent stay consistent and recover from errors across traces? | Agent app whose sessions span ≥ 2 traces. |
For other proposed evaluators (e.g. tone, format, safety), apply this scope test in order:
meta.input + meta.output, where "correctly" means the verdict cannot change if you considered other spans in the trace? → eval_scope: span.eval_scope: trace. Default to trace when the evaluator name contains *grounding*, *faithfulness*, *hallucination*, *completeness*, *correctness across steps*, *consistency*, or *workflow* — these almost always need cross-span context.session_id (overall satisfaction, behavior over time, multi-turn coherence) and sessions_present → eval_scope: session. Default to session when the name contains *session*, *conversation*, *across turns*, *over time*, *satisfaction*, *frustration*, or *abandonment*. If sessions_present is false, fall back to trace scope and note the limitation.Trace scope costs more than span scope: one judgment per completed trace (vs. per matching span), larger prompt payloads, and a 3-minute trigger latency (Datadog waits 3 minutes of inactivity before considering a trace complete; later spans are excluded). Session scope costs the most: one judgment per completed session (a session_id is complete after 30 minutes of inactivity — vs. 3 minutes for a trace — and spans arriving > 30 min after the prior span are excluded), with the largest payloads (every span of every trace in the session, capped at 10,000 spans). These are cost-control levers — handle with sampling_percentage and filter, not by demoting scope. The *correctness* of the eval is what picks the scope.
Add a Scope column to the proposal table and a one-sentence rationale per evaluator. If you skipped a canonical trace-scope or session-scope use case, list it under the matching "Skipped …-scope candidates" subsection with the reason — the user will see and can override.
> Example rationales:
> - tone_check — span. Judging "is this single response polite" needs only one LLM span's meta.output.messages[*].content; no other span in the trace can change that verdict.
> - goal_completion — trace. Whether the agent finished the user's request depends on the sequence of tool calls and the final LLM response together — meta.output of any single span only shows that step's output.
> - tool_use_correctness — trace. Comparing tool inputs against the request and the final response requires correlating ≥ 3 spans (root, tool, final LLM).
> - rag_faithfulness — trace. Grounding pairs the retrieval span's documents with the LLM span's answer.
> - session_goal_completion — session. Whether the user's overall goals were met depends on every trace in the session_id, not just the last one — only session scope sees the full conversation.
> - user_frustration_signals — session. Frustration surfaces as repeated or rephrased asks across traces; a single trace can't reveal the pattern.
>
> Example "Skipped trace-scope candidates" entry:
> - conversation_quality — skipped: traces contain a single LLM call (no multi-turn signal in this app's instrumentation).
>
> Example "Skipped session-scope candidates" entry:
> - session_goal_completion — skipped: every session_id maps to a single trace (no cross-trace context — trace scope already covers it).
You MUST output the proposal and wait for user confirmation before proceeding.
## Proposed Evaluator Suite
**App profile**: {LLM | RAG | Agent | Multi-agent}
**Entry mode**: {cold_start | from_rca}
| # | Name | Type | Scope | Measures | Pass Criteria |
|---|------|------|-------|----------|---------------|
| 1 | task_completion | LLMJudge (Boolean) | span | Whether the task was completed on this span | pass_when=True |
| 2 | tool_use_correctness | LLMJudge (Categorical) | trace | Right tool with right arguments across the agent run | pass_values=["correct"] |
| 3 | session_goal_completion | LLMJudge (Categorical) | session | Whether the user's goals were met across the whole multi-trace session | pass_values=["completed"] |
| 4 | ... | ... | ... | ... | ... |
(Drop the **Scope** column when not in `publish` mode.)
For each evaluator:
- **{name}**: {what it measures}
- Target span: {which span's data it was designed for}
- Rationale: {which quality dimension it covers and why}
- {Only in publish mode:} Scope: {span | trace | session} — {one-sentence rationale}
- Evidence: [Trace {id_short}](https://app.datadoghq.com/llm/traces?query=trace_id:{full_id})
{Only in publish mode, for multi-step apps. Required if any of the four canonical trace-scope use cases was not included above:}
**Skipped trace-scope candidates:**
- `{canonical_use_case}` — {one-line reason it does not apply to this app}
{Only in publish mode, when `sessions_present`. Required if any of the four canonical session-scope use cases was not included above:}
**Skipped session-scope candidates:**
- `{canonical_use_case}` — {one-line reason it does not apply, e.g. "every `session_id` maps to a single trace"}
{Only in publish mode, when the session probe found no sessions:}
**Session scope skipped** — no `session_id` on sampled spans; session-scope evaluators not proposed.
{Only in publish mode, when the suite contains code-based evaluators (JSONEvaluator, RegexMatchEvaluator, LengthEvaluator, StringCheckEvaluator, BaseEvaluator). Required when any code-based proposal exists.}
**Not publishable in this mode** (code-based evaluators — the publish API is LLM-judge only):
- `{name}` ({type}) — {what it would check}. Ask me to emit these as offline SDK code (or run `/eval-bootstrap {ml_app} --sdk-code`), or `/eval-bootstrap {ml_app} --data-only` for a framework-agnostic JSON spec.
Which evaluators should I generate? Treat the proposal as a candidate set — the suite below is intentionally broad so you can pick what matters for your team's quality bar. Reply with which to keep, which to drop, and which to rename; not every domain-specific proposal will fit your priorities. In sdk_code mode you may also add custom evaluators or change provider/model. In publish mode you may override integration_provider, model_name, sampling_percentage, eval_scope, root_spans_only, or filter per evaluator. (In the default publish mode these are created as online drafts in Datadog on confirmation — you review and enable them in the UI. Prefer offline SDK code or a JSON spec instead? Say so and I'll generate the confirmed suite that way.)
Do NOT proceed to code generation until the user confirms.
Branch on output_mode:
publish *(default)* → skip to Phase 3Csdk_code → Phase 3A belowdata_only → skip to Phase 3Bemit_dataset → skip to Phase 3D (Phases 0 step 4, 1, and 2 are bypassed — see Phase 3D for the dataset-mode workflow)The default path publishes online evaluators. If the user then asks for the suite as offline code or a portable spec (e.g. "now generate the SDK code for these", "give me a JSON spec"), do not re-run Phase 1–2. Reuse the already-confirmed evaluator suite and jump straight to Phase 3A (sdk_code) or Phase 3B (data_only), translating each published online evaluator into the offline form:
{{input_data}} / {{output_data}} placeholders (offline data comes from the user's dataset/task function, not spans — see the EvaluatorContext note), preserving the rubric and pass criteria.BaseEvaluator / built-in evaluators here.This works the other way too: a user who started with --sdk-code can ask to publish the confirmed suite online (Phase 3C). The emit_dataset path is separate from the evaluator workflow — it never has a "confirmed suite" to translate.
Goal: Generate the final .py file and write it to disk.
For each confirmed evaluator, generate production-quality Python code following the SDK Reference patterns above.
{{input_data}} and {{output_data}} as top-level placeholders in prompts — do NOT reference nested span paths like {{input_data.messages[-1].content}}. The evaluator's data comes from the user's dataset and task function, not directly from spans. Instead, add a comment above each evaluator describing what data it was designed for and what the user should adapt: # Designed for: input_data = user query, output_data = assistant response text
# Observed from: root agent span (input.value → output.value)
# If your dataset uses a different structure, adapt the prompt references below.
JSONEvaluator, RegexMatchEvaluator, StringCheckEvaluator, or LengthEvaluator, do NOT use an LLMJudge. Code-based evaluators are faster, cheaper, and deterministic.super().__init__(name=name) in __init__EvaluatorResult from evaluate()evaluate() (thread safety)^[a-zA-Z0-9_-]+$. Use snake_case descriptive names.evaluators list at the bottom of the file.The generated .py file should follow this structure:
"""
Auto-generated evaluators for {ml_app}
Generated: {YYYY-MM-DD} by eval-bootstrap
App profile: {LLM | RAG | Agent | Multi-agent}
Quality dimensions covered:
- {target_name}: {description}
Evidence: https://app.datadoghq.com/llm/traces?query=trace_id:{full_id}
...
Usage:
from ddtrace.llmobs import LLMObs
experiment = LLMObs.experiment(
name="my-experiment",
task=my_task_fn,
dataset=dataset,
evaluators=evaluators,
)
experiment.run()
"""
{imports — only what is used}
# --- Outcome Evaluators ---
{evaluator code}
# --- Format Evaluators ---
{evaluator code}
# --- Safety Evaluators ---
{evaluator code}
# --- Evaluator Suite ---
evaluators = [
{eval_1_variable_name},
{eval_2_variable_name},
...
]
Only include section comments (Outcome/Format/Safety) for categories that have evaluators.
Write the generated code to the output path (suggest ./evals/{ml_app}_evaluators.py if not specified), then display a summary:
## Generated Evaluators
Wrote {N} evaluators to `{output_path}`:
| # | Name | Type | Covers |
|---|------|------|--------|
| 1 | ... | ... | ... |
### Next Steps
1. **Review**: Check the generated prompts and criteria match your expectations
2. **Test offline**: Use `LLMObs.experiment(evaluators=evaluators)` to batch-evaluate against a labeled dataset and verify scores
After displaying the summary, offer notebook export.
rca_notebook_url was detected in Phase 0:> An RCA notebook was created earlier in this session: {rca_notebook_url}
> Would you like to (a) append the evaluator suite summary to that notebook, or (b) create a new standalone notebook?
If append: use the notebook creation fallback pattern (see below) with mcp__datadog-mcp__edit_datadog_notebook (id={rca_notebook_id}, append_only=true, evaluator suite summary cell).
If new: use the notebook creation fallback pattern (see below) with mcp__datadog-mcp__create_datadog_notebook.
rca_notebook_url:> Would you like to export this evaluator suite summary to a Datadog notebook?
If yes: use the notebook creation fallback pattern (see below) with mcp__datadog-mcp__create_datadog_notebook:
name: Eval Bootstrap: {ml_app} — YYYY-MM-DDtype: reportcells: single markdown cell with the evaluator suite summarytime: { "live_span": "1h" }Notebook creation fallback pattern (apply to every create_datadog_notebook / edit_datadog_notebook call):
/tmp/nb_bootstrap_{ml_app}.json as a full API envelope: {"data": {"attributes": {"name": "...", "time": {...}, "cells": [...]}, "type": "notebooks"}}pup notebooks create --file /tmp/nb_bootstrap_{ml_app}.jsonEvaluator suite exported to notebook: <url>
Notebook cell content — the markdown cell should contain:
## Eval Bootstrap: {ml_app}
**Generated**: YYYY-MM-DD | **App profile**: {LLM | RAG | Agent | Multi-agent} | **Entry mode**: {cold_start | from_rca}
**Generated code**: `{output_path}`
{One sentence: what does this app do?}
**Coverage**: {N} new evaluators ({comma-separated dimension names}) | {N} existing (unchanged: {names}) | {gaps if any: dimensions identified but not covered, and why}
### Evaluator Suite
| # | Name | Type | Measures | Pass Criteria |
|---|------|------|----------|---------------|
| 1 | ... | ... | ... | ... |
### Evidence
{For each evaluator: name — 1-line description — [Trace link]}
### Next Steps
1. Review generated prompts in `{output_path}`
2. Run against a labeled dataset to validate scores
3. Deploy to Datadog LLM Experiments
Goal: Serialize the confirmed evaluator suite and representative trace samples to a single self-contained JSON file — zero SDK dependencies.
Output path: ./evals/{ml_app}_eval_spec.json
{
"schema_version": "1",
"generated_at": "<ISO 8601 UTC>",
"generated_by": "eval-bootstrap",
"app": {
"ml_app": "<string>",
"app_type": "LLM | RAG | Agent | Multi-agent",
"trace_window": "<timeframe param, e.g. now-7d>",
"trace_count": "<integer>"
},
"evaluators": [
{
"name": "snake_case_name",
"category": "outcome | format | safety",
"type": "llm_judge | code_check",
"description": "<1-2 sentence plain-language description>",
"target_span": "<which span: root, llm sub-span, etc.>",
"scoring": {
"scale": "boolean | score_1_10 | categorical",
"categories": ["<only present when scale=categorical>"],
"pass_criteria": "<human-readable: true, >= 7, in [correct], etc.>"
},
"rubric": "<full prompt text for llm_judge; null for code_check>",
"implementation_hints": {
"type_if_code_check": "json_valid | regex | contains | length_words | null",
"pattern_if_code_check": "<pattern string or null>",
"notes": "<optional framework-agnostic implementation guidance>"
},
"evidence": [
{
"trace_id": "<32-char hex>",
"span_id": "<16-char hex>",
"url": "https://app.datadoghq.com/llm/traces?query=trace_id:<trace_id>",
"observation": "<why this trace illustrates the evaluator>"
}
]
}
],
"sample_records": [
{
"trace_id": "<string>",
"span_id": "<string>",
"input": {},
"output": "<string>",
"suggested_labels": {
"<evaluator_name>": "pass | fail | <score>"
}
}
]
}
evaluators[].type: "llm_judge" for semantic evaluators; "code_check" for deterministic checks (regex, length, JSON validity, etc.).evaluators[].rubric: For llm_judge — full prompt text grounded in observed trace patterns. Use {{input}} and {{output}} as generic placeholders (not {{input_data}} — that's ddeval-specific). For code_check — null.evaluators[].implementation_hints.notes: Optional framework-agnostic guidance, e.g. "For OpenAI Evals, use rubric as a model-graded criterion. For Braintrust, use as an LLM scorer. For Promptfoo, use as an llm-rubric assertion."Take datadog-labs/agent-observability-eval-bootstrap from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.