CALIBER
Quickstart

Cookbook 16 · Operate

Production Observability & Triage

Turn real production traces into a regression test set and a triage review queue, with the reviewers' answers written back onto the traces.

OperateCore30–45 min
What you build. You replay 40 production-like refund tickets through a real workflow (the buggy version 1 of cookbook 09), so CALIBER records 40 MLflow traces: 12 ERROR and 28 OK, four of which are silently wrong. You find failures with the status filter, read a trace's node tree for the failing node, capture the 16 traces that matter into a test set with their gold outcome, and route them to a prod-triage review queue whose answers appear as assessments on the traces. Nothing here needs a model.
Surfaces: Observability Test Sets Review Queues Workflows
What you learn
  • Filter traces by status (All statuses / OK / Error / In progress) and search by text
  • Read the Spans tree: node.validate, node.check_reference or node.decide is ERROR; for an upstream failure node.lookup is OK and decide fails
  • Capture traces into a test set with Add to test set or Capture from trace, then replace the captured error text with the gold outcome
  • Stand up a review queue with five triage questions, enqueue trace ids and submit reviews so answers write back as trace assessments
  • See how Observability behaves on an unknown trace (404), no match (empty list) and MLflow down (503)
  • Find the 4 silent failures (P25 to P28) that the Error filter cannot see

Implementation flow

flowchart LR
  SEED["seed_traces.py: 40 tickets through workflow v1"] --> OBS["Operate: Observability, filter Status = Error"]
  OBS --> TR["Open trace: Spans node tree"]
  TR -->|"Add to test set"| DS[("Test Set: prod-regression")]
  DS --> GOLD["Edit Expected: gold outcome"]
  TR -->|"trace ids, Enqueue"| RQ[("Review Queue: prod-triage")]
  RQ -->|"Submit review"| AS["Assessments on the trace"]
  OBS --> SIL["Find the OK but wrong traces by hand"]
  SIL --> RQ

Step-by-step UI only

Each step shows the exact navigation path, the fields to fill, the button to click, and a snapshot of the CALIBER screen you'll be on.

  1. Agent resources › Workflows › Import creates · published workflow (version 1)
    Click Import, name it prod-refund-intake, Choose file ticket-intake.v1.workflow.yaml (lab 09's version 1), Validate dependencies, Import as new. In the editor click Publish: Validate, Next, Next, Publish.
    Fill in
    Nameprod-refund-intake
    Click Import as new
    You'll see: Preflight passed, then the editor, then Published. This is the workflow "already running in production".
    Screen snapshot
    caliber · Agent resources › Workflows › Import
    WorkflowsImport
    Import as new
  2. Agent resources › Workflows › editor › Run Monitor creates · 40 real traces prod-regression.sample.jsonl ↓ seed_traces.py (API alternative) ↓
    Open Run Monitor, paste a ticket (a row's input.payload), click Run, wait for the badge, and repeat for P01 to P40.
    You'll see: 12 runs end failed, 28 completed; each records a trace (Open in Observability in the run's Execution Trace panel).
    Screen snapshot
    caliber · Agent resources › Workflows › editor › Run Monitor
    WorkflowsRun Monitor
    Read / inspect this surface — no form to fill.
  3. Operate › Observability creates · filtered traces
    Open Observability. Set Filter by status to Error, then OK, then All statuses.
    Fill in
    Filter by statusError, then OK
    You'll see: Error shows only ERROR rows (12 per time the 40 tickets were sent), OK shows 28 per time. Each row's request is the ticket. A trace that has just ended can read IN_PROGRESS for a moment; the list refreshes itself every five seconds, under any filter, so a failure that had not closed when you opened the page appears without a reload.
    Screen snapshot
    caliber · Operate › Observability
    ObservabilityObservability
  4. Operate › Observability › trace detail creates · root cause read from the node tree
    Search T-5035 in Search traces and open the row (the id lands in the URL as ?trace=). Read the Spans tree.
    You'll see: For the poison ticket T-5035: workflow.run ERROR, node.validate OK, node.check_reference ERROR (2.04 s). For the upstream ticket T-5038: node.lookup OK and node.decide ERROR.
    Screen snapshot
    caliber · Operate › Observability › trace detail
    Observabilitytrace detail
    Read / inspect this surface — no form to fill.
  5. Operate › Observability creates · empty state and 404
    Search with no match, then open an unknown trace. Type no-such-ticket-zzz in Search traces, then open /caliber/observability?trace=tr-doesnotexist.
    Fill in
    Search tracesno-such-ticket-zzz
    You'll see: The empty state, then trace 'tr-doesnotexist' not found (a 404).
    Screen snapshot
    caliber · Operate › Observability
    ObservabilityObservability
  6. Prompt lifecycle › Test Sets › + New Test Set creates · test set: prod-regression
    Create the test set Observability will capture into. Name prod-regression, owner @admin, Create.
    Fill in
    Nameprod-regression
    Owner@admin
    Click Create
    You'll see: The test set is listed. (Observability can only add to an existing test set.)
    Screen snapshot
    caliber · Prompt lifecycle › Test Sets › + New Test Set
    Test Sets+ New Test Set
    Create
  7. Operate › Observability › Add to test set; Test Sets › Capture from trace creates · captured examples
    Capture failures. In Observability open the T-5038 trace, choose prod-regression under Add to test set and click Add example. Then open the test set, click Capture from trace, paste the T-5035 trace id and click Capture.
    Fill in
    Add to test setprod-regression
    Trace idthe T-5035 trace id
    Click Capture
    You'll see: Two examples. Each input is the ticket, tagged from-trace and trace:<id>.
    Screen snapshot
    caliber · Operate › Observability › Add to test set; Test Sets › Capture from trace
    ObservabilityCapture from trace
    Capture
  8. Prompt lifecycle › Test Sets › prod-regression creates · gold outcome on a captured example
    Put the gold outcome on a captured example. A capture stores the response as the expected answer, and for a failed run that is the error text. Click Edit on the first example, set Expected (JSON object) to {"decision": "manual_review", "reason_code": "ACCOUNT_LOOKUP_FAILED", "upstream_status": 503} and Save.
    Fill in
    Expected (JSON object)the gold outcome of P38
    Click Save
    You'll see: The example becomes version 2 and shows the gold outcome.
    Screen snapshot
    caliber · Prompt lifecycle › Test Sets › prod-regression
    Test Setsprod-regression
    Save
  9. Operate › Review Queues › New queue creates · review queue: prod-triage triage-review.review-questions.json ↓
    Create the triage queue from triage-review.review-questions.json: name prod-triage, then add the five questions with + Add question (key, title, type, target, and the options for failure_mode and severity) and click Create queue.
    Fill in
    Nameprod-triage
    Questions5: pass_fail, categorical, categorical, text (expectation), text
    Click Create queue
    You'll see: The queue is listed.
    Screen snapshot
    caliber · Operate › Review Queues › New queue
    Review QueuesNew queue
    Create queue
  10. Operate › Review Queues › prod-triage creates · reviewed items
    Enqueue and review two traces. Select the queue, paste the trace ids of T-5038 and T-5025 (a wrong OK trace) into Trace ids and click Enqueue. For each: Pass, pick Where did it fail? and Operational severity, fill What should the run have produced? and Triage notes, Submit review.
    Fill in
    Trace idsthe two trace ids
    Click Submit review
    You'll see: Items (2), then All items reviewed.
    Screen snapshot
    caliber · Operate › Review Queues › prod-triage
    Review Queuesprod-triage
    Submit review
  11. Operate › Observability › trace detail creates · assessments on the trace
    Open the T-5038 trace again and read Assessments.
    You'll see: failure_mode tool and severity high are listed with the other three answers: the review was written back onto the trace.
    Screen snapshot
    caliber · Operate › Observability › trace detail
    Observabilitytrace detail
    Read / inspect this surface — no form to fill.
  12. Agent resources › Workflows › Versions creates · workflow version 2 fix/check_reference.py ↓ fix/validate.py ↓ fix/decide.py ↓
    Open prod-refund-intake, tab Versions, Restore as draft on v1. In the editor click the validate node and replace its Code with assets/fix/validate.py; do the same for check_reference and decide. Save, then Publish.
    You'll see: Saved, then Published.: version 2.
    Screen snapshot
    caliber · Agent resources › Workflows › Versions
    WorkflowsVersions
    Read / inspect this surface — no form to fill.
  13. Operate › Observability › Compare creates · old and new trace compared
    In Run Monitor run P25 to P40 again. In Observability search T-5038, click Compare and select both rows.
    You'll see: All 16 runs complete with the gold outcome. T-5038 has two traces, OK (version 2) above ERROR (version 1); the comparison shows them side by side.
    Screen snapshot
    caliber · Operate › Observability › Compare
    ObservabilityCompare
    Read / inspect this surface — no form to fill.
  14. Agent resources › Workflows › Versions › Compare versions creates · version diff
    Open prod-refund-intake, tab Versions, Compare versions: base v1, newer v2.
    You'll see: The panel lists the changed nodes, check_reference among them.
    Screen snapshot
    caliber · Agent resources › Workflows › Versions › Compare versions
    WorkflowsCompare versions
    Read / inspect this surface — no form to fill.

Assets (copy-paste)

The exact files this cookbook uses — copy each into the matching field. Source: docs-site/cookbooks/16-observability-triage/assets/.

assets/dataset/prod-regression.sample.jsonl
{"id": "P01", "tags": ["ok", "correct"], "input": {"payload": "{\"ticket_id\": \"T-5001\", \"account_id\": \"A-1007\", \"amount\": 48.0, \"currency\": \"USD\", \"reason\": \"Item arrived damaged in transit\", \"order_ref\": \"ORD-2291-A\"}"}, "expected": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}, "note": "premium account, small amount"}
{"id": "P02", "tags": ["ok", "correct"], "input": {"payload": "{\"ticket_id\": \"T-5002\", \"account_id\": \"A-1188\", \"amount\": 120, \"currency\": \"USD\", \"reason\": \"Wrong size shipped\", \"order_ref\": \"ORD-7710\"}"}, "expected": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}, "note": "standard account under the 200 limit"}
{"id": "P03", "tags": ["ok", "correct"], "input": {"payload": "{\"ticket_id\": \"T-5003\", \"account_id\": \"A-1020\", \"amount\": 450.0, \"currency\": \"USD\", \"reason\": \"Blender stopped working after a week\", \"order_ref\": \"ORD-3340-B\"}"}, "expected": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}, "note": "premium limit is 500"}
{"id": "P04", "tags": ["ok", "correct"], "input": {"payload": "{\"ticket_id\": \"T-5004\", \"account_id\": \"A-1188\", \"amount\": 260, \"currency\": \"USD\", \"reason\": \"Monitor has dead pixels\", \"order_ref\": \"ORD-5102\"}"}, "expected": {"decision": "manual_review", "reason_code": "AMOUNT_OVER_LIMIT"}, "note": "standard limit is 200"}
{"id": "P05", "tags": ["ok", "correct"], "input": {"payload": "{\"ticket_id\": \"T-5005\", \"account_id\": \"A-2210\", \"amount\": 35, \"currency\": \"USD\", \"reason\": \"Charged twice for the same order\", \"order_ref\": \"ORD-8841\"}"}, "expected": {"decision": "manual_review", "reason_code": "ACCOUNT_NOT_ACTIVE"}, "note": "suspended account is never auto-approved"}
{"id": "P06", "tags": ["ok", "correct"], "input": {"payload": "{\"ticket_id\": \"T-5006\", \"account_id\": \"A-1033\", \"amount\": 18.5, \"currency\": \"EUR\", \"reason\": \"Café machine arrived cracked\", \"order_ref\": \"ORD-9001\"}"}, "expected": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}, "note": "EUR is a supported currency"}
{"id": "P07", "tags": ["ok", "correct"], "input": {"payload": "{\"ticket_id\": \"T-5007\", \"account_id\": \"A-1190\", \"amount\": 75, \"currency\": \"GBP\", \"reason\": \"Subscription renewed after cancellation\", \"order_ref\": \"ORD-6120\"}"}, "expected": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}, "note": "GBP is a supported currency"}
{"id": "P08", "tags": ["ok", "correct"], "input": {"payload": "{\"ticket_id\": \"T-5008\", \"account_id\": \"A-3300\", \"amount\": 999, \"currency\": \"USD\", \"reason\": \"Duplicate invoice\", \"order_ref\": \"ORD-4410\"}"}, "expected": {"decision": "manual_review", "reason_code": "ACCOUNT_NOT_ACTIVE"}, "note": "suspended account"}
{"id": "P09", "tags": ["ok", "correct"], "input": {"payload": "{\"ticket_id\": \"T-5009\", \"account_id\": \"A-1188\", \"amount\": 199.99, \"currency\": \"USD\", \"reason\": \"Headphones do not pair\", \"order_ref\": \"ORD-1209-A\"}"}, "expected": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}, "note": "just under the limit"}
{"id": "P10", "tags": ["ok", "correct"], "input": {"payload": "{\"ticket_id\": \"T-5010\", \"account_id\": \"A-1188\", \"amount\": 200.01, \"currency\": \"USD\", \"reason\": \"Headphones do not pair\", \"order_ref\": \"ORD-1210-A\"}"}, "expected": {"decision": "manual_review", "reason_code": "AMOUNT_OVER_LIMIT"}, "note": "just over the limit"}
{"id": "P11", "tags": ["ok", "correct"], "input": {"payload": "{\"ticket_id\": \"T-5011\", \"account_id\": \"A-1020\", \"amount\": 500, \"currency\": \"USD\", \"reason\": \"Standing desk wobbles\", \"order_ref\": \"ORD-2002\"}"}, "expected": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}, "note": "exactly the premium limit"}
{"id": "P12", "tags": ["ok", "correct"], "input": {"payload": "{\"ticket_id\": \"T-5012\", \"account_id\": \"A-1020\", \"amount\": 501, \"currency\": \"USD\", \"reason\": \"Standing desk wobbles\", \"order_ref\": \"ORD-2003\"}"}, "expected": {"decision": "manual_review", "reason_code": "AMOUNT_OVER_LIMIT"}, "note": "one dollar over the premium limit"}
{"id": "P13", "tags": ["ok", "correct"], "input": {"payload": "{\"ticket_id\": \"T-5013\", \"account_id\": \"A-1191\", \"amount\": 12, \"currency\": \"USD\", \"reason\": \"Missing charger\", \"order_ref\": \"ORD-3100\"}"}, "expected": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}, "note": "small standard refund"}
{"id": "P14", "tags": ["ok", "correct"], "input": {"payload": "{\"ticket_id\": \"T-5014\", \"account_id\": \"A-1192\", \"amount\": 64.5, \"currency\": \"USD\", \"reason\": \"Late delivery\", \"order_ref\": \"ORD-3101\"}"}, "expected": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}, "note": "decimal amount"}
{"id": "P15", "tags": ["ok", "correct"], "input": {"payload": "{\"ticket_id\": \"T-5015\", \"account_id\": \"A-1193\", \"amount\": 88, \"currency\": \"EUR\", \"reason\": \"Wrong colour\", \"order_ref\": \"ORD-3102-C\"}"}, "expected": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}, "note": "hyphenated reference with a suffix"}
{"id": "P16", "tags": ["ok", "correct"], "input": {"payload": "{\"ticket_id\": \"T-5016\", \"account_id\": \"A-1194\", \"amount\": 150, \"currency\": \"USD\", \"reason\": \"Packaging crushed\", \"order_ref\": \"ORD-3103\"}"}, "expected": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}, "note": "standard"}
{"id": "P17", "tags": ["ok", "correct"], "input": {"payload": "{\"ticket_id\": \"T-5017\", \"account_id\": \"A-1033\", \"amount\": 420, \"currency\": \"GBP\", \"reason\": \"Lamp arrived without a bulb\", \"order_ref\": \"ORD-3104\"}"}, "expected": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}, "note": "premium, GBP"}
{"id": "P18", "tags": ["ok", "correct"], "input": {"payload": "{\"ticket_id\": \"T-5018\", \"account_id\": \"A-1195\", \"amount\": 33, \"currency\": \"USD\", \"reason\": \"Sizing guide was wrong\", \"order_ref\": \"ORD-3105\"}"}, "expected": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}, "note": "standard"}
{"id": "P19", "tags": ["ok", "correct"], "input": {"payload": "{\"ticket_id\": \"T-5019\", \"account_id\": \"A-1196\", \"amount\": 205, \"currency\": \"USD\", \"reason\": \"Mattress too firm\", \"order_ref\": \"ORD-3106\"}"}, "expected": {"decision": "manual_review", "reason_code": "AMOUNT_OVER_LIMIT"}, "note": "five dollars over the limit"}
{"id": "P20", "tags": ["ok", "correct"], "input": {"payload": "{\"ticket_id\": \"T-5020\", \"account_id\": \"A-1197\", \"amount\": 9.99, \"currency\": \"USD\", \"reason\": \"App subscription charged twice\", \"order_ref\": \"ORD-3107\"}"}, "expected": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}, "note": "smallest amounts still approve"}
{"id": "P21", "tags": ["ok", "correct"], "input": {"payload": "{\"ticket_id\": \"T-5021\", \"account_id\": \"A-1198\", \"amount\": 72, \"currency\": \"USD\", \"reason\": \"Missing page in the manual\", \"order_ref\": \"ORD-3108\"}"}, "expected": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}, "note": "standard"}
{"id": "P22", "tags": ["ok", "correct"], "input": {"payload": "{\"ticket_id\": \"T-5022\", \"account_id\": \"A-1199\", \"amount\": 181, \"currency\": \"EUR\", \"reason\": \"Printer jams on first use\", \"order_ref\": \"ORD-3109\"}"}, "expected": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}, "note": "standard, EUR"}
{"id": "P23", "tags": ["ok", "correct"], "input": {"payload": "{\"ticket_id\": \"T-5023\", \"account_id\": \"A-1007\", \"amount\": 310, \"currency\": \"USD\", \"reason\": \"Keyboard keys sticking\", \"order_ref\": \"ORD-3110\"}"}, "expected": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}, "note": "premium above the standard limit"}
{"id": "P24", "tags": ["ok", "correct"], "input": {"payload": "{\"ticket_id\": \"T-5024\", \"account_id\": \"A-1200\", \"amount\": 56, \"currency\": \"USD\", \"reason\": \"Gift arrived late\", \"order_ref\": \"ORD-3111\"}"}, "expected": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}, "note": "standard"}
{"id": "P25", "tags": ["ok", "silent_wrong", "lowercase_order_ref"], "input": {"payload": "{\"ticket_id\": \"T-5025\", \"account_id\": \"A-1188\", \"amount\": 65, \"currency\": \"USD\", \"reason\": \"Item arrived damaged\", \"order_ref\": \"ord-5521\"}"}, "expected": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}, "note": "lowercase order reference: production sent it to manual review, the right answer is approve"}
{"id": "P26", "tags": ["ok", "silent_wrong", "lowercase_order_ref"], "input": {"payload": "{\"ticket_id\": \"T-5026\", \"account_id\": \"A-1188\", \"amount\": 66, \"currency\": \"USD\", \"reason\": \"Item arrived damaged\", \"order_ref\": \"ord-5522-a\"}"}, "expected": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}, "note": "lowercase order reference with a suffix: production sent it to manual review, the right answer is approve"}
{"id": "P27", "tags": ["ok", "silent_wrong", "trailing_space"], "input": {"payload": "{\"ticket_id\": \"T-5027\", \"account_id\": \"A-1188\", \"amount\": 67, \"currency\": \"USD\", \"reason\": \"Item arrived damaged\", \"order_ref\": \"ORD-5523 \"}"}, "expected": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}, "note": "trailing space pasted with the order reference: production sent it to manual review, the right answer is approve"}
{"id": "P28", "tags": ["ok", "silent_wrong", "trailing_space"], "input": {"payload": "{\"ticket_id\": \"T-5028\", \"account_id\": \"A-1188\", \"amount\": 68, \"currency\": \"USD\", \"reason\": \"Item arrived damaged\", \"order_ref\": \"ORD-5524  \"}"}, "expected": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}, "note": "trailing spaces pasted with the order reference: production sent it to manual review, the right answer is approve"}
{"id": "P29", "tags": ["error", "validate", "amount_as_string"], "input": {"payload": "{\"ticket_id\": \"T-5029\", \"account_id\": \"A-1007\", \"amount\": \"75.00\", \"currency\": \"USD\", \"reason\": \"Item arrived damaged\", \"order_ref\": \"ORD-2291-A\"}"}, "expected": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}, "note": "amount sent as a string; should normalize"}
{"id": "P30", "tags": ["error", "validate", "amount_as_string"], "input": {"payload": "{\"ticket_id\": \"T-5030\", \"account_id\": \"A-1188\", \"amount\": \"$120.00\", \"currency\": \"USD\", \"reason\": \"Item arrived damaged\", \"order_ref\": \"ORD-5530\"}"}, "expected": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}, "note": "amount with a currency symbol"}
{"id": "P31", "tags": ["error", "validate", "amount_as_string"], "input": {"payload": "{\"ticket_id\": \"T-5031\", \"account_id\": \"A-1188\", \"amount\": \"35\", \"currency\": \"USD\", \"reason\": \"Item arrived damaged\", \"order_ref\": \"ORD-5531\"}"}, "expected": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}, "note": "whole-number string"}
{"id": "P32", "tags": ["error", "validate", "currency_case"], "input": {"payload": "{\"ticket_id\": \"T-5032\", \"account_id\": \"A-1188\", \"amount\": 48.0, \"currency\": \"usd\", \"reason\": \"Item arrived damaged\", \"order_ref\": \"ORD-5532\"}"}, "expected": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}, "note": "lowercase currency code"}
{"id": "P33", "tags": ["error", "validate", "missing_field"], "input": {"payload": "{\"ticket_id\": \"T-5033\", \"amount\": 48.0, \"currency\": \"USD\", \"reason\": \"Item arrived damaged\", \"order_ref\": \"ORD-5533\"}"}, "expected": {"decision": "rejected_input", "reason_code": "INVALID_TICKET", "v2_errors_contain": "missing required field 'account_id'"}, "note": "no account id: reject with the reason, do not crash"}
{"id": "P34", "tags":
… truncated — open the file in the repo for the full content.
assets/seed_traces.py
#!/usr/bin/env python3
"""Run the lab's 40 production tickets through a real workflow, so Observability has real traces.

In production these traces come from your own traffic. A fresh stack has none, and every step of this
lab works on traces, so this script produces them the way production does: it imports the
``refund-intake`` workflow from cookbook 09 (version 1, the one with the bugs), publishes it, and
submits each ticket in ``dataset/prod-regression.sample.jsonl`` as a workflow run. CALIBER's runtime
records an MLflow trace for every run; nothing here writes a trace itself, and no row is fabricated.
Which runs fail is decided by the workflow, not by this script.

Needs a server that can reach cookbook 09's stand-in account service (port 8780) and was started with
``CALIBER_EGRESS_ALLOWED_HOSTS=127.0.0.1``. Prints a JSON map ``{"P01": {"run_id", "trace_id",
"status"}, ...}`` on stdout. Every call imports a new workflow and writes 40 new traces, so run it once
per environment.

    export CALIBER_BASE_URL=http://127.0.0.1:5001 CALIBER_TOKEN=calpat_...
    PYTHONPATH=sdk/caliber-sdk python \
      docs-site/cookbooks/16-observability-triage/assets/seed_traces.py > traces.json
"""

from __future__ import annotations

import json
import os
import sys
import time
from pathlib import Path
from typing import Any

HERE = Path(__file__).resolve().parent
DATASET = HERE / "dataset" / "prod-regression.sample.jsonl"
#: Cookbook 09's version 1: validate, check_reference, lookup, decide.
WORKFLOW = (
    HERE.parents[1]
    / "09-workflow-debugger-self-healing-lab/assets/workflow/ticket-intake.v1.workflow.yaml"
)
RUN_TIMEOUT_SECONDS = 180.0


def load_rows(dataset: Path = DATASET) -> list[dict[str, Any]]:
    lines = dataset.read_text(encoding="utf-8").splitlines()
    return [json.loads(line) for line in lines if line.strip()]


def seed(
    caliber: Any,
    *,
    rows: list[dict[str, Any]] | None = None,
    suffix: str | None = None,
    workflow_file: Path = WORKFLOW,
) -> dict[str, dict[str, str]]:
    """Import and publish the workflow, run every row through it, return what each run produced."""
    rows = rows if rows is not None else load_rows()
    suffix = suffix or str(int(time.time()))
    workflow = caliber.workflows.import_workflow(
        manifest_yaml=workflow_file.read_text(encoding="utf-8"),
        name=f"prod-refund-intake-{suffix}",
    )
    version = caliber.workflows.versions.publish(
        caliber.workflows.versions.list(workflow.workflow_id)[0].version_id
    )
    submitted = {
        row["id"]: caliber.workflows.runs.submit(
            workflow_version_id=version.version_id, input=row["input"]["payload"]
        )
        for row in rows
    }
    seeded: dict[str, dict[str, str]] = {}
    for row_id, run in submitted.items():
        done = caliber.workflows.runs.wait(
            run.workflow_run_id, timeout=RUN_TIMEOUT_SECONDS, raise_on_failure=False
        )
        seeded[row_id] = {
            "run_id": done.workflow_run_id,
            "trace_id": done.trace_id or "",
            "status": done.status,
            "workflow_id": workflow.workflow_id,
        }
    return seeded


if __name__ == "__main__":
    from caliber_sdk import CaliberClient

    with CaliberClient(
        os.environ["CALIBER_BASE_URL"], token=os.environ["CALIBER_TOKEN"]
    ) as client:
        json.dump(seed(client), sys.stdout, indent=2)
    sys.stdout.write("\n")
assets/review-queues/triage-review.review-questions.json
{
  "queue_name": "prod-triage",
  "description": "Human triage of failing production traces. Reviewers classify each flagged trace so the failure mode, severity, and the correct expected output are captured as structured labels written back onto the trace (assessments + an expectation).",
  "questions": [
    {
      "key": "root_cause_known",
      "title": "Is the root cause identifiable from the trace?",
      "type": "pass_fail",
      "required": true,
      "target": "feedback"
    },
    {
      "key": "failure_mode",
      "title": "Where did it fail?",
      "type": "categorical",
      "options": ["prompt", "tool", "retrieval", "data", "infra"],
      "required": true,
      "target": "feedback"
    },
    {
      "key": "severity",
      "title": "Operational severity",
      "type": "categorical",
      "options": ["low", "medium", "high"],
      "required": true,
      "target": "feedback"
    },
    {
      "key": "expected_output",
      "title": "What should the run have produced?",
      "type": "text",
      "required": false,
      "target": "expectation"
    },
    {
      "key": "reviewer_notes",
      "title": "Triage notes",
      "type": "text",
      "required": false,
      "target": "feedback"
    }
  ],
  "notes": "Question field shape matches the Review Queues 'New Queue' form: key, title, type (pass_fail | categorical | numeric | text), options (categorical only), required, target (feedback | expectation). 'expected_output' targets expectation so the reviewer's answer becomes a trace expectation; the rest are feedback. Enqueue real failing trace ids (copied from the Observability ?trace= URL); answers write back onto each trace as MLflow assessments/expectations."
}
assets/fix/check_reference.py
ORDER_REF = re.compile(r"^[A-Z0-9]+(?:-[A-Z0-9]+)*-?$")

def run_python_node(input=None, context=None, inputs=None, run_input=''):
    ticket = dict(inputs.get("ticket") or {})
    # Customers type order references in any case; the order system stores them upper-case.
    ref = str(ticket.get("order_ref") or "").strip().upper()
    ticket["reference_valid"] = len(ref) <= 64 and bool(ORDER_REF.match(ref))
    ticket["query"] = {"account_id": ticket["account_id"]} if ticket.get("ok") else {}
    return ticket
assets/fix/validate.py
CURRENCIES = {"USD": "USD", "EUR": "EUR", "GBP": "GBP", "$": "USD", "\u20ac": "EUR", "\u00a3": "GBP"}

def _amount(value):
    if isinstance(value, bool):
        return None, "amount must be a number, got " + repr(value)
    if isinstance(value, (int, float)):
        return value, None
    if isinstance(value, str):
        text = value.strip()
        for symbol in ("$", "\u20ac", "\u00a3", "USD", "EUR", "GBP"):
            text = text.replace(symbol, "")
        text = text.strip()
        if re.match(r"^[0-9]+,[0-9]{1,2}$", text):
            return None, "amount " + repr(value) + " is ambiguous: comma may be a decimal separator"
        text = text.replace(",", "")
        if re.match(r"^[0-9]+(\.[0-9]+)?$", text):
            return (float(text) if "." in text else int(text)), None
    return None, "amount must be a number, got " + repr(value)

def run_python_node(input=None, context=None, inputs=None, run_input=''):
    raw = input if input is not None else run_input
    errors = []
    try:
        ticket = json.loads(raw) if isinstance(raw, str) else raw
    except Exception:
        return {"ok": False, "errors": ["ticket is not valid JSON"]}
    if not isinstance(ticket, dict):
        return {"ok": False, "errors": ["ticket must be a JSON object"]}
    for key in ("ticket_id", "account_id", "amount", "currency", "reason", "order_ref"):
        if key not in ticket:
            errors.append("missing required field '" + key + "'")
    out = {"ticket_id": ticket.get("ticket_id")}
    if "account_id" in ticket:
        account_id = str(ticket["account_id"]).strip().upper()
        if not re.match(r"^A-[0-9]{4}$", account_id):
            errors.append("account_id must look like A-1234, got " + repr(ticket["account_id"]))
        out["account_id"] = account_id
    if "amount" in ticket:
        amount, problem = _amount(ticket["amount"])
        if problem:
            errors.append(problem)
        elif amount <= 0:
            errors.append("amount must be greater than 0, got " + repr(ticket["amount"]))
        out["amount"] = amount
    if "currency" in ticket:
        currency = CURRENCIES.get(str(ticket["currency"]).strip().upper()) or CURRENCIES.get(str(ticket["currency"]).strip())
        if currency is None:
            errors.append("unsupported currency " + repr(ticket["currency"]))
        out["currency"] = currency
    if "reason" in ticket:
        if not str(ticket["reason"]).strip():
            errors.append("reason must not be empty")
        out["reason"] = str(ticket["reason"]).strip()
    if "order_ref" in ticket:
        out["order_ref"] = str(ticket["order_ref"]).strip()
    out["ok"] = not errors
    if errors:
        out["errors"] = errors
    return out
assets/fix/decide.py
LIMITS = {"standard": 200, "premium": 500}

def run_python_node(input=None, context=None, inputs=None, run_input=''):
    ticket = inputs["ticket"]
    if not ticket.get("ok"):
        return {
            "ticket_id": ticket.get("ticket_id"),
            "decision": "rejected_input",
            "reason_code": "INVALID_TICKET",
            "errors": ticket.get("errors", []),
        }
    response = inputs["account"]
    account = response.get("json")
    if response.get("status_code") != 200 or not isinstance(account, dict) or account.get("tier") not in LIMITS:
        return {
            "ticket_id": ticket["ticket_id"],
            "decision": "manual_review",
            "reason_code": "ACCOUNT_LOOKUP_FAILED",
            "upstream_status": response.get("status_code"),
            "amount": ticket["amount"],
            "currency": ticket["currency"],
        }
    if account.get("status") != "active":
        decision, reason = "manual_review", "ACCOUNT_NOT_ACTIVE"
    elif ticket["amount"] > LIMITS[account["tier"]]:
        decision, reason = "manual_review", "AMOUNT_OVER_LIMIT"
    elif not ticket["reference_valid"]:
        decision, reason = "manual_review", "ORDER_REF_UNVERIFIED"
    else:
        decision, reason = "approve", "ELIGIBLE_AUTO_APPROVE"
    return {
        "ticket_id": ticket["ticket_id"],
        "decision": decision,
        "reason_code": reason,
        "amount": ticket["amount"],
        "currency": ticket["currency"],
    }

Evaluation & quality gates

Quality gateTarget
Traffic recorded40 new traces, 12 ERROR and 28 OK, and the Error filter finds every failing one
Root cause readablethe failing node (validate, check_reference or decide) is ERROR in the node tree
Failure pathsunknown trace id 404, empty window empty list, MLflow down 503
Test set16 traces (12 errors + 4 wrong OK ones), each with its gold outcome
Triage written backprod-triage holds the same 16, two answered, and their five answers appear as assessments
Developer notes & gotchas
  • Feature flag. The lab needs none (Observability, Test Sets and Review Queues are supported alpha); CALIBER_FEATURE_COOKBOOKS=true only opens the gallery. Aria is not used.
  • Setup. The traces come from cookbook 09's workflow: run the stand-in account service (account_service.py 8780, not a real system) and start the server with CALIBER_EGRESS_ALLOWED_HOSTS=127.0.0.1, otherwise all 40 seed runs fail. A worker is required.
  • Nothing is simulated, no model needed. The workflow has no agent node, so the fake default providers change nothing. The optional Evaluations baseline on the test set is not part of this lab (Evaluations refuse on a simulated stack, see lab 10).
  • A capture stores the trace's response as the expected answer, which for a failed run is the error text; edit the example (or pass expected in the API) to put the gold outcome on it.
  • MLflow records traces asynchronously, so the last trace of a run can read IN_PROGRESS for a moment. With CALIBER_TRACING_ENABLED=false runs complete but trace_id is null.
  • Alpha limit: traces are not scoped to a project, so any signed-in user can read every trace and its request text; do not put sensitive data in them on a shared deployment.
  • Not covered: trace-to-refinement automation, the Evaluations baseline, and the UI rendering of the MLflow-down 503 (checked through the API only).
  • Run it with sdk/caliber-sdk/examples/cookbooks/cookbook_16_observability_triage.py or the Playwright spec caliber/caliber-ui/e2e/cookbooks/labs/16-observability-triage.spec.ts.

CALIBER : Contextual Adaptive Lifecycle for Intelligent Build, Evaluation, and Refinement — Cookbooks — every recipe is UI-implementable on the shipped platform. Source + assets under docs-site/cookbooks/<nn>-…/. Regenerate with python3 docs-site/cookbooks/training/build.py.