CALIBER
Quickstart

Cookbook 09 · Operate

Self-Healing Workflows

Reproduce production failures, read the run debugger and trace, write the patch as a new version, prove it on the same 35 tickets, and roll an alias back.

OperateCore20–30 min
What you build. A refund-intake workflow (start, validate, check_reference, lookup, decide, final) that is fine on the tickets you tested and fails on the ones production sends. Version 1 completes 11 of 35 tickets and fails 24, in three nodes for three reasons: a schema violation in validate, a poison record that makes check_reference time out, and an account-service error that fails decide two steps after lookup. You write the patch yourself (three node bodies, saved as version 2) and rerun all 35. No model is involved (no agent node) and the account service is a stand-in, assets/upstream/account_service.py.
Surfaces: Workflows Run Monitor Versions Observability
What you learn
  • Reproduce a schema failure (F12), a poison record (F29) and an upstream failure (F32), which all show the same failed badge, and find the node in Recovery Diagnostics (Current node), Execution Debugger and the error trace
  • See that a node failure leaves no checkpoint (only approvals and waits do) and that Retry (Attempt 2 of 2) fails at the same node: a retry is not a fix for a code fault
  • Call propose-patch and see its limits: a generic prompt suggestion for the timed-out node and a 400 for a guardrail patch aimed at a code node; the CALIBER Patches tab stays empty
  • Write version 2 by hand (assets/workflow/patch/validate.py, check_reference.py, decide.py), prove it on all 35 tickets, and compare versions in Versions
  • Move the staging alias to version 2, run through it, roll back, and see prod refuse a version with no deploy gate

Implementation flow

flowchart LR
  R[Run 35 tickets on v1] --> F[24 failed, 11 completed]
  F --> D[Recovery Diagnostics, Execution Debugger, trace]
  D --> RC[Root cause node: validate, check_reference or decide]
  RC --> RT[Retry: Attempt 2 of 2 fails at same node]
  RT --> PP[propose-patch: no code fix]
  PP --> P[Edit 3 node bodies, save and publish v2]
  P --> V[Run 35 tickets on v2: 0 failed]
  V --> A[staging alias to v2, rollback restores v1]
  A --> PR[prod refuses: no deploy gate]

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 · workflow: refund-intake (v1 draft) ticket-intake.v1.workflow.yaml ↓
    Import version 1 of the workflow. Click Import, name it refund-intake, Choose file ticket-intake.v1.workflow.yaml, click Validate dependencies, then Import as new. Before this, start the stand-in account service the workflow calls (assets/upstream/account_service.py 8780) and the server with CALIBER_EGRESS_ALLOWED_HOSTS=127.0.0.1.
    Fill in
    Namerefund-intake
    Fileticket-intake.v1.workflow.yaml
    Click Import as new
    You'll see: Preflight passed, then the editor opens on the graph start → validate → check_reference → lookup → decide → final.
    Screen snapshot
    caliber · Agent resources › Workflows › Import
    WorkflowsImport
    Import as new
  2. Agent resources › Workflows › refund-intake › editor creates · published version 1
    Publish it. Click Publish in the toolbar: Validate, Next, Next, Publish.
    Click Publish
    You'll see: The editor shows Published.; the version is now read-only.
    Screen snapshot
    caliber · Agent resources › Workflows › refund-intake › editor
    Workflowseditor
    Publish
  3. Agent resources › Workflows › refund-intake › Run Monitor creates · a completed run failing-inputs.jsonl ↓
    Run a healthy ticket. Open Run Monitor, paste the input.payload of row F01 and click Run.
    Fill in
    Run inputthe payload of F01
    Click Run
    You'll see: The run is completed and the output is {"amount": 48.0, "currency": "USD", "decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE", "ticket_id": "T-3101"}.
    Screen snapshot
    caliber · Agent resources › Workflows › refund-intake › Run Monitor
    WorkflowsRun Monitor
    Run
  4. Run Monitor › Recovery Diagnostics / Resume Checkpoints / Execution Debugger creates · failing run: schema violation at validate
    Reproduce a schema failure. Paste row F12 (the amount is the string "48.00") and click Run. Read Recovery Diagnostics, Resume Checkpoints and Execution Debugger.
    Fill in
    Run inputthe payload of F12
    Click Run
    You'll see: failed. Recovery Diagnostics says This run ended in failed. with Current node validate and ValueError: amount must be a number, got '48.00'. Resume Checkpoints: No persisted checkpoints exist for this run yet. The debugger shows 1 recorded step.
    Screen snapshot
    caliber · Run Monitor › Recovery Diagnostics / Resume Checkpoints / Execution Debugger
    Recovery Diagnostics / Resume Checkpoints / Execution Debugger
    Run
  5. Run Monitor creates · failing run: timeout at check_reference
    Reproduce the poison record. Paste row F29 (an order reference that sends a nested-quantifier regex into catastrophic backtracking) and click Run.
    Fill in
    Run inputthe payload of F29
    Click Run
    You'll see: After about two seconds: failed, python_code node 'check_reference' timed out after 2.0s, 2 recorded steps.
    Screen snapshot
    caliber · Run Monitor
    Run Monitor
    Run
  6. Run Monitor › Execution Debugger creates · failing run: upstream error surfacing in decide
    Reproduce the upstream failure. Paste row F32 (an account id the stand-in answers with 503) and click Run. Then in Execution Debugger select the lookup step.
    Fill in
    Run inputthe payload of F32
    Click Run
    You'll see: failed with python_code node 'decide' failed: KeyError: 'tier' and 4 recorded steps. The cause is the step before the failing node: lookup received status 503.
    Screen snapshot
    caliber · Run Monitor › Execution Debugger
    Execution Debugger
    Run
  7. Run Monitor › Retry Lineage creates · retry lineage (attempt 2 of 2)
    Click Retry.
    Click Retry
    You'll see: Attempt 2 of 2, and the new run fails at decide again: a retry runs the same code on the same input.
    Screen snapshot
    caliber · Run Monitor › Retry Lineage
    Retry Lineage
    Retry
  8. Agent resources › Workflows › refund-intake › CALIBER Patches creates · no patch candidates
    Look for a patch. Open the workflow page and the CALIBER Patches tab.
    You'll see: No CALIBER patches yet. Nothing in the UI calls propose-patch; the API path shows what it returns for a Python node (a prompt suggestion, no graph change).
    Screen snapshot
    caliber · Agent resources › Workflows › refund-intake › CALIBER Patches
    WorkflowsCALIBER Patches
    Read / inspect this surface — no form to fill.
  9. Agent resources › Workflows › refund-intake › Versions, then the editor creates · published version 2 validate.py ↓ check_reference.py ↓ decide.py ↓
    Patch it. In Versions click Restore as draft on v1. In the editor click the validate node and replace its Code with the content of patch/validate.py; do the same for check_reference and decide. Click Save, then Publish as before.
    Fill in
    validate Codepatch/validate.py
    check_reference Codepatch/check_reference.py
    decide Codepatch/decide.py
    Click Publish
    You'll see: Saved, then Published.: version 2.
    Screen snapshot
    caliber · Agent resources › Workflows › refund-intake › Versions, then the editor
    WorkflowsVersions, then the editor
    Publish
  10. Run Monitor (version 2) creates · fixed runs
    Prove it. Run F12, F29, F32 and F18 (no account id) on version 2.
    Fill in
    Run inputthe payload of each row
    Click Run
    You'll see: All four are completed: F12 ELIGIBLE_AUTO_APPROVE, F29 ORDER_REF_UNVERIFIED, F32 ACCOUNT_LOOKUP_FAILED with "upstream_status": 503, F18 "decision": "rejected_input".
    Screen snapshot
    caliber · Run Monitor (version 2)
    Run Monitor (version 2)
    Run
  11. Agent resources › Workflows › refund-intake › Versions creates · version diff, prod refusal
    Compare, then try to promote. Under Compare versions choose base v1 and newer v2. Then click Promote on v2 and confirm Promote v2 to LIVE.
    Click Promote
    You'll see: The comparison lists the three changed nodes. The promotion is refused: promoting to 'prod' (production) requires a deploy gate; attach one whose required_for_aliases includes this alias. (The staging alias and its rollback are API only.)
    Screen snapshot
    caliber · Agent resources › Workflows › refund-intake › Versions
    WorkflowsVersions
    Promote

Assets (copy-paste)

The exact files this cookbook uses — copy each into the matching field. Source: docs-site/cookbooks/09-workflow-debugger-self-healing-lab/assets/.

assets/workflow/ticket-intake.v1.workflow.yaml
schema_version: 1
workflow_id: refund-intake
name: refund-intake
description: Validate a refund ticket, look the account up, and decide approve or manual review. Version 1, the one that fails in production.
runtime:
  sdk: openai-agents-python
  sdk_version_policy: runtime-pinned
  compiler_version: caliber-workflow-compiler-v1
  default_model_ref: CALIBER_WORKFLOW_DEFAULT_MODEL
  session:
    type: none
nodes:
  start:
    id: start
    type: start
    outputs:
      user_message:
        type: string
  validate:
    id: validate
    type: python_code
    timeout_seconds: 5
    inputs:
      input:
        type: string
    outputs:
      text:
        type: string
      result:
        type: structured
    code: |
      def run_python_node(input=None, context=None, inputs=None, run_input=''):
          raw = input if input is not None else run_input
          ticket = json.loads(raw) if isinstance(raw, str) else raw
          if not isinstance(ticket, dict):
              raise ValueError("ticket must be a JSON object")
          for key in ("ticket_id", "account_id", "amount", "currency", "reason", "order_ref"):
              if key not in ticket:
                  raise ValueError("missing required field '" + key + "'")
          amount = ticket["amount"]
          if isinstance(amount, bool) or not isinstance(amount, (int, float)):
              raise ValueError("amount must be a number, got " + repr(amount))
          if amount <= 0:
              raise ValueError("amount must be greater than 0, got " + repr(amount))
          if ticket["currency"] not in ("USD", "EUR", "GBP"):
              raise ValueError("unsupported currency " + repr(ticket["currency"]))
          if not re.match(r"^A-[0-9]{4}$", str(ticket["account_id"])):
              raise ValueError("account_id must look like A-1234, got " + repr(ticket["account_id"]))
          if not str(ticket["reason"]).strip():
              raise ValueError("reason must not be empty")
          ticket["ok"] = True
          return ticket
  check_reference:
    id: check_reference
    type: python_code
    timeout_seconds: 2
    inputs:
      ticket:
        type: structured
    outputs:
      text:
        type: string
      result:
        type: structured
      query:
        type: structured
    code: |
      ORDER_REF = re.compile(r"^(?:[A-Z0-9]+-?)+$")

      def run_python_node(input=None, context=None, inputs=None, run_input=''):
          ticket = dict(inputs.get("ticket") or {})
          ticket["reference_valid"] = bool(ORDER_REF.match(str(ticket.get("order_ref") or "")))
          ticket["query"] = {"account_id": ticket.get("account_id")}
          return ticket
  lookup:
    id: lookup
    type: api_request
    mode: url
    url: http://127.0.0.1:8780/accounts
    method: GET
    timeout_seconds: 3
    inputs:
      payload:
        type: structured
    outputs:
      text:
        type: string
      response:
        type: structured
      metadata:
        type: structured
  decide:
    id: decide
    type: python_code
    timeout_seconds: 5
    inputs:
      ticket:
        type: structured
      account:
        type: structured
    outputs:
      text:
        type: string
      result:
        type: structured
    code: |
      LIMITS = {"standard": 200, "premium": 500}

      def run_python_node(input=None, context=None, inputs=None, run_input=''):
          ticket = inputs["ticket"]
          account = inputs["account"]["json"]
          limit = LIMITS[account["tier"]]
          if account["status"] != "active":
              decision, reason = "manual_review", "ACCOUNT_NOT_ACTIVE"
          elif ticket["amount"] > limit:
              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"
          result = {
              "ticket_id": ticket["ticket_id"],
              "decision": decision,
              "reason_code": reason,
              "amount": ticket["amount"],
              "currency": ticket["currency"],
          }
          return result
  final:
    id: final
    type: output
    inputs:
      response:
        type: string
edges:
  - id: e_start_validate
    from: start
    to: validate
    map:
      user_message: input
  - id: e_validate_reference
    from: validate
    to: check_reference
    map:
      result: ticket
  - id: e_reference_lookup
    from: check_reference
    to: lookup
    map:
      query: payload
  - id: e_reference_decide
    from: check_reference
    to: decide
    map:
      result: ticket
  - id: e_lookup_decide
    from: lookup
    to: decide
    map:
      response: account
  - id: e_decide_final
    from: decide
    to: final
    map:
      text: response
assets/dataset/failing-inputs.jsonl
{"id": "F01", "tags": ["healthy"], "input": {"payload": "{\"ticket_id\": \"T-3101\", \"account_id\": \"A-1007\", \"amount\": 48.0, \"currency\": \"USD\", \"reason\": \"Item arrived damaged in transit\", \"order_ref\": \"ORD-2291-A\"}"}, "expected": {"v1_status": "completed", "v1_failing_node": null, "v1_error_contains": null, "decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}}
{"id": "F02", "tags": ["healthy"], "input": {"payload": "{\"ticket_id\": \"T-3102\", \"account_id\": \"A-1188\", \"amount\": 120, \"currency\": \"USD\", \"reason\": \"Wrong size shipped, need a refund\", \"order_ref\": \"ORD-7710\"}"}, "expected": {"v1_status": "completed", "v1_failing_node": null, "v1_error_contains": null, "decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}}
{"id": "F03", "tags": ["healthy", "premium_limit"], "input": {"payload": "{\"ticket_id\": \"T-3103\", \"account_id\": \"A-1020\", \"amount\": 450.0, \"currency\": \"USD\", \"reason\": \"Blender stopped working after a week\", \"order_ref\": \"ORD-3340-B\"}"}, "expected": {"v1_status": "completed", "v1_failing_node": null, "v1_error_contains": null, "decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}}
{"id": "F04", "tags": ["healthy", "over_limit"], "input": {"payload": "{\"ticket_id\": \"T-3104\", \"account_id\": \"A-1188\", \"amount\": 260, \"currency\": \"USD\", \"reason\": \"Monitor has dead pixels\", \"order_ref\": \"ORD-5102\"}"}, "expected": {"v1_status": "completed", "v1_failing_node": null, "v1_error_contains": null, "decision": "manual_review", "reason_code": "AMOUNT_OVER_LIMIT"}}
{"id": "F05", "tags": ["healthy", "suspended_account"], "input": {"payload": "{\"ticket_id\": \"T-3105\", \"account_id\": \"A-2210\", \"amount\": 35, \"currency\": \"USD\", \"reason\": \"Charged twice for the same order\", \"order_ref\": \"ORD-2291-A\"}"}, "expected": {"v1_status": "completed", "v1_failing_node": null, "v1_error_contains": null, "decision": "manual_review", "reason_code": "ACCOUNT_NOT_ACTIVE"}}
{"id": "F06", "tags": ["healthy", "unicode"], "input": {"payload": "{\"ticket_id\": \"T-3106\", \"account_id\": \"A-1033\", \"amount\": 18.5, \"currency\": \"EUR\", \"reason\": \"Café machine arrived cracked — photo attached\", \"order_ref\": \"ORD-9001\"}"}, "expected": {"v1_status": "completed", "v1_failing_node": null, "v1_error_contains": null, "decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}}
{"id": "F07", "tags": ["borderline", "lowercase_order_ref"], "input": {"payload": "{\"ticket_id\": \"T-3107\", \"account_id\": \"A-1188\", \"amount\": 75, \"currency\": \"GBP\", \"reason\": \"Item arrived damaged\", \"order_ref\": \"ord-5521\"}"}, "expected": {"v1_status": "completed", "v1_failing_node": null, "v1_error_contains": null, "decision": "manual_review", "reason_code": "ORDER_REF_UNVERIFIED"}}
{"id": "F08", "tags": ["healthy", "suspended_account", "high_amount"], "input": {"payload": "{\"ticket_id\": \"T-3108\", \"account_id\": \"A-3300\", \"amount\": 999, \"currency\": \"USD\", \"reason\": \"Subscription renewed after cancellation\", \"order_ref\": \"ORD-2291-A\"}"}, "expected": {"v1_status": "completed", "v1_failing_node": null, "v1_error_contains": null, "decision": "manual_review", "reason_code": "ACCOUNT_NOT_ACTIVE"}}
{"id": "F09", "tags": ["borderline", "trailing_hyphen"], "input": {"payload": "{\"ticket_id\": \"T-3109\", \"account_id\": \"A-1188\", \"amount\": 30, \"currency\": \"USD\", \"reason\": \"Item arrived damaged\", \"order_ref\": \"ORD-4410-\"}"}, "expected": {"v1_status": "completed", "v1_failing_node": null, "v1_error_contains": null, "decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}}
{"id": "F10", "tags": ["borderline", "long_reason"], "input": {"payload": "{\"ticket_id\": \"T-3110\", \"account_id\": \"A-1020\", \"amount\": 60.0, \"currency\": \"USD\", \"reason\": \"The parcel was left outside in the rain and the box was soaked through. The parcel was left outside in the rain and the box was soaked through. The parcel was left outside in the rain and the box was soaked through. The parcel was left outside in the rain and the box was soaked through. The parcel was left outside in the rain and the box was soaked through. The parcel was left outside in the rain and the box was soaked through. The parcel was left outside in the rain and the box was soaked through. The parcel was left outside in the rain and the box was soaked through. The parcel was left outside in the rain and the box was soaked through. The parcel was left outside in the rain and the box was soaked through. The parcel was left outside in the rain and the box was soaked through. The parcel was left outside in the rain and the box was soaked through. The parcel was left outside in the rain and the box was soaked through. The parcel was left outside in the rain and the box was soaked through. The parcel was left outside in the rain and the box was soaked through. The parcel was left outside in the rain and the box was soaked through. The parcel was left outside in the rain and the box was soaked through. The parcel was left outside in the rain and the box was soaked through. \", \"order_ref\": \"ORD-6120\"}"}, "expected": {"v1_status": "completed", "v1_failing_node": null, "v1_error_contains": null, "decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}}
{"id": "F11", "tags": ["borderline", "lowercase_looks_like_poison"], "input": {"payload": "{\"ticket_id\": \"T-3111\", \"account_id\": \"A-1188\", \"amount\": 52, \"currency\": \"USD\", \"reason\": \"Item arrived damaged\", \"order_ref\": \"abcdefghijklmnopqrstuvwxyz0123456789\"}"}, "expected": {"v1_status": "completed", "v1_failing_node": null, "v1_error_contains": null, "decision": "manual_review", "reason_code": "ORDER_REF_UNVERIFIED"}}
{"id": "F12", "tags": ["schema_violation", "normalizable", "amount_as_string"], "input": {"payload": "{\"ticket_id\": \"T-3112\", \"account_id\": \"A-1007\", \"amount\": \"48.00\", \"currency\": \"USD\", \"reason\": \"Item arrived damaged\", \"order_ref\": \"ORD-2291-A\"}"}, "expected": {"v1_status": "failed", "v1_failing_node": "validate", "v1_error_contains": "amount must be a number, got '48.00'", "decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}}
{"id": "F13", "tags": ["schema_violation", "normalizable", "amount_as_string"], "input": {"payload": "{\"ticket_id\": \"T-3113\", \"account_id\": \"A-1020\", \"amount\": \"$1,048.00\", \"currency\": \"USD\", \"reason\": \"Item arrived damaged\", \"order_ref\": \"ORD-8800\"}"}, "expected": {"v1_status": "failed", "v1_failing_node": "validate", "v1_error_contains": "amount must be a number", "decision": "manual_review", "reason_code": "AMOUNT_OVER_LIMIT"}}
{"id": "F14", "tags": ["schema_violation", "normalizable", "currency_case"], "input": {"payload": "{\"ticket_id\": \"T-3114\", \"account_id\": \"A-1188\", \"amount\": 22, \"currency\": \"usd\", \"reason\": \"Item arrived damaged\", \"order_ref\": \"ORD-1209\"}"}, "expected": {"v1_status": "failed", "v1_failing_node": "validate", "v1_error_contains": "unsupported currency 'usd'", "decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}}
{"id": "F15", "tags": ["schema_violation", "normalizable", "currency_symbol"], "input": {"payload": "{\"ticket_id\": \"T-3115\", \"account_id\": \"A-1188\", \"amount\": 15, \"currency\": \"$\", \"reason\": \"Item arrived damaged\", \"order_ref\": \"ORD-1210\"}"}, "expected": {"v1_status": "failed", "v1_failing_node": "validate", "v1_error_contains": "unsupported currency '$'", "decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}}
{"id": "F16", "tags": ["schema_violation", "normalizable", "account_id_format"], "input": {"payload": "{\"ticket_id\": \"T-3116\", \"account_id\": \" a-1188 \", \"amount\": 80, \"currency\": \"USD\", \"reason\": \"Item arrived damaged\", \"order_ref\": \"ORD-1211\"}"}, "expected": {"v1_status": "failed", "v1_failing_node": "validate", "v1_error_contains": "account_id must look like A-1234", "decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE"}}
{"id": "F17", "tags": ["schema_violation", "ambiguous"], "input": {"payload": "{\"ticket_id\": \"T-3117\", \"account_id\": \"A-1188\", \"amount\": \"€ 34,50\", \"currency\": \"EUR\", \"reason\": \"Item arrived damaged\", \"order_ref\": \"ORD-2291-A\"}"}, "expected": {"v1_status": "failed", "v1_failing_node": "validate", "v1_error_contains": "amount must be a number", "decision": "rejected_input", "reason_code": "INVALID_TICKET", "v2_errors_contain": "ambiguous"}}
{"id": "F18", "tags": ["schema_violation", "missing_field"], "input": {"payload": "{\"ticket_id\": \"T-3118\", \"amount\": 48.0, \"currency\": \"USD\", \"reason\": \"Item arrived damaged\", \"order_ref\": \"ORD-2291-A\"}"}, "expected": {"v1_status": "failed", "v1_failing_node": "validate", "v1_error_contains": "missing required field 'account_id'", "decision": "rejected_input", "reason_code": "INVALID_TICKET", "v2_errors_contain": "missing required field 'account_id'"}}
{"id": "F19", "tags": ["schema_violation", "negative_amount"], "input": {"payload": "{\"ticket_id\": \"T-3119\", \"account_id\": \"A-1188\", \"amount\": -20, \"currency\": \"USD\", \"reason\": \"Item arrived damaged\", \"order_ref\": \"ORD-2291-A\"}"}, "expected": {"v1_status": "failed", "v1_failing_node": "validate", "v1_error_contains": "amount must be greater than 0", "decision": "rejected_input", "reason_code": "INVALID_TICKET", "v2_errors_contain": "greater than 0"}}
{"id": "F20", "tags": ["schema_violation", "zero_amount"], "input": {"payload": "{\"ticket_id\": \"T-3120\", \"account_id\": \"A-1188\", \"amount\": 0, \"currency\": \"USD\", \"reason\": \"Item arrived damaged\", \"order_ref\": \"ORD-2291-A\"}"}, "expected": {"v1_status": "failed", "v1_failing_node": "validate", "v1_error_contains": "amount must be greater than 0", "decision": "rejected_input", "reason_code": "INVALID_TICKET", "v2_errors_contain": "greater than 0"}}
{"id": "F21", "tags": ["schema_violation", "null_amount"], "input": {"payload": "{\"ticket_id\": \"T-3121\", \"account_id\": \"A-1188\", \"amount\": null, \"currency\": \"USD\", \"reason\": \"Item arrived damaged\", \"order_ref\": \"ORD-2291-A\"}"}, "expected": {"v1_status": "failed", "v1_failing_node": "validate", "v1_error_contains": "amount must be a number, got None", "decision": "rejected_input", "reason_code": "INVALID_TICKET", "v2_errors_contain": "must be a number"}}
{"id": "F22", "tags": ["schema_violation", "unsupported_currency"], "input": {"payload": "{\"ticket_id\": \"T-3122\", \"account_id\": \"A-1188\", \"amount\": 48.0, \"currency\": \"JPY\", \"reason\": \"Item arrived damaged\", \"order_ref\": \"ORD-2291-A\"}"}, "expected": {"v1_status": "failed", "v1_failing_node": "validate", "v1_error_contains": "unsupported currency 'JPY'", "decision": "rejected_input", "reason_code": "INVALID_TICKET", "v2_errors_contain": "unsupported currency"}}
{"id": "F23", "tags": ["schema_violation", "account_id_format"], "input": {"payload": "{\"ticket_id\": \"T-3123\", \"account_id\": \"1007\", \"amount\": 48.0, \"currency\": \"USD\", \"reason\": \"Item arrived damaged\", \"order_ref\": \"ORD-2291-A\"}"}, "expected": {"v1_status": "failed", "v1_failing_node": "validate", "v1_error_contains": "account_id must look like A-1234", "decision": "rejected_input", "reason_code": "INVALID_TICKET", "v2_errors_contain": "account_id must look like"}}
{"id": "F24", "tags": ["schema_violation", "empty_reason"], "input": {"payload": "{\"ticket_id\": \"T-3124\", \"account_id\": \"A-1188\", \"amount\": 48.0, \"currency\": \"USD\", \"reason\": \"   \", \"order_ref\": \"ORD-2291-A\"}"}, "expected": {"v1_status": "failed", "v1_failing_node": "validate", "v1_error_contains": "reason must not be empty", "decision": "rejected_input", "reason_code": "INVALID_TICKET", "v2_errors_contain": "reason must not be empty"}}
{"id": "F25", "tags": ["schema_violation", "not_an_object"], "input": {"payload": "[1, 2, 3]"}, "expected": {"v1_status": "fa
… truncated — open the file in the repo for the full content.
assets/workflow/patch/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/workflow/patch/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 {})
    ref = str(ticket.get("order_ref") or "")
    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/workflow/patch/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
Version 1 against the dataset11 completed, 24 failed: 17 validate, 3 check_reference, 4 decide
Failing node is findableERROR trace span names the node; no checkpoint; retry fails at the same node
Version 2 against the dataset35 completed, 0 failed (10 approve, 13 manual_review, 12 rejected_input)
Regression slicethe 11 tickets v1 handled give identical output
Alias and prod guardrollback restores v1; prod promote of an ungated version is refused (400)
Developer notes & gotchas
  • Prerequisite flags. The lab itself needs none: workflows, the Run Monitor, versions and aliases are part of the supported alpha. CALIBER_FEATURE_COOKBOOKS=true only opens the gallery, whose starter this lab does not use. Aria is not used.
  • Egress and the stand-in service. Start assets/upstream/account_service.py 8780 (not a real system; fixed 503, 500 and 404 ids) and the stack with CALIBER_EGRESS_ALLOWED_HOSTS=127.0.0.1 scripts/cookbook-env.sh up lab09 --flags cookbooks; without the allowed host lookup fails with outbound request to '127.0.0.1' is blocked. Needs a workflow worker.
  • Nothing here needs a model. There is no agent node, so CALIBER_LLM_PROVIDER=fake does not matter and every number is measured. The poison records time out because Python re really backtracks.
  • Preview and deploy gates cannot run this workflow. Python Code and API Request nodes are refused (preview blocked before execution ...), so the proof is real runs of the dataset on version 2, and a prod promotion is refused for lack of a deploy gate.
  • Patching is manual. propose-patch is API only, agent-shaped (it cannot repair a code node) and no page calls it. Aria is not used and there is no UI for aliases: the alpha UI has one live alias (prod), so staging and its rollback are API only.
  • Run it. PYTHONPATH=sdk/caliber-sdk caliber/.venv/bin/python sdk/caliber-sdk/examples/cookbooks/cookbook_09_self_healing_workflows.py (about three minutes, about 75 runs) or the spec caliber/caliber-ui/e2e/cookbooks/labs/09-workflow-debugger.spec.ts (npx playwright test --config=playwright.beta.config.ts); offline check caliber/tests/test_cookbook_09_self_healing.py.
  • Retry from a checkpoint exists for approvals and waits (lab 03), not for node failures; role failures are covered by lab 18.

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.