Skip to content
← Blog

How to build an agent that reconciles two spreadsheets

Map invoice and payout columns, match exact references in a sandbox, and export an Excel workbook of missing, duplicate, and mismatched rows.

floo team

TL;DR

Two spreadsheets describe the same payments using different column names. Let the agent identify the columns, then use an exact matching rule to produce an Excel workbook a person can review.

  • Give the model the headers and keep transaction rows out of the prompt.
  • Use text references and integer cents in a single currency.
  • Put missing references, duplicates and amount differences in an exceptions sheet.

Decide what counts as a match

An invoice matches when there is exactly one row on each side with the same reference and amount. Reference 001 is text. Converting it to the number 1 could merge identifiers the source system keeps separate. Amounts arrive in cents, so $90.00 and $85.00 compare as 9000 and 8500.

The sample deliberately has a clean match, an underpayment, an invoice with no payout, a duplicate invoice, and a payout with no invoice. A duplicate needs review even when both invoice rows have the same amount. Silently keeping the last one would make an ambiguous match look certain.

Run the sample and open the workbook

Use Python 3.10 or later, a signed-in Claude Code CLI, and a floo account with sandbox credits. Sign in with the floo CLI or set FLOO_API_KEY in your shell. Run these commands in an empty directory.

python3 -m venv .venv
. .venv/bin/activate
python -m pip install floo-sandbox==0.2.0 openpyxl==3.1.5
export FLOO_API_KEY="${FLOO_API_KEY:-$(floo auth token)}"
base=https://getfloo.com/examples/sandbox-agents
curl -fsSLO "$base/agent_tools.py"
curl -fsSLO "$base/reconcile_agent.py"
python reconcile_agent.py

Open exceptions.xlsx and select the Exceptions sheet. The embedded sample produced these rows. Brackets keep every amount associated with a reference, including repeated values.

ReferenceReasonInvoice amounts (cents)Payout amounts (cents)
002amount mismatch[9000][8500]
003invoice only[4000][]
004duplicate reference[1000, 1000][]
005payout only[][2000]

Reference 001 matched at 12500 cents and therefore has no exception row. That matched case is worth keeping in a fixture: a program that flags everything for review can look thorough without reconciling anything. Reconciliation agent source · Host helper

Give the model the smallest judgment call

The invoice headers are Invoice ID and Invoice cents. The payout headers are Reference and Paid cents. The model sees each header list and returns the names of the two columns. The host rejects missing names, repeated headers, or a mapping that chooses one column twice. Check the mapping yourself when onboarding an unfamiliar export, especially one with separate gross, fee, and net columns.

The host reads the active sheet, validates the selected values, and sends reference-and-cents pairs to the sandbox. Inside it, Python groups rows by reference and walks the union of keys. The union matters: iterating over invoices alone would lose payout 005 entirely. Duplicate detection runs before amount comparison. The host writes the returned exceptions to Excel as text cells.

Try your own two files

Keep the input workbooks in the same directory and run:

python reconcile_agent.py invoices.xlsx payouts.xlsx

Use one active sheet per input, with distinct headers in row one. Store the reference as text and amounts as integer cents in a single currency. If Excel already stripped leading zeroes, recover the original export before matching. A formula or decimal amount will stop the sample so you can choose how to normalize it.

Change payout 002 from 8500 to 9000 cents and rerun. Its exception should disappear while the missing and duplicate cases remain. The script overwrites exceptions.xlsx in the working directory. It makes no changes to either input workbook or to a payment system.

Get your app live.

read https://getfloo.com/agents.md and set me up on floo

Get an API key
Usage-based pricing. See plans →