How to build a Document Comparison AI Agent

StackAI’s Document Comparison Agent reads two or more versions of a document and highlights every change. It turns messy diffs across Excel, Word, and PDF files into a clean, structured report that anyone can trust.

Challenge

Comparing versions by hand is slow and error-prone. Files arrive in mixed formats with tracked changes off, screenshots embedded, and sheets renamed. Analysts waste time hunting for deltas instead of validating impact, and audit teams need a defensible trail that manual reviews rarely provide.

Industry

Finance

Department

Finance

Legal

HR

Integrations

OpenAI

Excel/Sheets

TL;DR

  • What it does: Compares two uploaded files and returns a complete list of changes as a structured table (sheet, cell, old value, new value).

  • Who it’s for: Finance ops, legal, procurement, QA/compliance, PMOs.

  • Time to value: ~30–45 minutes to configure; seconds per comparison thereafter.

  • Output: A diff table (markdown/CSV/JSON) ready to paste into docs, tickets, or Slack.

Common Pain Points of Comparing Documents

  • Tracked changes are off or incomplete across versions.

  • Mixed formats (Excel, Word, PDF scans) make line-by-line review impossible.

  • Version sprawl in shared drives with unclear “final” files.

  • No consistent audit trail for approvals and sign-off. 

What the Agent Delivers

  • Exhaustive, cell-level diffs for spreadsheets with sheet name, cell, old value, new value.

  • Structured output you can export (markdown now; CSV/JSON optional).

  • Deterministic runs with low temperature for repeatable results.

  • Optional notifications to send results to Slack/Email. 

Check Out This Short Tutorial!

Step-by-Step Build (StackAI Nodes)

1) Documents (Files)

  • What it does: You upload the two Excel files to compare.

  • Goal: Provide the LLM direct access to the file contents.

  • How to set it up:


    • Upload BusinessPlan_V1.xlsx first → becomes {doc-0}.

    • Upload BusinessPlan_V2.xlsx second → becomes {doc-1}.


  • Tips: Use clear filenames so your prompt can refer to “old” vs “new” unambiguously.

2) Analyze Differences with AI (LLM)

  • What it does: Reads both workbooks, checks every sheet/cell pair, and lists only the cells whose values changed.

  • Goal: Produce a clean, exhaustive markdown table of differences.

  • Model: o3 (OpenAI) - most reliable for calculations, following KPI formats, and caveats.

Instructions

You are an AI agent specialized in document comparison. Your task is to compare two Excel business plans—a previous version and a modified version—and identify all changes between them.



For every change, return:



Sheet name

Cell reference (e.g., B3)

Old value (from the original version)

New value (from the updated version)





Only include cells where the value has changed. Ignore formatting or comments. Output should be structured and easy to read or export (e.g., in markdown table or JSON format)

Prompt

Compare the two Excel files and identify the differences.

- Analyze the files <Documents>
  <File1>
  {doc-0}
  </File1>
  <File2>
  {doc-1}
  </File2>
  </Documents>

- For each difference found:
  - Display the sheet name
  - Indicate the cell (e.g., C7)
  - Show the old value (from BusinessPlan_V1)
  - Show the new value (from BusinessPlan_V2)

- Only include cells where the value has changed.
- Present the results in a markdown table format as follows:

| Sheet       | Cell | Old Value | New Value |
|-------------|------|-----------|-----------|
| Financials  | B3   | 100,000   | 120,000   |
| Assumptions | C7   | 5.5%      | 6.0%      |

- Do not summarize; return the complete list of changed cells

Response format: Text (markdown table only).

Advanced settings: Temperature 0; Top-p 1; Max tokens high enough to cover all diffs; stop words not required.

3) Differences in a table format (Output)

  • What it does: Displays the markdown table from the LLM.

  • Goal: Give you a copy-pastable diff for docs, tickets, or Slack.

Optional enhancements

  • Export: Add a small “Formatter” step to also save as CSV (same columns) if you want a file artifact.

  • Notify: Send the diff to Slack/Email if triggered by a new upload.

4) Export Interface: Advanced Form

Export the workflow and select Advanced Form. This lets you share the workflow as a form where others can upload the documents and submit them to get the results.

Get started

Secure Connections. Trusted Data Handling.

We prioritize your security and privacy, ensuring safe database connectivity with strict data processing controls.

Get started

Secure Connections. Trusted Data Handling.

We prioritize your security and privacy, ensuring safe database connectivity with strict data processing controls.

Get started

Secure Connections. Trusted Data Handling.

We prioritize your security and privacy, ensuring safe database connectivity with strict data processing controls.