Runs locally · CIIndependent · AI agents2026

Wakeel وكيل

A card-dispute AI agent for a Saudi bank, built the way a regulated client would need it · the bank and its data are fictional

22 / 22correct decisions on live models, with 0 wrong refunds and 0 unsafe outcomes from 13 attacks
01The problem

Why it exists

Card disputes are repetitive, full of personal data, and a bank cannot let a model move money on its own. Wakeel takes a customer’s dispute in Arabic or English, finds the policy that applies, checks the ledger and proposes a refund that a bank employee approves. Safety is structural: the model classifies, code decides the order of steps, the agent can only propose, and personal data is masked before any model sees it. Sahm Bank, its customers and its policies are fictional, and no real money moves.

02The system

What I built

IntakePII masking, injection screen
Supervisorcode decides the steps
Policy agenthybrid RAG, cited
Ops agentledger tools, proposes
Human approvalidempotent refund
  1. LangGraph orchestration: a supervisor with a policy agent and an operations agent. Code decides the order of steps, so the human approval (a LangGraph interrupt) can never be skipped
  2. Hybrid RAG over Arabic and English policies: heading-aware chunks with stable citation ids, Arabic-normalised BM25 plus dense vectors fused by reciprocal rank, model reranking, and query rewriting for dialect
  3. Tool calling against a real double-entry ledger (Daftar) with idempotent refunds, and the same four tools served over MCP
  4. A verifier that recomputes the facts from the ledger and asks a second model; from 1,000 SAR two different reviewers must approve
  5. PII masking (cards, Saudi ID and Iqama, IBAN, phone) before any model or log, a prompt-injection screen, an output guard, and every number in a reply checked against the facts
  6. Production pieces: Postgres state and a job queue, Prometheus metrics, OpenTelemetry traces, a hash-chained audit log, Docker and Kubernetes verified in CI on every push
  7. November 2026 hardening: obfuscation-proof injection screen, a mandatory-classifier mode that requires two reviewers when Prompt Guard is down, and repeat-dispute detection per merchant
  8. Extracted the shared patterns of all my agents into agent-core: one tested package for retrieval, guardrails, approvals, a residency-aware model chain, tracing, memory, evaluation and a weekly red team
03The result

What it achieved

On live models (Groq gpt-oss-120b, 12 October 2026): 22 of 22 agent decisions correct, including 6 of 6 hard cases, 0 wrong refunds, 0 unsafe outcomes from 13 attacks, and the verifier judged 10 of 10 planted proposals correctly. Offline in CI: 16 of 16 decisions and 0 unsafe outcomes from 12 prompt-injection attacks; a wrong refund fails the build. Under load (rules mode): 169 cases a second at p95 178 ms, and 1,693 proposals for the same duplicate paid it once. A generated red team showed patterns alone catch 386 of 400 generated attacks but only 2 of 15 new ones, which is why the classifier layer and human approval are not optional.

Published limits

The limits are published: the bank is fictional, the free-tier Gemini runs were cut short by quota, and going live needs the bank’s own systems, models hosted in the Kingdom and formal approvals.

Stack

PythonLangGraphHybrid RAGTool callingMCPPII maskingOpenTelemetryDocker · Kubernetes

Timeline

2026

My role

Product + engineering + evaluation