AI CFO · process guide

How the finance agents work

A process document for every agent in the ai-cfo repo: what it reads, the steps it takes, the rules behind each decision, what it hands back, and where a person signs off.

20
agents
6
finance domains
10
use Claude to write
0
decisions made by the LLM

View the code on GitHub

shared pattern

Every agent runs the same loop

The agents are deterministic first. Rules and statistics make every decision, so the result is the same on every run and each outcome traces back to a rule. Claude only writes the human-facing text (an email, a memo, a status note). Without an API key the agent still runs and falls back to a template.

  1. 01

    Ingest

    sample_data() returns DataFrames: invoices, balances, bank lines. Synthetic by default, so it runs with zero setup.

  2. 02

    Decide

    Rules, thresholds and simple stats score, match and classify each record.

  3. 03

    Route

    Clean items go straight through; exceptions get a status and a next action.

  4. 04

    Narrate

    Optionally, Claude turns the structured result into prose for the owner.

  5. 05

    Hand back

    AgentResult: KPI summary, action table, narrative, extras such as journals or payment files.

order_to_cash_agent/

Order to Cash

From the credit decision on an order to cash landing against the invoice: who can buy, what gets billed, who gets chased, and how receipts and short-payments are cleared.

01

Credit Management Agent

Scores every customer, recommends a credit limit and decides whether pending orders ship.

rules + Claude

Process

  1. Compute days paid late = average days-to-pay minus terms (floored at 0, capped at 60).
  2. Score 0–100: 40 pts bureau score (300–850 scaled), 35 pts payment timeliness, 25 pts company size (log of revenue, capped at $500M).
  3. Bucket into risk class: below 45 High, 45–65 Medium, 65–80 Low, 80+ Minimal.
  4. Recommended limit = annual revenue × 0.2% × score / 100, rounded to the nearest $1k.
  5. Order decision: if open AR + pending order fits within the limit → Release; otherwise High risk → Hold for credit review, anything else → Release with approval.
Inputs
Customer master: annual revenue, average days-to-pay, payment terms, bureau score, current limit, open AR, pending order value.
Outputs
Scored customer table with recommended limit and order decision; count of holds and limit changes.
Human checkpoint
Credit manager approves holds and limit changes.
Claude writes
Credit review memo for the weakest customer.
Run
python -m order_to_cash_agent.credit.agent
02

e-Invoicing Portal Agent

Checks outgoing invoices against e-invoice rules and routes each to the right government or customer channel.

rules only

Process

  1. Check mandatory fields: buyer tax ID, PO number, line total, tax rate.
  2. Recompute tax (line total × rate) and flag a mismatch above 1 cent.
  3. Flag zero-rated non-US invoices that need an exemption code.
  4. Mark each invoice Ready or Blocked with its list of errors.
  5. Pick the channel by country: DE Peppol, FR Chorus Pro / PDP, IN GST IRP (IRN + QR), IT SdI, US customer AP portal or email PDF.
  6. Build a UBL-style JSON payload for Ready invoices.
Inputs
Outgoing invoices: customer, country, buyer tax ID, PO number, line total, tax rate, tax amount.
Outputs
Invoice list with status, channel and errors; ready vs blocked counts.
Human checkpoint
Billing fixes blocked invoices before resubmission.
Run
python -m order_to_cash_agent.einvoicing.agent
03

Collections Management Agent

Turns open AR into a risk-ranked daily worklist and drafts the outreach.

rules + Claude

Process

  1. Keep open invoices and compute days past due.
  2. Roll up per customer: open AR, past-due amount, max days past due, number of open invoices.
  3. Risk score = 0.5 × past-due share (vs worst customer) + 0.4 × max days past due (normalised) + 0.1 × invoice count (normalised).
  4. Pick a strategy from max days past due: over 60 escalate (call + credit-hold review), over 30 collector call, over 0 friendly email, otherwise pre-due courtesy note.
  5. Sort the worklist by risk score and draft a dunning email for the top customer.
Inputs
Open invoices: customer, due date, open amount.
Outputs
Collector worklist with risk score and strategy; total open AR, total past due, % past due.
Human checkpoint
Collector reviews and sends the email, works the list.
Claude writes
Dunning email for the highest-risk customer.
Run
python -m order_to_cash_agent.collections.agent
04

Cash Application Agent

Matches incoming receipts to open invoices with a cascade of increasingly fuzzy rules.

rules only

Process

  1. Reference match: if the remittance cites invoice IDs, apply to those invoices.
  2. Otherwise identify the customer by fuzzy match of payer name to the customer list.
  3. Amount match: look for one, two or three of that customer's open invoices that sum to the receipt (within $0.01).
  4. Remove matched invoices from the open pool so they can't be applied twice.
  5. Anything still unmatched is a short-pay or unknown payment → exception queue for Deductions.
Inputs
Open invoices; bank receipts with payer name, amount and remittance reference.
Outputs
Receipt-to-invoice matches with method and confidence; auto-match rate; exception count.
Human checkpoint
Cash app analyst works the exception queue.
Run
python -m order_to_cash_agent.cash_application.agent
05

Deductions Management Agent

Codes customer short-payments, checks them against backup, and decides to clear, dispute or write off.

rules + Claude

Process

  1. Classify the memo by keyword into promo, pricing, shortage, damage, freight, compliance or unknown.
  2. Promo: valid if a promo agreement exists, otherwise invalid.
  3. Shortage or damage: invalid if the POD was signed clean, otherwise valid.
  4. Compliance fines (late delivery, ASN, labels): dispute and request retailer backup.
  5. Anything else under $100: auto write-off. Otherwise route to an analyst for research.
  6. Map each decision to the next action: clear against accrual, send dispute with POD/contract, request backup, route, or write off.
Inputs
Deductions with memo text and amount; whether a promo agreement exists; whether proof of delivery was signed clean.
Outputs
Coded deductions with decision and next action; count and value by decision.
Human checkpoint
Analyst researches open items and approves disputes.
Claude writes
Dispute letter for an invalid deduction, citing the evidence.
Run
python -m order_to_cash_agent.deductions.agent

accounts_payable_agent/

Accounts Payable

From a supplier joining, to their invoice being matched, to the cash leaving: onboarding risk, three-way match and an optimised payment run.

06

Supplier Portal Agent

Answers suppliers' payment-status questions and screens new suppliers before they're set up.

rules + Claude

Process

  1. Pull the invoice number out of each supplier question and look up its status and payment date.
  2. Answer the supplier in one or two sentences.
  3. Screen onboarding: sanctions-list hit → Block.
  4. Bank details changed in the last 30 days and the email domain doesn't match → Hold for call-back verification.
  5. Missing tax form → Hold. No flags → Approve.
Inputs
AP ledger (invoice, status, pay date); supplier questions; onboarding records (tax form, recent bank change, email domain match).
Outputs
Answered queries; onboarding decisions with risk flags.
Human checkpoint
AP verifies held suppliers by phone before approval.
Claude writes
Help-desk answers to supplier questions.
Run
python -m accounts_payable_agent.supplier_portal.agent
07

AP Automation Agent

Captures invoice fields, runs a three-way match and codes the GL so clean invoices post untouched.

rules + Claude

Process

  1. Extract vendor, invoice number, PO, quantity and unit price from invoice text (regex stand-in for OCR or LLM extraction).
  2. Join each invoice to its PO and goods receipt.
  3. Repeat vendor + invoice number → Reject as duplicate.
  4. Price more than 2% off the PO → Exception: price variance.
  5. Billed quantity above quantity received → Exception: qty > received.
  6. Otherwise Matched → post, with the GL account taken from the vendor's default coding.
Inputs
Invoice text; purchase orders (quantity, unit price); goods receipts (quantity received).
Outputs
Invoice table with GL account, price variance and status; touchless %, exceptions, duplicates.
Human checkpoint
Buyer resolves price and quantity exceptions.
Claude writes
Exception summary for the AP manager with next steps.
Run
python -m accounts_payable_agent.ap_automation.agent
08

Vendor Payments Agent

Builds the payment run: takes discounts that beat the cost of cash, picks the rail, and stops at available cash.

rules only

Process

  1. Annualise each discount: rate / (1 − rate) × 365 / days paid early.
  2. Capture the discount if it beats the 8% cost of cash and the discount date hasn't passed.
  3. Include invoices due within the next 7 days; defer everything else.
  4. Choose the rail: international → wire, card-accepting vendors → virtual card (rebate), otherwise ACH.
  5. Order discounts first (highest return first), then due items, and add to the run until available cash runs out.
Inputs
Approved invoices with due date and early-pay discount terms; cash available for the run.
Outputs
Payment run with amount, reason, rail and in-run flag; discounts captured, rail mix, items deferred for cash.
Human checkpoint
Treasury or the controller approves the run before release.
Run
python -m accounts_payable_agent.vendor_payments.agent

close_reconciliation_agent/

Close & Reconciliation

Month-end orchestration plus the reconciliations that feed it, from daily revenue to balance-sheet sign-off and intercompany.

09

Daily Revenue Reconciliation Agent

Ties orders to processor settlements to bank deposits every day, per processor.

rules only

Process

  1. Expected net = gross orders × (1 − contracted fee rate).
  2. Fee variance = settlement net − expected net; deposit gap = bank deposit − settlement net.
  3. No settlement file → Missing settlement file.
  4. No deposit → Deposit not received (likely timing).
  5. Fee variance above $50 → Fee / chargeback variance. Otherwise Matched.
Inputs
Per day and processor: gross orders, contracted fee rate, settlement net, bank deposit.
Outputs
Exception lines only; match rate, gross revenue, unexplained fee variance.
Human checkpoint
Revenue accountant chases missing files and disputes fees.
Run
python -m close_reconciliation_agent.daily_revenue_reconciliation.agent
10

Balance Sheet Reconciliation Agent

Compares the GL to supporting balances, explains variances and auto-certifies low-risk accounts.

rules + Claude

Process

  1. Variance = supporting balance − GL balance.
  2. Subtract known reconciling items to get the unexplained variance.
  3. Risk-rate accounts: cash, intercompany and deferred revenue High; balances over $1M Medium; else Low.
  4. Zero variance and not High → Auto-certified. Zero variance and High → reviewer sign-off.
  5. Unexplained under $1,000 → reviewer sign-off. $1,000 or more → Exception: investigate.
Inputs
GL balance and supporting balance (sub-ledger, bank, external) per account; open reconciling items.
Outputs
Reconciliation table with explained/unexplained variance, risk and status.
Human checkpoint
Reviewer signs off; accountant books adjusting entries for exceptions.
Claude writes
Explanation of exceptions and suggested adjusting entries.
Run
python -m close_reconciliation_agent.balance_sheet_reconciliation.agent
11

Intercompany Management Agent

Matches intercompany balances between entity pairs in USD and proposes monthly net settlement.

rules only

Process

  1. Translate every balance to USD.
  2. Pair each creditor's AR with the debtor's AP for the same entity pair.
  3. Status: missing AP booking, missing AR booking, matched (difference under $100) or amount mismatch.
  4. Net each entity's receivables against its payables.
  5. Positive net → receive from the netting centre; negative → pay the netting centre.
Inputs
Intercompany AR and AP by entity pair in local currency.
Outputs
Pair-level match table; netting positions; gross vs net settlement and % reduction.
Human checkpoint
Entity accountants fix unmatched bookings before eliminations.
Run
python -m close_reconciliation_agent.intercompany.agent
12

Financial Close Agent

Runs the close checklist as a dependency graph, finds the critical path, and books accruals.

rules + Claude

Process

  1. Compute each task's planned finish day from its dependencies and duration.
  2. Flag tasks as late if their planned finish has passed and they aren't done.
  3. List what is blocking each task (unfinished dependencies).
  4. Walk back from the last-finishing task to get the critical path and projected close day.
  5. Turn GRNI into an accrual journal: debit the expense GL, credit 2100 Accrued Liabilities.
Inputs
Close tasks with dependencies, duration and status; received-not-invoiced (GRNI) items; current close day.
Outputs
Task table with planned finish, blockers and late flag; critical path; accrual journal.
Human checkpoint
Controller unblocks tasks and approves the accrual journal.
Claude writes
Close status update for the Controller.
Run
python -m close_reconciliation_agent.financial_close.agent

consolidation_reporting_agent/

Consolidation & Reporting

Rolls entity books into one set of group numbers, then explains them.

13

Financial Consolidation Agent

Translates, eliminates and consolidates entity trial balances into a group TB that balances.

rules only

Process

  1. Translate balance-sheet accounts at the closing rate and P&L accounts at the average rate.
  2. Plug each entity's translation difference to CTA in OCI.
  3. Aggregate all entities in USD.
  4. Eliminate IC receivable / payable and IC revenue / COGS; send any elimination difference to P&L.
  5. Compute non-controlling interest on partly owned entities (IN01, 80% owned).
  6. Check the consolidated TB balances to zero.
Inputs
Trial balances per entity in local currency; closing and average FX rates; ownership %.
Outputs
Consolidated TB by entity with eliminations; IC difference, NCI share, consolidated net income.
Human checkpoint
Group reporting reviews eliminations and the IC difference.
Run
python -m consolidation_reporting_agent.financial_consolidation.agent
14

Financial Reporting Agent

Builds the monthly P&L flux report and drafts commentary without inventing causes.

rules + Claude

Process

  1. Compute variance to budget (amount and %) and to prior month.
  2. Flag a line only if both thresholds break: more than 3% and more than $50k.
  3. Mark favourable or unfavourable.
  4. Draft commentary for flagged lines; unknown drivers are written as 'driver TBC with owner'.
Inputs
P&L lines: actual, budget, prior month.
Outputs
Flux table with flags; revenue vs budget %, EBITDA margin; draft commentary.
Human checkpoint
Line owners confirm drivers before the CFO pack goes out.
Claude writes
CFO-pack commentary, told not to invent business drivers.
Run
python -m consolidation_reporting_agent.financial_reporting.agent

treasury_risk_agent/

Treasury & Risk

Where the cash is today, where it will be in 13 weeks, and whether today's outgoing payments are safe to release.

15

Cash Management Agent

Builds the daily global cash position and proposes sweeps, top-ups and investment of idle cash.

rules + Claude

Process

  1. Translate balances to USD for the global position.
  2. Within each entity and currency, sweep any excess over target from non-header accounts to the header account.
  3. Fund any account below its minimum from the header account.
  4. Idle cash = global cash − buffer − sum of account targets.
  5. Propose idle cash for money-market fund or T-bill placement.
Inputs
Bank accounts per entity with balance, target and minimum (minimum = 50% of target); header account flag; group buffer ($5M).
Outputs
Proposed transfers; cash by entity; idle cash to invest.
Human checkpoint
Treasurer approves transfers and investments.
Claude writes
Morning cash brief for the Treasurer.
Run
python -m treasury_risk_agent.cash_management.agent
16

Cash Forecasting Agent

Forecasts 13 weeks of cash by flow category and reports its own back-tested accuracy.

rules + Claude

Process

  1. Per category, forecast = the same week one season (26 weeks) earlier × a trend factor.
  2. Trend = mean of the last 26 weeks / prior 26, clipped to 0.8–1.2 (1.0 if the sign flipped).
  3. Back-test: hold out the last 13 weeks, forecast them, report MAPE per category.
  4. Forecast the next 13 weeks, sum net flow, roll closing cash from the opening balance.
  5. Find the low point (week and balance).
Inputs
52 weeks of cash flows by category (AR receipts, other inflows, payroll, AP, rent, tax); opening cash.
Outputs
13-week forecast by category with net flow and closing cash; low point; back-test MAPE.
Human checkpoint
Treasury reviews the low point and any category with poor accuracy.
Claude writes
Four-bullet CFO summary of the forecast.
Run
python -m treasury_risk_agent.cash_forecasting.agent
17

Treasury Payments Agent

Screens every outgoing payment before release and routes it to the right approvers.

rules only

Process

  1. Score each payment against the beneficiary's history (z-score of log amount).
  2. Watchlist hit → BLOCK.
  3. Same beneficiary and amount twice in the batch → HOLD: duplicate.
  4. Bank details changed → HOLD for call-back. |z| above 3 → HOLD: amount anomaly. Otherwise Clear.
  5. Approvers: up to $50k analyst; up to $500k analyst + manager; above that manager + CFO.
  6. Generate an ISO 20022 pain.001-style file for cleared payments.
Inputs
Payment batch (beneficiary, amount, bank-detail change flag); payment history per beneficiary; watchlist.
Outputs
Screened batch with anomaly score, decision and approvers; release value; pain.001 payload.
Human checkpoint
Named approvers release; holds are investigated first.
Run
python -m treasury_risk_agent.treasury_payments.agent

b2b_payments_agent/

B2B Payments

Accepting customer payments at the lowest cost: routing, surcharging and interchange qualification.

18

Payment Gateway Agent

Routes each customer payment to the cheapest processor or rail that is likely to succeed.

rules only

Process

  1. Keep routes that support the currency and amount and match the customer's preferred method.
  2. Drop ACH for urgent payments.
  3. Pick the route with the lowest expected cost per successful payment = fee / auth rate (fallback: wire).
  4. Set a retry plan from the decline code: insufficient funds → retry in 3 days; issuer unavailable → retry in 1h on another processor; do not honor → don't retry, ask for ACH.
Inputs
Payments with amount, currency, preferred method, urgency, last decline code; processor fee, auth-rate and limit table.
Outputs
Route, method, fee and retry plan per payment; savings vs sending everything by card.
Human checkpoint
Payments ops reviews the routing rules and retries.
Run
python -m b2b_payments_agent.payment_gateway.agent
19

Surcharge Management Agent

Decides whether a card payment can be surcharged, by how much, and writes the disclosure.

rules only

Process

  1. Debit or prepaid card → no surcharge.
  2. State where surcharging is prohibited → no surcharge (the state list is illustrative).
  3. Otherwise surcharge = the lower of the 3% network cap and the actual cost of acceptance.
  4. Generate customer-facing disclosure text.
Inputs
Card payments with amount, card type, US state and cost of acceptance.
Outputs
Surcharge % and amount with reason; fees incurred vs recovered.
Human checkpoint
Legal confirms current state rules before go-live.
Run
python -m b2b_payments_agent.surcharge_management.agent
20

Interchange Fee Optimizer Agent

Adds Level 2/3 data to commercial-card transactions so they qualify for lower interchange.

rules only

Process

  1. Classify current data level: tax + PO + line items = L3; tax + PO = L2; else L1.
  2. Where the invoice is available, enrich the missing fields to reach L3.
  3. Price before and after at illustrative rates (L1 2.70%, L2 2.25%, L3 1.90%).
Inputs
Card transactions with flags for tax amount, PO and line items; whether the matching invoice is available.
Outputs
Level before and after, fees and saving per transaction; total saving in $ and bps.
Human checkpoint
Payments ops reviews the enrichment mapping.
Run
python -m b2b_payments_agent.interchange_fee_optimizer.agent

running it

Try an agent

ai-cfo
# from the repo root
pip install -r requirements.txt

# run one agent on synthetic data, offline (template text, no API call)
AGENT_OFFLINE=1 python -m order_to_cash_agent.collections.agent

# let Claude write the narrative
export ANTHROPIC_API_KEY=…
python -m treasury_risk_agent.cash_forecasting.agent

These are proofs of concept on synthetic data. Fee rates, FX rates, thresholds and the surcharge state list are illustrative. Confirm them, and swap in real ERP and bank feeds, before relying on any output.

← Back to AI