Skip to main content

Quick start

Built-in tool calls (NPV, loan, AML, options) return ToolCallStatus.COMPUTED: the result was computed deterministically but not verified against an LLM claim. Only tools with a custom verification_fn that compare against an LLM output can return ToolCallStatus.APPROVED.

Fail-closed default

Since v2.1.0: Tools registered without a verification_fn are rejected by default. This enforces the QWED principle: “Verification decides IF.”

Tool call statuses

ToolCallStatus.MODIFIED exists in the enum for custom verification_fn implementations, but no built-in path returns it.

Tool call flow

  1. LLM emits tool call with arguments
  2. QWED intercepts and checks for a registered verification_fn
  3. If no verification_fn → REJECTED (fail-closed, audited)
  4. If verification_fn exists → execute with error boundary
  5. Returns the result; built-in tools and missing-verification_fn rejections carry a receipt. A custom tool’s result carries one only if its verification_fn creates it

Available built-in tools

All built-in tools return COMPUTED status because they perform deterministic calculations without comparing against an LLM claim.

AML country consistency

The check_aml_compliance tool delegates to ComplianceGuard.high_risk_countries for its high-risk country list, so the tool and the guard use the same list.

Black-Scholes input validation

The price_option tool rejects non-positive inputs for spot_price, strike_price, time_to_expiry, and volatility before computing, preventing ZeroDivisionError at the math boundary.

Black-Scholes single source of truth

price_option delegates to DerivativesGuard.verify_black_scholes(), the same mpmath (30 decimal places) implementation used by direct guard calls, so pricing through the OpenResponses integration and pricing through DerivativesGuard produce identical outputs for identical inputs.
Previously, the integration shipped its own IEEE-754 float-based Black-Scholes routine (math.log/exp/sqrt/erf). Same formula, two precision paths: the same input could give two different outputs depending on the call site. The duplicate has been removed. The tool result now reports the computed price and delta Greek straight from the guard’s quantized Decimal output:

Item wrapper (streaming)

Format results for streaming compatibility:

COMPUTED item structure

APPROVED item structure


OpenAI integration


Custom tools

Register your own verified tools. A verification_fn is required: tools without one are rejected.
If your verification_fn raises an exception, it will be caught by the error boundary and return ToolCallStatus.ERROR with a descriptive message, so the agent loop does not crash.

Audit trail

Built-in tool calls and rejections for a missing verification_fn produce receipts in qwed.audit_log automatically. Results returned by a custom verification_fn are passed through as-is: they carry a receipt only if your function creates one, and they appear in qwed.audit_log only if your function also logs that receipt.
Rejected tool calls (missing verification_fn) are audited with a receipt containing the rejection reason.
These outcomes return no receipt and are not written to audit_log: an unknown tool name, invalid JSON arguments, a custom verification_fn that raises, and the price_option rejection for non-positive inputs. A custom verification_fn can return a receipt without adding it to audit_log; create and log the receipt yourself when you need both. Log result.status and result.error yourself if you need a complete trail.