Skip to main content
KaireonAI can turn any persisted decision trace into a written explanation of why that decision was made, suitable for three different audiences:
  • Regulator — formal, compliance-grade prose with full factor detail. Writes to the AuditLog for DSAR / regulator use.
  • Agent — structured JSON for internal tooling (call-center consoles, troubleshooting UIs). Machine-readable.
  • Customer — one or two plain-language sentences you can show to the end customer in-product.
Narratives are generated on-demand against persisted decision traces. They never run during a /recommend call, so LLM latency or availability cannot affect live decisioning.

When to use each mode

Pick the mode that matches the downstream consumer. The same trace can be explained in all three modes and the results are cached independently.

How to enable it

LLM explanations are off by default for every tenant. Enable them in Settings > AI explanations, or via the API:
The flag is stored at tenantSettings.aiAnalyzerSettings.llmExplanationsEnabled. While disabled, the narrative endpoint returns 403:

End-to-end flow


PII redaction

Before any outbound LLM call, the input context runs through a PII-redaction pass:
  • Customer identifiers, email addresses, phone numbers, and free-text address fields are replaced with a [redacted] marker — matched by both field-name patterns (email/phone/ssn/dob/account_number/address/…) and value-shape heuristics (looks-like-email/phone/credit-card/SSN).
  • Only offer IDs, feature contributions, scores, policy reasons, and experiment assignment remain in the prompt.
  • The prompt explicitly notes “customer attributes redacted before LLM call; features reflected via topFactors on each offer” so the model does not invent missing attributes.
Redaction is best-effort defense-in-depth. The primary safeguard is the per-tenant opt-in. Do not disable the opt-in globally if your data-handling policies forbid sending any customer-derived data to external models.

Caching

The inputsHash component guarantees that if the underlying trace is re-scored or updated, the next request will generate a fresh narrative.

Audit log for regulator mode

Every successful mode = "regulator" call produces an audit-log row:
This makes regulator narratives discoverable during DSAR assembly and compliance review. Agent and customer narratives do not write audit rows.

Worked example — one trace, three views

Given a trace where offer_premium_card was selected with score 0.89, and offer_gold_plus came second with 0.71, the three modes produce:

Regulator

Agent

Customer


Exact SHAP for gradient_boosted models

The narrative endpoint produces prose explanations. For numerical, mathematically-grounded per-feature attributions on gradient_boosted models, KaireonAI also exposes an exact TreeSHAP endpoint:
Implementation: Lundberg, Erion, Lee 2018 (path-dependent TreeSHAP, Algorithm 2). Sum of shapValues plus baseline equals rawMargin exactly — the additivity invariant is verified per-call and reported as additivityResidual. Use this when:
  • A regulator demands a defensible per-feature breakdown for an audit (EU AI Act Art. 13 / 22, GDPR Art. 15).
  • You want to feed numerical attributions into a downstream dashboard, CSV export, or your own NLG layer.
  • The cheap path-heuristic explanations field on DecisionTrace.scoringResults is not exact enough — TreeSHAP is the consistent, axiomatically-grounded alternative.
Pair /shap with /narrative for regulator exports: the SHAP numbers are the math, the narrative is the prose. Both flow through the same per-tenant llmExplanationsEnabled opt-in. See the Decision Traces API for full request/response and audit-log details.

Rate limits

  • 20 requests / minute / tenant on the narrative endpoint.
  • 30 requests / minute / tenant on the SHAP endpoint.
  • Exceeding returns 429 TOO_MANY_REQUESTS. Retry after the bucket refills (the limiter is a sliding 60-second window).

In-app usage

Open any row in Studio > Decision Traces and click Explain. The dialog has tabs for all three modes, a regenerate button that sets noCache: true, and a metadata footer showing the model used, cache status, and token counts. See also: Decision Traces API | Security Model | AI Configuration