Case study
Tariff Exposure Agent
Classifies an import against the U.S. Harmonized Tariff Schedule and calculates duties, fees, effective tariff rate and landed cost, with a source citation for each output.
- Role
- Solo project: design and engineering
- Timeline
- 2026 – present
- Stack
- Python, LangGraph, Decimal arithmetic
- Repository
- Private. Walkthrough available on request.
- ~4,000Pages of U.S. Harmonized Tariff Schedule rules the tool classifies against
- 44Unit tests covering the duty, fee and landed-cost calculations
- 3Scenarios modeled: pass-through, margin absorption, re-sourcing
- 0Dollar figures computed by the language model
01 / The problem
What will this import actually cost?
When trade policy changes, a business that imports goods has to answer a practical question quickly: what will this product now cost to land, and what should we do about it? Answering it means finding the right classification in roughly 4,000 pages of U.S. Harmonized Tariff Schedule rules, then working out duties, fees, the effective tariff rate and the landed cost.
The first half of that is a reading and judgment problem. The second half is arithmetic where a wrong digit costs real money. Those are different kinds of work, and treating them as the same kind is where tools like this go wrong.
02 / The design decision
Let the model read. Never let it count.
A language model is good at judgment and unreliable at arithmetic. So the tool splits the job in two. The model handles classification, reading the tariff schedule and proposing where a product belongs. Ordinary Python, using exact Decimal arithmetic rather than floating point, handles every duty, fee, rate and total.
The rule I held to was that every number must trace back to a formula I can inspect. The calculation layer is covered by 44 unit tests, and each output carries a source citation, so a result can be checked against the schedule itself rather than taken on trust.
- 01
Product description
What is being imported, and from where.
- 02AI model
Classification
The model reads the tariff schedule and proposes a classification, with its citation.
- 03Deterministic
Duties and fees
Exact Decimal arithmetic. Covered by unit tests.
- 04Deterministic
Effective rate and landed cost
Derived from the step before, never estimated.
- 05Deterministic
Scenarios
Pass-through, margin absorption and re-sourcing compared side by side.
03 / The decision it supports
Three ways to respond to a tariff
Knowing the landed cost is only useful if it informs a choice. The tool models the three responses a business realistically has:
- Pass-through. Raise the price and let the customer carry the tariff.
- Margin absorption. Hold the price and accept a thinner margin.
- Re-sourcing. Move supply to a country with a lower rate, and weigh what that does to cost.
Comparing them side by side turns a tariff change from a compliance question into a profitability and sourcing decision.
04 / What I took from it
Where AI belongs in a financial tool
The most useful thing this project taught me was not about tariffs. It was about where to draw the line around a language model. The interesting design question is rarely whether a model can do a task. It is whether you would be comfortable defending its output to someone whose money depends on it.
I made the same choice again in CostProof, where the model writes the explanation and a separate guard checks every figure in its text against the numbers it was given.