Cookbook 03 · Foundations
Policy-Safe Decision Tool
A deterministic refund policy hardened against 49 fixtures, then a refund that only a second person can release.
FoundationsCore15–30 min
What you build. A refund policy as a registered read tool (
decide_refund: approve, deny or manual review, with a stable reason code) and a write tool (initiate_refund, registered with requires_approval). You run them in the sandbox, save a 49-case fixture suite, pin a baseline and catch one deliberate regression, then import the refund-decision workflow that decides, routes, and issues the refund only after a different person approves and the run is resumed. No model is involved: nothing here is simulated.
Surfaces: Tools Workflows Administration Audit Log Cookbooks
What you learn
- Register a read tool and a write tool: Write locks Requires Approval on, and a write tool registered without it is refused with
400 - Sandbox: the read tool runs live in a subprocess, the write tool is mocked (Success (mocked))
- Save 49 fixtures, Run calibration (Pass rate 100% — 49/49 passed), pin the run as the baseline, then break R09 and read 1 regression (48/49)
- Import the workflow and Run it: the run stops at Awaiting approval on the
refundnode; the initiator is refused with403,approver1approves, and the refund fires only after Resume - Reject (
approval_rejected, no refund), deny (completes without approval), and read who approved what in the Audit Log - Where the sandbox stops being a boundary: a stalled tool is killed, a large write is refused, the environment is empty, and the network is still reachable
Implementation flow
flowchart LR
A["Tools: register decide_refund and initiate_refund"] --> B["Sandbox: live read, mocked write"]
B --> C["Fixtures: 49 cases"]
C --> D["Hardening: run calibration, 49/49"]
D --> E["Test Runs: Set as baseline"]
E --> F["Break R09: 1 regression"]
F --> G["Workflows: import refund-decision"]
G --> H{"Router on decision"}
H -->|deny| I["Output: denied, no approval"]
H -->|other| J["initiate_refund: waiting_approval"]
J -->|"approver1 approves, admin Resume"| K["Refund issued once"]
K --> L["Audit Log: approver and initiator"]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.
- Register the policy tool. The wizard has five steps: Identity, Implementation, Schema, Playground, Safety & Review. A registered tool must point at importable Python, so you give a
Module Pathand aCallable Namefrom the shipped demo module. On the Schema step use each schema's Raw JSON toggle and pasteinput_schemaandoutput_schemafrom the asset.Fill inName decide_refundVersion 1.0Module Path caliber.workflows.demo_toolsCallable Name decide_refundSide effect level Read (the default) Allow in Preview on, so the sandbox runs the real callable Click Register ToolYou'll see: The tool opens in its workspace. Back in the Tools list its row has no Built-in or Unavailable label: those mark CALIBER's own tools. The address becomes/tools?tool=TL-…, so a reload keeps you there.Screen snapshotcaliber · Tools › Register ToolRegister Tool - Register the write tool the same way. On the Safety & Review step click Write: Requires Approval switches on and is locked, because the registry refuses a write tool without it. (Through the API that refusal is an HTTP 400.)Fill in
Name initiate_refundVersion 1.0Module Path caliber.workflows.demo_toolsCallable Name initiate_refundSide effect level Write Click Register ToolYou'll see:initiate_refundis registered with Requires Approval on and cannot be turned off.Screen snapshotcaliber · Tools › Register ToolRegister Tool Tools › decide_refund › SandboxOpen the tool from the Tools list, then the Sandbox tab. Run the policy with the first fixture's inputs. Then openinitiate_refundand run it: a write tool is never called in the sandbox.Fill inInput JSON (decide_refund) {"order_id": "ord_1007", "account_id": "acct_2013", "order_state": "delivered", "amount": 49.0, "days_since_order": 5, "customer_tier": "standard", "refunds_last_90d": 0, "risk_flags": []}Input JSON (initiate_refund) {"order_id": "ord_1007", "amount": 49.0}Click Test RunYou'll see: Success withdecision: approve,reason_code: ELIGIBLE_AUTO_APPROVE. For the write tool: Success (mocked) and the output{"_preview_mock": true}.Screen snapshotcaliber · Tools › decide_refund › SandboxTest Run- Load the 49 cases from the dataset file: Load cases from file, choose
refund-fixtures.jsonl. Each line becomes a case namedR01 small delivered order, with the line'sinputsas the input JSON and anequalsassertion on itsexpectations(key order and spacing do not matter). Loading only fills the editor; nothing is stored until you save. You can also add or edit single cases by hand with Add case.Click Save casesYou'll see:Loaded 49 cases from refund-fixtures.jsonl. Save cases to keep them., then Saved after you save, and 49 case rows in the editor (still 49 after a reload).Screen snapshotcaliber · Tools › decide_refund › FixturesSave cases Tools › decide_refund › HardeningRun the saved suite. It scores inline, one subprocess per case, so 49 cases take about half a minute. A run is recorded under Test Runs automatically.Click Run calibrationYou'll see: Pass rate 100% — 49/49 passed and a green pass on every case.Screen snapshotcaliber · Tools › decide_refund › HardeningRun calibrationTools › decide_refund › Test RunsOpen Test Runs and pin the latest run. Then go back to Hardening, change the expected value of case R09 (approve) tomanual_review/AMOUNT_OVER_THRESHOLD/true, and run the suite again. Put the value back afterwards and run once more.Click Set as baseline then Run calibrationYou'll see: The pinned run carries a Baseline marker. The second run reads Pass rate 98% — 48/49 passed; under Test Runs the comparison shows 1 regression on R09 and Net score -2%.Screen snapshotcaliber · Tools › decide_refund › Test RunsSet as baselineRun calibration- Import the workflow asset. If you registered the tools under other names, replace
decide_refundandinitiate_refundin the file first. Validate dependencies checks that both tools resolve.Fill inNew workflow name refund-decisionYAML/JSON manifest Choose file: refund-decision.workflow.yamlClick Validate dependencies then Import as newYou'll see: Preflight passed, both tools resolved; then the editor opens on the new draft.Screen snapshotcaliber · Workflows › ImportValidate dependenciesImport as new Workflows › refund-decision › Run MonitorRun a case, then try to approve it yourself. In a second browser session sign in asapprover1, pick the same workspace, open the workflow, Run Monitor, select the run in Recent runs and approve. Back in the first session, Resume. The gate is the refund tool's own approval flag.Fill inRun input the R01 inputs, as in the Sandbox step Click Run then Approve then Approve then ResumeYou'll see: The run stops at Awaiting approval on noderefund. Your own Approve is refused (a second person must decide). After approver1 approves, Resume enables; after it the run is completed and the output showsrefund_status: initiated,amount_usd: 49.0.Screen snapshotcaliber · Workflows › refund-decision › Run MonitorRunApproveApproveResumeWorkflows › refund-decision › Run Monitor, then Audit LogStart two more runs: one with the R01 inputs that approver1 rejects, one with the R23 inputs (a cancelled order). Then open Audit Log.Click Run then RejectYou'll see: The rejected run is failed and its output holds no refund. The R23 run completed withdecision: denyand never asked for approval. Audit Log listsapprove_workflow_run_runtime_approvalandreject_workflow_run_runtime_approvalbyapprover1, andresume_workflow_runby the initiator.Screen snapshotcaliber · Workflows › refund-decision › Run Monitor, then Audit LogRunRejectTools › decide_refund › PublishOpendecide_refund, tab Publish, Version history, New version (admins). The wizard opens with the name fixed and the version1.1; change the description and step through to Register. In the new workspace open Fixtures, Load cases from file (refund-fixtures.jsonlagain), Save cases, then Hardening and Run calibration.Click Run calibrationYou'll see: Pass rate 100% — 49/49 passed on version 1.1. Publish lists1.0and1.1under Version history, and the Tools list shows both under the one name.Screen snapshotcaliber · Tools › decide_refund › PublishRun calibration
Assets (copy-paste)
The exact files this cookbook uses — copy each into the matching field. Source: docs-site/cookbooks/03-tool-hardening-contract-lab/assets/.
{
"name": "decide_refund",
"version": "1.0",
"description": "Deterministic refund policy: approve, deny or send to manual review, with a stable reason code.",
"module_path": "caliber.workflows.demo_tools",
"callable_name": "decide_refund",
"side_effect_level": "read",
"allow_in_preview": true,
"input_schema": {
"type": "object",
"required": ["order_state", "amount", "days_since_order"],
"properties": {
"order_id": {"type": "string", "description": "Carried for traceability; the policy does not read it."},
"account_id": {"type": "string", "description": "Carried for traceability; the policy does not read it."},
"order_state": {"type": "string", "description": "delivered, shipped or returned can be refunded; anything else is denied; empty fails closed."},
"amount": {"type": "number", "description": "Refund amount in USD."},
"days_since_order": {"type": "integer", "minimum": 0, "description": "Whole days since the order."},
"customer_tier": {"type": "string", "enum": ["standard", "plus", "premium"], "default": "standard"},
"refunds_last_90d": {"type": "integer", "minimum": 0, "default": 0, "description": "Refunds already issued to this account in the last 90 days."},
"risk_flags": {"type": "array", "items": {"type": "string"}, "description": "Fraud or risk signals. Omit or null when the risk lookup failed: the policy fails closed."}
}
},
"output_schema": {
"type": "object",
"required": ["decision", "reason_code", "requires_approval"],
"properties": {
"decision": {"type": "string", "enum": ["approve", "deny", "manual_review"]},
"reason_code": {"type": "string"},
"requires_approval": {"type": "boolean", "description": "True exactly when the decision is manual_review."}
}
}
}
{
"name": "initiate_refund",
"version": "1.0",
"description": "Issue the refund. A write: the registry requires approval for it, and the sandbox mocks it.",
"module_path": "caliber.workflows.demo_tools",
"callable_name": "initiate_refund",
"side_effect_level": "write",
"requires_approval": true,
"input_schema": {
"type": "object",
"required": ["order_id"],
"properties": {
"order_id": {"type": "string", "description": "Order to refund."},
"amount": {"type": "number", "description": "Refund amount in USD."}
}
},
"output_schema": {
"type": "object",
"properties": {
"order_id": {"type": "string"},
"refund_status": {"type": "string"},
"amount_usd": {"type": "number"}
}
}
}
{"id": "R01", "name": "small delivered order", "tags": ["golden", "approve"], "inputs": {"order_id": "ord_1007", "account_id": "acct_2013", "order_state": "delivered", "amount": 49.0, "days_since_order": 5, "customer_tier": "standard", "refunds_last_90d": 0, "risk_flags": []}, "expectations": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE", "requires_approval": false}}
{"id": "R02", "name": "shipped order inside the window", "tags": ["golden", "approve"], "inputs": {"order_id": "ord_1014", "account_id": "acct_2026", "order_state": "shipped", "amount": 25.0, "days_since_order": 12, "customer_tier": "standard", "refunds_last_90d": 0, "risk_flags": []}, "expectations": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE", "requires_approval": false}}
{"id": "R03", "name": "returned order, mid-size amount", "tags": ["golden", "approve"], "inputs": {"order_id": "ord_1021", "account_id": "acct_2039", "order_state": "returned", "amount": 120.0, "days_since_order": 20, "customer_tier": "standard", "refunds_last_90d": 1, "risk_flags": []}, "expectations": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE", "requires_approval": false}}
{"id": "R04", "name": "one day inside the window, just under the limit", "tags": ["golden", "approve"], "inputs": {"order_id": "ord_1028", "account_id": "acct_2052", "order_state": "delivered", "amount": 199.99, "days_since_order": 29, "customer_tier": "standard", "refunds_last_90d": 0, "risk_flags": []}, "expectations": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE", "requires_approval": false}}
{"id": "R05", "name": "window boundary: day 30 is still eligible", "tags": ["boundary", "window", "approve"], "inputs": {"order_id": "ord_1035", "account_id": "acct_2065", "order_state": "delivered", "amount": 49.0, "days_since_order": 30, "customer_tier": "standard", "refunds_last_90d": 0, "risk_flags": []}, "expectations": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE", "requires_approval": false}}
{"id": "R06", "name": "window boundary: day 31 is outside", "tags": ["boundary", "window", "deny"], "inputs": {"order_id": "ord_1042", "account_id": "acct_2078", "order_state": "delivered", "amount": 49.0, "days_since_order": 31, "customer_tier": "standard", "refunds_last_90d": 0, "risk_flags": []}, "expectations": {"decision": "deny", "reason_code": "OUTSIDE_WINDOW", "requires_approval": false}}
{"id": "R07", "name": "same-day refund", "tags": ["boundary", "window", "approve"], "inputs": {"order_id": "ord_1049", "account_id": "acct_2091", "order_state": "delivered", "amount": 49.0, "days_since_order": 0, "customer_tier": "standard", "refunds_last_90d": 0, "risk_flags": []}, "expectations": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE", "requires_approval": false}}
{"id": "R08", "name": "long past the window", "tags": ["golden", "deny"], "inputs": {"order_id": "ord_1056", "account_id": "acct_2104", "order_state": "delivered", "amount": 49.0, "days_since_order": 95, "customer_tier": "standard", "refunds_last_90d": 0, "risk_flags": []}, "expectations": {"decision": "deny", "reason_code": "OUTSIDE_WINDOW", "requires_approval": false}}
{"id": "R09", "name": "amount boundary: exactly 200.00", "tags": ["boundary", "amount", "approve"], "inputs": {"order_id": "ord_1063", "account_id": "acct_2117", "order_state": "delivered", "amount": 200.0, "days_since_order": 10, "customer_tier": "standard", "refunds_last_90d": 0, "risk_flags": []}, "expectations": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE", "requires_approval": false}}
{"id": "R10", "name": "amount boundary: 200.01 needs review", "tags": ["boundary", "amount", "manual_review"], "inputs": {"order_id": "ord_1070", "account_id": "acct_2130", "order_state": "delivered", "amount": 200.01, "days_since_order": 10, "customer_tier": "standard", "refunds_last_90d": 0, "risk_flags": []}, "expectations": {"decision": "manual_review", "reason_code": "AMOUNT_OVER_THRESHOLD", "requires_approval": true}}
{"id": "R11", "name": "large refund needs review", "tags": ["amount", "manual_review"], "inputs": {"order_id": "ord_1077", "account_id": "acct_2143", "order_state": "delivered", "amount": 250.0, "days_since_order": 10, "customer_tier": "standard", "refunds_last_90d": 0, "risk_flags": []}, "expectations": {"decision": "manual_review", "reason_code": "AMOUNT_OVER_THRESHOLD", "requires_approval": true}}
{"id": "R12", "name": "laptop-sized refund needs review", "tags": ["amount", "manual_review"], "inputs": {"order_id": "ord_1084", "account_id": "acct_2156", "order_state": "delivered", "amount": 1299.0, "days_since_order": 3, "customer_tier": "standard", "refunds_last_90d": 0, "risk_flags": []}, "expectations": {"decision": "manual_review", "reason_code": "AMOUNT_OVER_THRESHOLD", "requires_approval": true}}
{"id": "R13", "name": "plus tier: day 45 is eligible", "tags": ["tier", "plus", "boundary", "approve"], "inputs": {"order_id": "ord_1091", "account_id": "acct_2169", "order_state": "delivered", "amount": 100.0, "days_since_order": 45, "customer_tier": "plus", "refunds_last_90d": 0, "risk_flags": []}, "expectations": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE", "requires_approval": false}}
{"id": "R14", "name": "plus tier: day 46 is outside", "tags": ["tier", "plus", "boundary", "deny"], "inputs": {"order_id": "ord_1098", "account_id": "acct_2182", "order_state": "delivered", "amount": 100.0, "days_since_order": 46, "customer_tier": "plus", "refunds_last_90d": 0, "risk_flags": []}, "expectations": {"decision": "deny", "reason_code": "OUTSIDE_WINDOW", "requires_approval": false}}
{"id": "R15", "name": "plus tier: exactly 350.00", "tags": ["tier", "plus", "boundary", "approve"], "inputs": {"order_id": "ord_1105", "account_id": "acct_2195", "order_state": "delivered", "amount": 350.0, "days_since_order": 10, "customer_tier": "plus", "refunds_last_90d": 0, "risk_flags": []}, "expectations": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE", "requires_approval": false}}
{"id": "R16", "name": "plus tier: 350.01 needs review", "tags": ["tier", "plus", "boundary", "manual_review"], "inputs": {"order_id": "ord_1112", "account_id": "acct_2208", "order_state": "delivered", "amount": 350.01, "days_since_order": 10, "customer_tier": "plus", "refunds_last_90d": 0, "risk_flags": []}, "expectations": {"decision": "manual_review", "reason_code": "AMOUNT_OVER_THRESHOLD", "requires_approval": true}}
{"id": "R17", "name": "premium tier: day 60 is eligible", "tags": ["tier", "premium", "boundary", "approve"], "inputs": {"order_id": "ord_1119", "account_id": "acct_2221", "order_state": "delivered", "amount": 400.0, "days_since_order": 60, "customer_tier": "premium", "refunds_last_90d": 0, "risk_flags": []}, "expectations": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE", "requires_approval": false}}
{"id": "R18", "name": "premium tier: day 61 is outside", "tags": ["tier", "premium", "boundary", "deny"], "inputs": {"order_id": "ord_1126", "account_id": "acct_2234", "order_state": "delivered", "amount": 400.0, "days_since_order": 61, "customer_tier": "premium", "refunds_last_90d": 0, "risk_flags": []}, "expectations": {"decision": "deny", "reason_code": "OUTSIDE_WINDOW", "requires_approval": false}}
{"id": "R19", "name": "premium tier: exactly 500.00", "tags": ["tier", "premium", "boundary", "approve"], "inputs": {"order_id": "ord_1133", "account_id": "acct_2247", "order_state": "delivered", "amount": 500.0, "days_since_order": 10, "customer_tier": "premium", "refunds_last_90d": 0, "risk_flags": []}, "expectations": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE", "requires_approval": false}}
{"id": "R20", "name": "premium tier: 500.01 needs review", "tags": ["tier", "premium", "boundary", "manual_review"], "inputs": {"order_id": "ord_1140", "account_id": "acct_2260", "order_state": "delivered", "amount": 500.01, "days_since_order": 10, "customer_tier": "premium", "refunds_last_90d": 0, "risk_flags": []}, "expectations": {"decision": "manual_review", "reason_code": "AMOUNT_OVER_THRESHOLD", "requires_approval": true}}
{"id": "R21", "name": "day 40 is outside for a standard customer", "tags": ["tier", "standard", "deny"], "inputs": {"order_id": "ord_1147", "account_id": "acct_2273", "order_state": "delivered", "amount": 80.0, "days_since_order": 40, "customer_tier": "standard", "refunds_last_90d": 0, "risk_flags": []}, "expectations": {"decision": "deny", "reason_code": "OUTSIDE_WINDOW", "requires_approval": false}}
{"id": "R22", "name": "250.00 is inside the plus limit", "tags": ["tier", "plus", "approve"], "inputs": {"order_id": "ord_1154", "account_id": "acct_2286", "order_state": "delivered", "amount": 250.0, "days_since_order": 10, "customer_tier": "plus", "refunds_last_90d": 0, "risk_flags": []}, "expectations": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE", "requires_approval": false}}
{"id": "R23", "name": "cancelled order", "tags": ["golden", "state", "deny"], "inputs": {"order_id": "ord_1161", "account_id": "acct_2299", "order_state": "cancelled", "amount": 80.0, "days_since_order": 3, "customer_tier": "standard", "refunds_last_90d": 0, "risk_flags": []}, "expectations": {"decision": "deny", "reason_code": "NOT_REFUNDABLE_STATE", "requires_approval": false}}
{"id": "R24", "name": "order not shipped yet", "tags": ["state", "deny"], "inputs": {"order_id": "ord_1168", "account_id": "acct_2312", "order_state": "pending", "amount": 80.0, "days_since_order": 1, "customer_tier": "standard", "refunds_last_90d": 0, "risk_flags": []}, "expectations": {"decision": "deny", "reason_code": "NOT_REFUNDABLE_STATE", "requires_approval": false}}
{"id": "R25", "name": "order already refunded", "tags": ["state", "abuse", "deny"], "inputs": {"order_id": "ord_1175", "account_id": "acct_2325", "order_state": "refunded", "amount": 80.0, "days_since_order": 8, "customer_tier": "standard", "refunds_last_90d": 1, "risk_flags": []}, "expectations": {"decision": "deny", "reason_code": "NOT_REFUNDABLE_STATE", "requires_approval": false}}
{"id": "R26", "name": "state is trimmed and case-folded", "tags": ["edge", "state", "approve"], "inputs": {"order_id": "ord_1182", "account_id": "acct_2338", "order_state": " Delivered ", "amount": 49.0, "days_since_order": 5, "customer_tier": "standard", "refunds_last_90d": 0, "risk_flags": []}, "expectations": {"decision": "approve", "reason_code": "ELIGIBLE_AUTO_APPROVE", "requires_approval": false}}
{"id": "R27", "name": "order state unknown", "tags": ["fail_closed", "state", "manual_review"], "inputs": {"order_id": "ord_1189", "account_id": "acct_2351", "order_state": "", "amount": 49.0, "days_since_order": 5, "customer_tier": "standard", "refunds_last_90d": 0, "risk_flags": []}, "expectations": {"decision": "manual_review", "reason_code": "UNKNOWN_ORDER_STATE", "requires_approval": true}}
{"id": "R28", "name": "fraud flag on the account", "tags": ["abuse", "risk", "manual_review"], "inputs": {"order_id": "ord_1196", "account_id": "acct_2364", "order_state": "delivered", "amount": 49.0, "days_since_order": 4, "customer_tier": "standard", "refunds_last_90d": 0, "risk_flags": ["fraud_suspected"]}, "expectations": {"decision": "manual_review", "reason_code": "RISK_FLAG_PRESENT", "requires_approval": true}}
{"id": "R29", "name": "chargeback history", "tags": ["abuse", "risk", "manual_review"], "inputs": {"order_id": "ord_1203", "account_id": "acct_2377", "order_state": "delivered", "amount": 30.0, "days_since_order": 9, "customer_tier": "plus", "refunds_last_90d": 1, "risk_flags": ["chargeback_history"]}, "expectations": {"decision": "manual_review", "reason_code": "RISK_FLAG_PRESENT", "requires_approval": true}}
{"id": "R30", "name": "risk lookup failed (flags missing)", "tags": ["fail_closed", "risk", "manual_review"], "inputs": {"order_id": "ord_1210", "account_id": "acct_2390", "order_state": "delivered", "amount": 49.0, "days_since_order": 4, "customer_ti… truncated — open the file in the repo for the full content.
schema_version: 1
workflow_id: refund-decision
name: refund-decision
description: Decide a refund with the deterministic policy tool, then issue it only after a person approves.
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
policy:
id: policy
type: tool
tool_name: decide_refund
inputs:
input:
type: string
arguments:
type: structured
outputs:
text:
type: string
result:
type: structured
metadata:
type: structured
route:
id: route
type: router
inputs:
input:
type: string
outputs:
route:
type: string
branches:
- condition:
field: input
op: contains
value: '"decision": "deny"'
to: denied
- condition: null
to: refund
denied:
id: denied
type: output
inputs:
response:
type: string
refund_request:
id: refund_request
type: data_transform
operation: mapping
config:
fields:
order_id: order_id
amount: amount
inputs:
value:
type: structured
text:
type: string
outputs:
text:
type: string
result:
type: structured
valid:
type: boolean
metadata:
type: structured
refund:
id: refund
type: tool
tool_name: initiate_refund
inputs:
input:
type: string
arguments:
type: structured
outputs:
text:
type: string
result:
type: structured
metadata:
type: structured
issued:
id: issued
type: output
inputs:
response:
type: string
edges:
- id: e_start_policy
from: start
to: policy
map:
user_message: input
- id: e_start_request
from: start
to: refund_request
map:
user_message: text
- id: e_policy_route
from: policy
to: route
map:
text: input
- id: e_route_denied
from: route
to: denied
map:
route: response
- id: e_route_refund
from: route
to: refund
map:
route: input
- id: e_request_refund
from: refund_request
to: refund
map:
result: arguments
- id: e_refund_issued
from: refund
to: issued
map:
text: response
tools:
decide_refund:
registry_ref: tool.decide_refund.v1
version_constraint: ">=1,<2"
initiate_refund:
registry_ref: tool.initiate_refund.v1
version_constraint: ">=1,<2"
Evaluation & quality gates
| Quality gate | Target |
|---|---|
| Fixture pass rate | 1.0 over 49 cases (tool_fixture_pass_rate_min 1.0); recorded as a suite run and pinned as the baseline |
| Regression is visible | one wrong fixture (R09) scores 48/49 with exactly 1 regression against the baseline |
| Approval enforced | run waits at waiting_approval on refund; initiator 403; approver1 approves; refund fires only after Resume |
| Reject and deny paths | rejected run fails with approval_rejected and issues no refund; a denied decision finishes with no approval |
| Audit trail and roles | approver1 and the initiator named in the audit log; a viewer cannot run, calibrate or approve (403) |
Developer notes & gotchas
- Feature flag.
CALIBER_FEATURE_COOKBOOKS=trueonly opens the Cookbooks gallery starter (the last step); the rest of the lab needs no flag. No Aria, integrations or release-candidate flag. - Nothing is simulated. No model and no judge are involved, so the fake LLM provider is irrelevant here.
- Runtime settings. Needs runtime approvals, the workflow run queue, checkpointing and a worker (
scripts/cookbook-env.shturns them on). WithoutCALIBER_WORKFLOW_RUN_RUNTIME_APPROVALS_ENABLED=truea run does not pause.CALIBER_APPROVER_USERSmust listapprover1; leaveCALIBER_APPROVAL_ALLOW_SELF_APPROVALunset or the second-person rule does not bite. - Split of duties. Run, calibrate and Resume need
caliber.operator; deciding needscaliber.approver; only an admin registers a tool.approver1deliberately cannot Resume. - Tools are importable Python. A registered tool needs a
module_pathandcallable_namein the server's environment (the shippedcaliber.workflows.demo_toolsprovides both); there is no inline tool editor. SetCALIBER_REGISTERED_TOOL_MODULE_ALLOWLISTbeyond a trial. - Limits. The sandbox is a process boundary, not isolation (the child keeps network and filesystem access), and the memory limit is not enforced on macOS. The effect ledger covers webhook and API-request nodes, not registered tools, so make a payments tool idempotent itself.
- Calibration is slow. 49 cases take about 35 s synchronously, longer than the SDK default 30 s timeout. Run it with
sdk/caliber-sdk/examples/cookbooks/cookbook_03_policy_safe_decision_tool.py(python -m examples.cookbooks.cookbook_03_policy_safe_decision_tool) or the Playwright spece2e/cookbooks/labs/03-tool-hardening.spec.ts.