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
Prompt
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.






