Agent
How a dispute turn runs: the graph, the policy that decides, the tools that act and the models.
The LLM understands, the rules decide, the tools act, verification confirms, a person closes.
Every view on this page is generated from the repository's code and contracts; the tests fail when one drifts.
Architecture
Agent on LangGraph Platform, customer tools as an MCP server, case state in Postgres.
- Request (HTTPS)
- Agent run and tools
- LLM call
- Data
- Delivery (CI/CD)
Request paths, in order
Static view (SVG) · the original drawing, which also shows the notifications and the S3 bucket.
Graph dispute_intake
15 nodes from START to END; a branch follows the policy engine, a tool read or the understood input, never the LLM's text.
- Branch on a policy engine decision
- Branch on a tool read or verification result
- Branch on a understood input
- Always next
Scroll sideways to see the whole graph; the table below lists the same nodes.
View as table (Graph nodes)
| # | Node | What it does | Next |
|---|---|---|---|
| 1 | identity | Reads the session, mode and arm from the run config the api injects; never from the customer's text. | greet |
| 2 | greet | First turn of a verified session: greets with the first name returned by get_customer_profile. | understand |
| 3 | understand | Language, injection flag, intent and slots with the B0 rules; below τ, arms S1/S2 ask the LLM, only in a verified session. | route |
| 4 | route | Spec 02 rules 1–4 through the policy engine's screen(); the engine, not the graph, picks the branch. | one of refuse (reauthenticate | deny) · connect (connect_person) · retrieve (screen() = none) · status (answer_status) · respond (no intent | other_language) |
| 5 | refuse | Deny or re-authenticate with no data and a way forward; the denial is recorded in policy_denials. | respond |
| 6 | connect | Registers a call request where the policy says, on the active case or a general one; never refused. | respond |
| 7 | retrieve | Finds the customer's transaction with search_transaction; for exactly one, reads its card, score, amount and any active case. | one of decide (no read_failed) · respond (read_failed) |
| 8 | decide | Runs the policy engine's decide() on tool facts only; the graph follows its result, never a rule of its own. | one of clarify (ask) · refuse (deny) · plan (no existing_case) · duplicate (existing_case) · connect (request_call) · respond (no request_call) |
| 9 | plan | States the numbered steps before acting; in the confirm state it asks before anything is done. | one of act (decision ≠ confirm) · respond (decision = confirm) |
| 10 | act | Runs only the writes decide() allowed: open_case first, then block_card when allowed, each with an idempotency key. | verify |
| 11 | verify | Reads each write's post-condition with its verifying tool: verified only with a V- id, otherwise not confirmed and escalated. | one of connect (request_call) · respond (row = reauthenticate | no request_call) |
| 12 | duplicate | The charge already has an active case: nothing is opened; the case and its stored deadlines come from get_case. | one of connect (request_call) · respond (no request_call) |
| 13 | clarify | One question, nothing done: up to the allowed number of option cards, or a request for the details. | respond |
| 14 | status | Re-reads cards or cases in this turn and answers with tool facts and the time of the reading. | respond |
| 15 | respond | Builds the reply, the receipt and the handoff card from templates and tool results; the grounding gate drops any fact no tool returned. | END |
Policies
The bank's fraud score picks a zone, the zone picks the action, and a case opens in every zone.
< 30
30–49
≥ 50
Also zone human, whatever the number
Amount gate
- Amount gateApproval modechanges
- Amount gateRegulatory clocknever changes
The amount only makes a money action's approval stricter; the legal deadline comes from the country table alone.
[data] score bands as of today, from the EDA (policies.yaml zones)
View as table (Policy ids)
| Policy id | What it decides | Guardrail |
|---|---|---|
| POL-SESSION | session expired or unverified → reauthenticate, before any other rule | G-SES-01 |
| POL-INJECTION | input flagged by the injection detector → deny | G-IN-01 |
| POL-CROSS-CUSTOMER | request targets another customer's data → deny | G-SES-02 |
| POL-HUMAN-REQUEST | intent human_request → connect_person with a call request; never refused. Full ruleintent human_request → connect_person with a call request; never refused. If it also reports a charge on one card transaction the customer did not reject, and the intent confidence is at least clarify.intent_confidence_min, the call goes on that transaction's case, which opens in review and is never blocked in that turn nor later while the call is open (D-029, D-042): in the high zone with person_requested, so the analyst decides the block after the call (amount_over_case_gate or supervised_mode when the block needs a person anyway); in the medium and human zones with the zone's handoff reason. After the mode check, check() denies a money action when call_requested is true; block_card reads it from the store, true until the analyst runs approve_block, resolve or close_case on the case; take, request_customer_info, mark_ambiguous and any other analyst action keep it (D-042, ADR 0024). Below that confidence, only the call | — |
| POL-PII | customer text with a card number, CVV or password → deny; nothing is stored and the agent asks not to send it | G-IN-04 |
| POL-STATUS | intent status_inquiry → answer_status; read-only, no case opened. Full ruleintent status_inquiry → answer_status; read-only, no case opened. If it also reports a charge and the customer has no active case, the turn goes on like a dispute (rules 4-9) | — |
| POL-OUT-OF-SCOPE | intent out_of_scope with no reported charge, or the identified transaction's product is not a card → deny (polite abstention) | G-IN-04 |
| POL-CLARIFY | intent confidence below clarify.intent_confidence_min, not exactly one candidate, or an out_of_scope intent that reports a charge → ask | G-IN-03 |
| POL-CLARIFY-EXHAUSTED | still unclear after clarify.max_clarification_turns → handoff (clarification_exhausted) | G-IN-03 |
| POL-SCORE-NULL | no fraud score → zone human; the case is still opened | — |
| POL-SCORE-LLM | score from the llm provider → zone human; an LLM score never decides a block | — |
| POL-SCORE-SOURCE | score from a source not in scoring.deciding_sources → zone human | — |
| POL-ZONE-HIGH | score in zones.high → block_and_open_case: the high zone blocks and verifies, unless the customer asked for a person in that turn: the case opens, the call is registered and the analyst decides the block after the call. Full rulescore in zones.high → block_and_open_case: the high zone blocks and verifies, unless the customer asked for a person in that turn: the case opens, the call is registered and the analyst decides the block after the call (D-029: connect_person, person_requested; held until the analyst approves the block, resolves or closes the case, D-042). When the block needs a person (amount tier, supervised mode): a handoff, or connect_person on a call request | — |
| POL-ZONE-MEDIUM | score in zones.medium → confirm with the customer, then open the case and hand off proposing approve_block; a call request opens the case without asking; never a block | — |
| POL-ZONE-HUMAN | score in zones.human → open the case and hand off (zone_human); no block | — |
| POL-ZONE-MISMATCH | open_case called with a zone other than the one computed from get_fraud_score for that transaction → deny; the zone comes from the score, never from the agent or the customer | G-IN-02 |
| POL-TICKET-ALWAYS | open_case runs with mode auto in every zone; registering is not a money decision | — |
| POL-AMOUNT-GATE | the amount tier made a money action's approval mode stricter; it never changes a deadline | G-TOOL-02 |
| POL-AMOUNT-UNKNOWN | no tier applies (country without a gate, amount missing, negative or not finite, other currency) → human_required | G-TOOL-02 |
| POL-SUPERVISED | supervised_mode forced human_required on a money action | G-TOOL-02 |
| POL-DEFAULT-DENY | no rule allows the action → deny | G-POL-01 |
| POL-CLOCK-UNKNOWN | no verified regulatory_clock entry for the country → case opened, no deadline, routed to a person | — |
| POL-QUEUE-TRANSITION | analyst transition not listed in case_queue.transitions → deny | G-POL-01 |
| POL-CLOSE-HUMAN | close requested by a non-human actor → deny | G-POL-01 |
| POL-REEVAL-WINDOW | re-evaluation requested after reevaluation.window_days → deny; the agent offers a call | G-POL-01 |
Customer tools
16 tools are the agent's only way to data; every write is read back before it counts as verified.
Read 10
Reads the customer's own data; changes nothing.
Act 2
The writes the graph's act node runs on a new dispute.
- Idempotent: takes an idempotency key, so a retry never runs twicePost-condition: verified by reading get_case
- Idempotent: takes an idempotency key, so a retry never runs twicePost-condition: verified by reading get_product_status
Follow up 3
Writes on a case that already exists.
- Idempotent: takes an idempotency key, so a retry never runs twicePost-condition: verified by reading get_case
- Idempotent: takes an idempotency key, so a retry never runs twicePost-condition: verified by reading get_case
- Idempotent: takes an idempotency key, so a retry never runs twicePost-condition: verified by reading get_case
Notify 1
Sends to a channel the customer confirmed.
- Idempotent: takes an idempotency key, so a retry never runs twicePost-condition: verified by reading list_my_notifications
View as table (Customer tools)
| Tool | Kind | Purpose | Verified with |
|---|---|---|---|
| get_customer_profile | Read | First name, language, country, display currency, confirmed channels | — |
| search_transaction | Read | Find the disputed charge (gold; plus demo_transactions in live) | — |
| get_fraud_score | Read | The bank's score with its source and version | — |
| compute_deadline | Read | Legal deadline for a new case, with source_url, verified_on and deadline_source_label in the session's language | — |
| open_case | Write | Open the case | get_case |
| block_card | Write | Block the card | get_product_status |
| get_product_status | Read | One card: type, last 4, status, read_at | — |
| list_my_cards | Read | The customer's cards with status | — |
| get_case | Read | Customer view of a case: status label, stored deadlines with source, deadline_source_label in the session's language and deadline_verified_on, visible timeline, taken_by_person, related_case_id, read_at | — |
| list_my_cases | Read | The customer's cases | — |
| add_case_info | Write | Customer adds information to an active case | get_case |
| request_call | Write | Customer asks a person to call | get_case |
| request_reevaluation | Write | Re-evaluate a resolved case (→ review) or open a related case for a closed one | get_case |
| convert_amount | Read | Amount in the display currency, with rate, source and date | — |
| send_case_summary | Notification | Send the receipt template to a confirmed channel | list_my_notifications |
| list_my_notifications | Read | Notifications with masked address and delivery status | — |
Guardrails
15 guardrails, each in code with a case in the evaluation set.
input
session
tools
policy
output
operations
View as table (Guardrails)
| Id | Layer | Guardrail | How | Cited by |
|---|---|---|---|---|
| G-IN-01 | input | direct and indirect prompt injection | customer text and tool outputs as delimited data; injection classifier (rules + LR) → human zone | POL-INJECTION |
| G-IN-02 | input | customer-invented data | amount/date/merchant only for searching; score, product and country come from gold | POL-ZONE-MISMATCH |
| G-IN-03 | input | language and ambiguity | ES/PT detection with a threshold; low confidence → ask, then human | POL-CLARIFY · POL-CLARIFY-EXHAUSTED |
| G-IN-04 | input | PII and out of scope | PAN/CVV/password regex → reject and ask not to send it; topic outside disputes → abstain | POL-PII · POL-OUT-OF-SCOPE |
| G-SES-01 | session | identity and scope | mock OTP TTL 15 min; customer_id only from the session; expired → no data | POL-SESSION |
| G-SES-02 | session | access to another customer | the tool filters by session; another customer's record answers NOT_FOUND, as an unknown id does, and is logged as a policy_denials row with POL-CROSS-CUSTOMER (D-052) | POL-CROSS-CUSTOMER |
| G-TOOL-01 | tools | allowlist and strict schemas | the agent only sees customer tools; Pydantic rejects unexpected arguments; rate limit per session | — |
| G-TOOL-02 | tools | controlled writes | approval mode per action; idempotency key; mandatory post-condition; credit never auto | POL-AMOUNT-GATE · POL-AMOUNT-UNKNOWN · POL-SUPERVISED |
| G-POL-01 | policy | default deny and logging | versioned policies.yaml; every denial is a row in policy_denials | POL-DEFAULT-DENY · POL-QUEUE-TRANSITION · POL-CLOSE-HUMAN · POL-REEVAL-WINDOW |
| G-OUT-01 | output | grounding | every number, date, ID or status in the answer exists in a tool result or in the policy; otherwise it is dropped and logged | — |
| G-OUT-02 | output | verified only | 'blocked' only when get_product_status == Blocked; 'case #' only when get_case returns the case_id with read_at | — |
| G-OUT-03 | output | leaks of other customers' data and secrets | output filter rejects IDs/amounts that are not from the session; never YAML or keys | — |
| G-OUT-04 | output | tone and abstention | no promises of money or deadlines the policy did not give; explicit abstention | — |
| G-OPS-01 | operations | budget and retries | token cap per conversation and per day, checked before calling; 2 retries; 800 ms timeout | — |
| G-OPS-02 | operations | immutable audit | every event with actor, trace_id and input hash; nothing is deleted | — |
Models and decision engines
Everything that understands, scores, decides, checks or advises, with its version.
Understand
Score
Decide
Check
Advise
View as table (Model inventory)
| Engine | Kind | Version | Role | Source |
|---|---|---|---|---|
| Policy engine | Rules | policies.yaml v2 | Decides every action, default deny; the LLM never reads or edits it. | contracts/policies.yaml · spec 02 |
| Regulatory clock | Rules (data table) | policies.yaml v2 | The legal deadline per country and product, each entry with source_url and verified_on; no entry → POL-CLOCK-UNKNOWN. | contracts/policies.yaml regulatory_clock · ADR 0019 |
| Fraud score | Bank's score (vendor) | dataset · gold-v1 | Places the case in a zone; only the deciding sources below can. | contracts/policies.yaml scoring |
| Intent classifier and injection rules (B0) | Rules | b0-v1 | Language, intent, slots and the injection flag in the understand node; the graph loads arm B0. | packages/nick_of_time/nlu/rules.py · spec 11 |
| Intent classifier (B1) | TF-IDF + logistic regression | b1-v1 | Learned arm measured by the spec 11 protocol; not loaded by the graph. | packages/nick_of_time/nlu/learned.py · spec 11 |
| LLM arm S1 | LLM · Amazon Bedrock | us.anthropic.claude-haiku-4-5-20251001-v1:0 | Intent and slots below τ in a verified session when the run's arm is S1; also the demo persona's opening message. | packages/nick_of_time/config · spec 15 |
| LLM arm S2 | LLM · Amazon Bedrock | us.anthropic.claude-sonnet-4-6 | The same step on the quality-ceiling model when the run's arm is S2. | packages/nick_of_time/config · spec 15 §4.3 |
| Judge | LLM · advisory | Claude Haiku 4.5 until the spec 15 benchmark picks the judge's model | A second opinion for the analyst on cases in review, every reason tied to evidence; never decides or changes state. | packages/nick_of_time/audit/judge.py · spec 18 · spec 15 Q4 |
| Outcome auditor | Deterministic checks | A1–A10 | Re-derives each run's decision, deadline, verified actions and facts from its records; findings go to audit_findings. | packages/nick_of_time/audit · spec 18 §4.1 |
View as table (Score providers)
| Provider | Version | Can place a zone | Note |
|---|---|---|---|
| dataset | gold-v1 | yes | reads transactions.fraud_score from gold for preset transactions; demo default |
| rules | rules-v0 | yes | heuristic: amount vs the customer's p95, channel, hour, different country; no training |
| model | model-v0 | yes | plan B: GBM/LR on transactions features against is_fraud, temporal held-out; only if Slack says the score is not available in real time |
| llm | llm-v0 | no, zone human | demo illustration only; NEVER decides a block (zone forced to human when it is the source) |
| synthetic | synthetic-v0 | yes | live mode only: the score generated with a labeled synthetic transaction in demo_transactions (ADR 0020); never in replay, eval or a pitch number; shown as [simulated] on the receipt, handoff and console |