Dev Tools

Run tariff research with LlamaIndex

In this example, we built an agent that uses Nimble Web Search Agents to search the web for tariff schedules, duty overlays, and product classifications, returning every fact with citations and a shelf-life-aware refresh.

Quick Start

Inputs

  1. A question in plain words A tariff code and a country of origin, for example "What's the duty on HTS 8507.60.00 from China?". The desk answers from what it already holds, or researches it and keeps the result.
  2. Or a product description "canvas sneakers with rubber soles" returns candidate tariff codes quoted from the official schedule, each cited. Classification stays a human decision, so it offers options rather than picking one.

Outputs

  • The base rate and each duty overlay, kept separate and cited
  • A source link and research date on every figure
  • A confidence grade per claim, from the run's own trust data
  • What could not be verified, listed beside the answer
  • A change log of what each refresh moved

The repo ships 17 researched facts across 7 tariff codes and 10 product-and-origin combinations, plus six cached code lookups, so the app runs with no billable calls. One fact is deliberately past its shelf life so the freshness guard has something to catch.

View example on GitHub

How it works

A 6-phase pipeline.

  1. Find the code first A Web Search Agent reads the official schedule and CBP's rulings and returns candidate tariff codes, each quoted and cited.
  2. Split the research by how fast it ages Two agents run per product-and-origin: one for the base schedule rate, one for the duty overlays.
  3. Index with the provenance attached Each run becomes a LlamaIndex Document carrying confidence, per-claim citations, source URLs and the research date.
  4. Refuse to answer from stale facts A node postprocessor withholds anything past its shelf life instead of serving it as current.
  5. Show the gaps beside the answer Unverified items are listed with the answer, because confidence grades what was claimed, not what was covered.
  6. Refresh only what moved Only the volatile half is re-researched, and the diff against the previous run is logged.

Stack

Nimble primitives plus the full runtime stack.
Nimble APIs
What it does
  1. Web Search Agent Three agents, each with its own schema and source restriction, returning a schema-conforming answer with per-claim citations and a confidence grade.
  2. llama-index-tools-nimble Nimble's LlamaIndex integration. NimbleAgentToolSpec runs an agent and returns a LlamaIndex Document, so research output arrives as the framework's native type.
3rd Party Tools
Role
  1. llama-index-core Ingestion with upsert-by-hash, a persisted vector index, metadata-filtered retrieval, and a node postprocessor that enforces shelf life.
  2. claude-sonnet-5 Parses the question into a tariff code plus origin, and writes the answer from the retrieved facts.
  3. OpenAI text-embedding-3-small Embeddings for the vector index.
  4. streamlit Question box, tariff-code lookup, and a coverage sidebar showing each fact's age.
  5. python 3.10+ Required by llama-index-tools-nimble.
Reach out if you have any questions.
Talk to an Expert