Turning unstructured text into
validated, schema-bound JSON
Agent 09 solves a deceptively hard problem: enterprises drown in semi-structured documents — emails, PDFs, forms, contracts — where the data is present but not extractable. This agent makes it machine-readable on demand.
The Problem
Every enterprise handles high volumes of documents that are structurally inconsistent: vendor invoices arrive in dozens of formats, job applications mix freeform paragraphs with structured fields, customer emails embed order details in prose. Extracting this data manually is expensive and error-prone.
Traditional regex and rule-based extraction breaks the moment a vendor changes their invoice template. NLP pipelines require training data and infrastructure. The gap between "we have the data" and "we can query the data" costs businesses enormous operational overhead.
Design Decisions
Schema-first extraction
Rather than trying to infer what fields are interesting, Agent 09 requires the user to define the target schema upfront. This has a critical advantage: the model's extraction is grounded in explicit intent, not best-guess heuristics. The schema also doubles as the validation contract.
Field-level confidence scores
Every extracted value carries a confidence score between 0 and 1. This is the key differentiator from naive extraction. A value present verbatim in the text scores near 1.0. A value inferred or ambiguous scores lower. A missing value returns null at 0.0.
This means downstream systems can build confidence thresholds into their workflows: auto-approve high-confidence extractions, route medium-confidence cases for quick review, flag low-confidence fields for human verification. Confidence scores make the agent composable with human oversight.
Tight token budget
The entire agent operates within a strict token envelope designed for production use at scale.
The system prompt is dynamically generated from the user's schema, staying under 300 tokens regardless of field count. The 800-token output cap comfortably covers JSON for 15–20 fields with confidence scores. Single-call architecture means latency stays low and costs stay predictable.
How It Works
User specifies field names and types (string, number, date, boolean, array). Presets for common document types accelerate setup. Schema feeds directly into the system prompt.
Any unstructured text: email body, PDF paste, form response, contract clause. No preprocessing required. The model handles format noise natively.
System prompt encodes schema + output format requirements. User message contains the document. The model returns structured JSON only — no preamble, no commentary.
JSON is parsed client-side, validated against the schema, and rendered as an interactive table with confidence bars and a copyable clean JSON output.
System Prompt Design
The system prompt is the core of the agent. It must be concise enough to stay under 300 tokens while encoding enough precision that the model reliably outputs valid, parseable JSON.
Key choices: constrained output format (JSON only, no markdown fences), explicit null handling, confidence as a first-class field, and field enumeration embedded at generation time. The prompt rebuilds on every schema change, keeping it minimal.
Results & Observations
What works well
Extraction quality is high for documents where fields are explicitly labeled — invoices, structured emails, job postings. Date normalization, currency detection, and boolean inference all perform reliably. The model handles minor OCR artifacts and formatting noise gracefully.
Where confidence drops
Fields that require inference across multiple sentences score lower. Array fields (line items, skills lists) are extracted correctly but confidence ratings tend toward conservative. Documents with conflicting signals — e.g., multiple dates — produce appropriately lower confidence, which is the correct behavior.
Compared to alternatives
| Approach | Template-free | Confidence scores | Setup time | Maintenance |
|---|---|---|---|---|
| Agent 09 (LLM) | ✓ | ✓ | Seconds | None |
| Regex / rules | ✗ | ✗ | Days–weeks | High |
| Fine-tuned NER | ✗ | Partial | Weeks | Medium |
| Manual data entry | ✓ | N/A | Immediate | Ongoing labor |
What I Learned
The biggest insight: confidence scores aren't just a UX affordance — they change the product's trust model. Without them, every extraction is binary (right or wrong). With them, you can build tiered workflows where high-confidence extractions flow automatically and edge cases surface to humans. This makes the agent enterprise-deployable rather than a demo.
The schema-first approach initially felt limiting — why not let the model infer the schema? In practice, schema-first produces far more reliable results because the model's extraction is grounded. Open-ended extraction is still useful, but the output variance is much higher.
Token efficiency matters more than it looks. By keeping the system prompt under 300 tokens and output under 800, this agent can process documents at roughly 1/5th the cost of a naive implementation. At scale, that's the difference between a viable product and an expensive prototype.