Short on time? Agentic document parsing means treating a messy document as several different jobs and sending each part to the model or tool that handles it best: plain text to a text reader, tables to a layout model, scans and stamps to a vision model. A router splits the document, checks every result and sends low-confidence parts to a person. This article shows the design, code and controls.
Real business documents are rarely clean. A single contract can hold typed paragraphs, a scanned signature page, a pricing table, a handwritten note and a header logo. One tool seldom handles all of that well, and sending everything to one large model is slow and costly.
Agentic document parsing is a design that splits the work. A small controller looks at the document, decides what each part is and calls the right tool for it. This article explains the idea, the parts, a code sketch, a worked example and the controls that keep results trustworthy. It suits teams that process invoices, claims, contracts, forms or reports.
Key takeaways
- Documents mix text, tables, images and scans. Different parts need different tools.
- Microsoft describes Azure Document Intelligence as a machine-learning based OCR and intelligent document processing service that extracts key data from forms and documents.
- IBM’s 2026 trends point to systems of several models and tools working together, instead of one giant model doing everything.
- A router, per-part extractors, validation rules and human review make the design reliable.
- Measure accuracy per field and per document type, not just overall.
Why one model is rarely enough
A general language model reads text well, but scanned pages need OCR first, tables need layout understanding and stamps or signatures need vision. Sending whole pages to the strongest model costs more per page, adds delay and still misses table structure sometimes.
A split design uses cheap, specialised steps where they fit and strong models only where they are needed. This matches a theme in IBM’s 2026 trends: AI shifts from single models to systems where several parts work together. See AI orchestration.
What specialised tools exist
Cloud providers offer services built for documents. Microsoft’s Azure Document Intelligence is described as a machine-learning based OCR and intelligent document processing service that automates extraction of key data from forms and documents. Google Cloud offers a comparable Document AI service. Open-source libraries also parse PDFs, tables and images.
Use them as building blocks. Choose by accuracy on your documents, languages, data location rules and price.
The agentic document parsing design
1. Intake and triage
Receive the file, check type and size and scan for malware. Detect whether pages are digital text or scans. Record where the file came from.
2. Split into parts
Break each page into regions: paragraphs, tables, figures, signatures and stamps. A layout model or a simple rule set can do this. Keep the page number and position for each region, so results can be traced back.
3. Route each part
A router sends each region to a suitable tool:
- Digital text: direct text extraction.
- Scanned text: OCR.
- Tables: a table or layout model.
- Images and stamps: a vision model.
- Hard cases: a stronger language model, with the surrounding context.
4. Extract to a schema
Every extractor returns data in the same structure, such as JSON with named fields, values, page references and confidence.
5. Validate
Check results with rules: totals add up, dates are valid, required fields exist and values fall in sensible ranges.
6. Merge and review
Combine parts into one record. Send low-confidence or failed validations to a person with the page image next to the extracted value.
7. Learn from corrections
Store reviewer corrections. Use them for tests and, where suitable, to improve prompts or models.
A code sketch
This illustrative router shows the idea. The extractor functions are placeholders for your chosen tools:
from dataclasses import dataclass
@dataclass
class Region:
page: int
kind: str # "text", "scan", "table", "image"
content: bytes
def extract_text(r): ... # direct text extraction
def run_ocr(r): ... # OCR for scanned text
def read_table(r): ... # table or layout model
def read_image(r): ... # vision model
ROUTES = {"text": extract_text, "scan": run_ocr, "table": read_table, "image": read_image}
def parse_document(regions, min_conf=0.85):
results, review = [], []
for r in regions:
handler = ROUTES.get(r.kind)
if handler is None:
review.append({"page": r.page, "reason": "unknown region type"})
continue
out = handler(r) # {"fields": {...}, "confidence": 0.0-1.0}
out["page"] = r.page
(results if out["confidence"] >= min_conf else review).append(out)
return results, review And a validation step for an invoice:
def validate_invoice(fields):
problems = []
lines = fields.get("lines", [])
if abs(sum(l["amount"] for l in lines) - fields.get("subtotal", 0)) > 0.01:
problems.append("Line items do not add up to the subtotal.")
if fields.get("subtotal", 0) + fields.get("tax", 0) != fields.get("total"):
problems.append("Subtotal plus tax does not equal the total.")
if not fields.get("invoice_number"):
problems.append("Missing invoice number.")
return problems Why call it agentic
In a basic pipeline the steps are fixed. In an agentic design a controller can decide at run time: try a second tool when confidence is low, ask for a higher-resolution scan, look up a supplier record to check a value or stop and ask a person. Anthropic’s guidance on building effective agents advises finding the simplest solution possible. Start with a fixed router. Add agent behaviour only where tests show a gain, and keep limits on steps and cost.
A worked example: supplier invoices
This example is illustrative.
A company receives 20,000 supplier invoices a month in many layouts, some scanned.
- Triage: detect digital versus scanned. About 30 percent are scans.
- Split and route: header text to text extraction or OCR, line-item tables to a table model and logos and stamps ignored or sent to a vision model only when they matter.
- Schema: supplier, invoice number, date, currency, lines, tax and total.
- Validation: totals, tax rates, duplicate invoice numbers and supplier lookup.
- Review: anything under the confidence threshold goes to a clerk with the page image and the extracted value side by side.
- Measures: field-level accuracy, share needing review, time per invoice and cost per invoice.
- Result to look for: a lower review rate over time as corrections feed tests and prompts, with accuracy at or above the manual process.
Controls and risks
- Prompt injection in documents. A document can contain text meant to steer a model. Treat document text as data, give extractors no tools and validate outputs. See prompt injection explained.
- Privacy. Documents may hold personal data. Limit access, redact where possible and set retention.
- Silent errors. A misread digit can look fine. Use validation rules and sampling.
- Cost drift. Track cost per page by route.
- Audit. Keep the original, the extracted data and the review history.
Small business and enterprise views
- Sole trader or small business: use a hosted document service for invoices and receipts, check totals by eye and keep the originals.
- Mid-size company: build a router for your top three document types, add validation and a review screen and track field accuracy.
- Enterprise: run a shared document platform with a tool catalogue, versioned schemas, access control, monitoring and a governed review process. See AI model monitoring.
Regional and regulatory notes
Documents often include personal and financial data, so data protection and retention rules apply, and some sectors require records to stay in a given region. Check where each service processes data. See data residency and sovereignty. Test OCR and models on each language and script you handle.
Common mistakes
- Sending whole pages to one large model.
- No schema, so outputs differ by tool.
- Judging accuracy only overall.
- No validation rules.
- No review path for low-confidence parts.
- Ignoring injection risk in document text.
- Not keeping the source and the audit trail.
A starting plan
- Collect 200 real documents of one type, and label the fields you need.
- Run two or three tools, and compare accuracy per field.
- Build the router, schema and validation.
- Add a review screen and log corrections.
- Expand agentic document parsing to the next document type once the first one is stable.
How SoftSapien supports document automation
SoftSapien’s AI engineers design document pipelines, choose and test extraction tools, build validation and review screens and connect results to your systems. See our AI development and data science services.
To plan your document automation, use the contact page to chat with our team, send a message or schedule a free consultation call.
Frequently asked questions
What is agentic document parsing?
A design in which a controller splits a document into parts, sends each part to the best tool or model, validates the output and escalates doubtful parts to a person.
Why not send everything to one large model?
It costs more and runs slower, and it can still miss table structure or scanned content that a specialised tool handles well.
How do we keep results accurate?
Use one schema, validation rules such as totals that must add up, confidence thresholds and human review with the page image beside the value.
Is document text safe to trust?
No. Document text can carry hidden instructions, so treat it as data, give extractors no tools and validate their outputs.
Can SoftSapien help automate document processing?
Yes, from tool choice to review screens. Contact SoftSapien through the contact page to chat with our team, send a message or schedule a free consultation call.