In a post published on the AWS blog, an architecture was presented for a contract intelligence platform based on AI agents, the Amazon Bedrock AgentCore service, and Amazon Quick analytics tools. The solution is designed to address the limitations of RAG-based chat tools when analyzing large contract portfolios, proposing a transition from chunk-based semantic retrieval to structured data extraction paired with database aggregation queries.
RAG Limitations in Portfolio-Wide Aggregation Questions
According to the post's authors, a contracting director is responsible for hundreds or thousands of vendor contracts containing critical information such as contract values, expiration dates, signature status, and key contacts. When this information is locked inside PDF files, teams are forced to manually extract data into spreadsheets to answer recurring questions from leadership, such as which contracts are about to expire or which vendor accounts for the highest spend.
The post explains that many enterprise chat tools rely on Retrieval Augmented Generation (RAG) technology. This method breaks long documents into chunks, indexes them, and retrieves only the most relevant chunks (top-k) during a semantic search. While this approach works well for targeted questions focused on a single document, it fails when aggregation across an entire contract portfolio is required—such as calculating total portfolio value or identifying the most expensive contract. Because the model receives only a small subset of the chunks, it performs calculations solely on the retrieved chunks and returns an incorrect answer.
The key insight presented is that the solution for cross-document questions lies in structured extraction of key fields into a dedicated database, using artificial intelligence to convert unstructured information into a defined structure, and using the database to perform mathematical operations and aggregations. Simultaneously, original documents are maintained in a knowledge base to handle specific, single-document questions.
Pipeline Architecture: Dual Agents and Data Verification
The described solution is a React-based web application on AWS, consisting of several steps:
- Contract PDF documents are uploaded to an Amazon Simple Storage Service (Amazon S3) bucket, which triggers an automated processing pipeline.
- An AI-based extraction agent (powered by the Claude Sonnet series of models) reads the PDF and extracts eight key fields, assigning a confidence score to each field.
- A separate verification agent (powered by the lighter Claude Haiku model) independently reads the same document and verifies the extracted information.
- If a disagreement occurs between the two agents regarding signature detection, Amazon Textract serves as a deterministic tiebreaker using computer vision analysis.
- Verified data is saved to an Amazon Aurora PostgreSQL database.
- Users receive real-time status updates via WebSocket communication and can query the data through embedded dashboards and a natural language chat agent.
The article's authors note that the pipeline can process a contract in seconds under typical conditions, and the serverless architecture is designed to enable parallel scaling for processing numerous contracts. The agents were built using the Strands Agent SDK and run in the Amazon Bedrock AgentCore environment, which provides serverless hosting, automatic scaling, and session isolation. In addition, the policy mechanism in Bedrock AgentCore allows defining Cedar-based security controls to ensure users and agents access only authorized contracts.
Model Selection and Signature Detection Tiebreaking
The architecture combines two different models: Claude Sonnet for extraction, due to its ability to read PDF files directly without prior OCR preprocessing and return structured JSON, and Claude Haiku for fast, cost-effective verification providing an independent perspective that catches errors.
During testing, the developers discovered a failure mode in which the verification model sometimes flagged a contract as signed with 95%–100% confidence even though no signature was present, while the extraction agent correctly identified that the contract was unsigned. The model misinterpreted the text of an empty signature block ("Signature: __________") as proof of a signature. Rather than relying on complex prompt instructions, Amazon Textract was added as an evidentiary tiebreaker that runs only when there is disagreement on the is_signed field. Textract visually analyzes the page to identify actual handwritten or digital signatures, thereby preventing false positives at minimal cost.
In an experiment conducted on a sample of 20 contracts with 8 hand-labeled fields (160 values total), extraction was found to be the higher-impact step on accuracy. Using a more capable extraction model held accuracy up even when paired with a light verifier model, while a lighter extraction model brought accuracy down regardless of the verifier model.
Querying and Analytics with Amazon Quick
To enable data access, the system connects to Amazon Quick, which combines structured dashboards and a natural language conversational agent:
- Aggregation questions (such as total portfolio value or the number of expired contracts) are routed to queries against the PostgreSQL database and defined Topics.
- Document-specific questions (such as payment terms in a specific vendor's contract) are retrieved directly from the knowledge base of source files.
Amazon Quick Sight dashboards are embedded directly into the React application using the dedicated SDK, querying data directly from the database to display updated information immediately upon contract processing completion. The views include key performance indicators (KPIs), a full extraction table, confidence scores from both agents, and a cost breakdown.
Operating Costs and Key Insights
According to the published cost analysis, the bulk of the monthly cost stems from analytics tool licensing rather than running the language models:
- Amazon Quick licensing for an Enterprise user and infrastructure: approximately $290.
- Amazon Aurora Serverless v2 database: approximately $44.
- Model execution in Amazon Bedrock (extraction and verification): approximately $12 per month for 1,000 contracts.
- Amazon Textract service (signature tiebreaker): approximately $2 per month.
- Additional infrastructure services (AWS Lambda, API Gateway, S3, CloudFront): less than $1.
- Total monthly cost estimated by the team stands at approximately $349 for processing 1,000 contracts per month.
AI model inference costs total approximately $0.014 per contract. The authors concluded that for aggregation use cases across many documents, it is recommended to extract key fields into a structured database before querying, use two independent models for verification to catch errors in high-stakes data, and rely on purpose-built deterministic services when language models are prone to hallucinations. In cases where two models disagree in ways a deterministic service cannot settle, the next step is to route the contract to a human reviewer instead of auto-resolving.