A document-processing agent should turn an untrusted file into a reviewable structured proposal—not silently import its guesses as authoritative records.
Evidence check: 25 October 2026. Product details reflect the referenced documentation observed at this cutoff; exact plans, prices, regional eligibility and unverified release dates are not claimed. This is an editorial guide, not a hands-on test.
Define the contract before choosing a model
Inputs: a file, authenticated submitter, source ID and target record type. Outputs: extracted fields, per-field evidence, validation flags and an approval-ready draft. The target system should accept only a typed schema. Use deterministic checks for file size, extension, duplicate hash, required fields and authorization before any model sees the document.
Ingestion and extraction
Store the original document in restricted storage. Extract machine-readable text or use an appropriate document parser, retaining page and position metadata. An LLM may help interpret ambiguous tables or headings, but should report missing values as null rather than fabricate them. Keep the original bytes and extracted text separated from the model’s instructions.
Reconcile against authority
Validate dates, numeric units, currencies and identifiers with code. Check existing records and approved reference tables. Mark conflicts, inaccessible sources and low-confidence OCR for human review. Where a model provides a plausible value without source evidence, present it as proposed rather than verified.
Approval step
A reviewer receives the original document link, source excerpt, draft values, proposed changes and any policy flags. Approving the draft should authorize one specific write to one target record. Store the approval event and exact content hash; edits after approval require resubmission. Never let a text instruction in an uploaded document grant permission to send it outside the organization.
Commit, verify and recover
Use a single operation ID to guard against duplicate imports. After storing, read back the authoritative record and record its version. If the write times out, reconcile before retrying. If validation fails, return an actionable error message without modifying the target.
Suggested evaluation
Use a held-out set of clean, scanned, multilingual, truncated, duplicated and adversarial files. Score field correctness, evidence traceability, successful human correction and verified single-write completion. This is a reproducible design recipe, not evidence that any specific model or parser has passed the tests.
A reproducible document example
Take a sample invoice with invoice number, vendor, currency, total and due date. The extraction agent emits a JSON object with source page, quoted evidence snippet and confidence/unknown state for each field. A deterministic validator rejects totals whose line items do not reconcile and flags date ambiguity between regional formats. A reviewer sees the original page beside the proposed data and can correct or reject each field.
Commit only the reviewed version
The approved payload is frozen with a content hash and linked to the source document’s version. A service then creates a draft ledger record under a scoped identity, writes an external object ID into an audit trail and refuses duplicate submissions for the same idempotency key. Quarantine files with malformed encodings, malicious links or unsupported content rather than instructing the model to improvise. Test the full workflow on blank pages, rotated documents, duplicate invoices and conflicting supplier identities before treating it as production-capable.
Sources and Further Reading
- OpenAI — File search tool in Responses API (accessed 2026-10-25)
- LangChain — LangGraph: Interrupts (accessed 2026-10-25)
- OWASP — Prompt Injection security glossary (accessed 2026-10-25)