Overview
The CGIAR Risk Intelligence Tool uses a multi-agent AI pipeline built on AWS Bedrock to automate risk assessment. The system orchestrates specialized AI agents, each handling a specific phase of the analysis workflow.Architecture
Processing Flow
- Document Upload → PDF files uploaded to S3
- AWS Textract → Extracts text and tables from documents
- Parser Agent → Structures extracted data into risk categories
- Gap Detector → Identifies missing or incomplete fields
- Risk Analysis Agent → Scores all 7 risk categories with subcategories
- Report Generator → Creates comprehensive PDF with traffic-light indicators
All AI operations run asynchronously as background jobs. The frontend polls job status for completion.
AWS Bedrock Integration
Foundation Models
All agents use Claude 3.5 Sonnet v2 from Anthropic:Resilience Features
Circuit Breaker
Circuit Breaker
Prevents cascading failures by opening after 3 consecutive failures:
- Open: Rejects requests immediately for 60 seconds
- Half-Open: Allows one test request after timeout
- Closed: Normal operation
Exponential Retry
Exponential Retry
Automatically retries throttled requests:
- Retries up to 3 times for throttling/service errors
- Exponential backoff between attempts
- Fails fast for validation errors
Agent Pipeline
1. Parser Agent
Purpose: Structures raw Textract output into organized risk category data Input:- Extracted text content from AWS Textract
- Extracted tables with headers and rows
- Assessment metadata (company name, type, country)
2. Gap Detector Agent
Purpose: Identifies missing or incomplete data fields that need user verification Input:- Parsed document data
- Assessment metadata
- List of required fields per risk category
- MISSING
- PARTIAL
- VERIFIED
Field has no extracted value. User must provide data manually.
Gap detection is triggered for
GUIDED_INTERVIEW and MANUAL_ENTRY intake modes after data submission, and for UPLOAD mode after document parsing.3. Risk Analysis Agent
Purpose: Generates risk scores, narratives, and recommendations for all categories Input:- Verified gap field data
- Assessment metadata
- Historical risk benchmarks (future enhancement)
1
Score Subcategories
AI analyzes data and assigns scores (0-100) to 5 subcategories:
2
Calculate Category Score
Aggregate subcategory scores (default: equal weights):
3
Assign Risk Level
Map score to traffic-light level:
4
Generate Narrative
AI creates contextual risk narrative:
5
Create Recommendations
Generate 2-3 prioritized recommendations:
4. Report Generation Agent
Purpose: Creates PDF report with visualizations and traffic-light indicators Input:- Complete risk score data
- Assessment metadata
- Recommendations
Asynchronous Job Processing
All AI operations run as background jobs:Retry Logic
Automatic Retries
Automatic Retries
Jobs retry up to 3 times on failure:
Job Chaining
Job Chaining
Jobs can automatically trigger dependent jobs:
Prompt Management
AI agents use versioned prompts managed through the Prompt CMS:Code Example: Complete AI Pipeline
Best Practices
Monitor Token Usage
Track Bedrock token consumption per job type to optimize costs and identify inefficient prompts
Implement Timeouts
Set reasonable polling timeouts (10 min for Textract, 5 min for AI jobs) to prevent infinite loops
Handle Partial Results
Design UIs to show progress and partial results rather than blocking on job completion
Version Prompts
Always version prompts before deploying to production. Use the Prompt CMS change tracking.
Related Resources
Risk Scoring
Understand how AI-generated scores map to risk levels
Assessment Workflow
See how AI agents fit into the assessment lifecycle
Report Generation
Learn about PDF report creation with AI-generated content