Skip to main content

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

  1. Document Upload → PDF files uploaded to S3
  2. AWS Textract → Extracts text and tables from documents
  3. Parser Agent → Structures extracted data into risk categories
  4. Gap Detector → Identifies missing or incomplete fields
  5. Risk Analysis Agent → Scores all 7 risk categories with subcategories
  6. 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

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
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)
Processing:
AWS Textract Analysis:
Output: Structured data ready for gap detection Document Status Transitions:
Textract jobs can take several minutes for large PDFs. The frontend should poll document status every 3-5 seconds with a maximum timeout of 10 minutes.

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
Processing:
Gap Field States:
Field has no extracted value. User must provide data manually.
Output: Gap fields created across all 7 risk categories (5 fields each = 35 total) Assessment Status Transition:
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)
Processing:
For Each Risk Category:
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:
Output: Complete risk scores for all 7 categories + overall assessment score Assessment Status Transition:

4. Report Generation Agent

Purpose: Creates PDF report with visualizations and traffic-light indicators Input:
  • Complete risk score data
  • Assessment metadata
  • Recommendations
Processing:
See: Report Generation for detailed documentation

Asynchronous Job Processing

All AI operations run as background jobs:

Retry Logic

Jobs retry up to 3 times on failure:
Jobs can automatically trigger dependent jobs:

Prompt Management

AI agents use versioned prompts managed through the Prompt CMS:
See: Prompt Management documentation for versioning, comments, and change tracking

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.

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