Enterprise Document IntelligenceCase studies← Back to the case

The agent loop, shown step by step

One real question on a real contract: FEMA NFIP Dwelling Form (public domain). The naive keyword search says "not covered". The loop finds the cover on page 9.

Left: the question and the cited answer. Right: every tool call the agent made, in order.

Offline demo · real trace embedded · no server, no API key

The question

After a flood, will the policy pay the extra cost to rebuild my building to meet current floodplain building codes?

Answer (after the loop)
Yes, under Coverage D — Increased Cost of Compliance p.9–11
"This policy pays you to comply with a State or local floodplain management law or ordinance affecting repair or reconstruction of a building suffering flood damage."

The phrase "building code" never appears in the policy. The cover is filed under the trade term. That is why one keyword lookup gets it wrong, and why the loop is needed.

The loop

Keyword box (one shot)

search "building code" → 0 hits
Verdict: "Not covered." Confident, and wrong.

Agent (the loop)

expands to the governing term, finds it, reads the page, cites it.
Verdict: "Covered, page 9." Traceable and checkable.

What the loop actually does

  1. Search the obvious word. "building code" returns nothing. A keyword system stops here and answers "not covered".
  2. Notice the miss and expand. The agent tries the vocabulary an underwriter would use: code → compliance → ordinance → increased cost.
  3. Hit the governing term. "increased cost of compliance" lands on the policy's own Coverage D heading, page 9.
  4. Read the page to confirm context. A match inside an exclusion would mean the opposite; the agent reads to be sure.
  5. Return a cited answer, then stop. Status, the exact sentence, and the page. The citation is checked in code against the source.

The model is not being clever here. It is filling in the arguments of two tiny tools (search, read_page) in a loop. The intelligence is the loop, not the model.

The honest limit: when the same loop does not converge

Point the identical generic loop at "compare the two policy forms" and it never stops. It keeps searching and reading both documents and never produces an answer, even after 32 turns and 168 seconds. Comparison is a pipeline (parse both, align, diff, report), not an open search. The fix is not a better prompt; it is to give the agent a typed compare tool that runs the deterministic comparison and returns a structured result. The loop works when the task decomposes into the tools you gave it, and stalls when the right tool is missing. The engineering is the tools.

Static demonstration (frozen data), not the live tool. For a tool on your own documents, contact us. · Case studies