This guide covers setting up and running FSI Foundry locally for development and testing without deploying to AWS.
Local development allows you to:
- Test agent logic without AWS deployment
- Debug with breakpoints and print statements
- Iterate quickly on code changes
- Avoid AWS costs during development
- Work offline (with cached Bedrock responses)
The application supports local development mode:
- Local mode - Runs on port 8000 with REST API for testing agent logic
- Python 3.11 or higher
- pip (Python package manager)
- AWS credentials (for Bedrock and S3 access)
- Git (for cloning the repository)
- Docker - For testing containerized deployment locally
- virtualenv or venv - For isolated Python environments
- jq - For pretty-printing JSON responses
# 1. Clone the repository (if not already done)
git clone <repository-url>
cd financial-risk-assessment-poc
# 2. Set up Python environment
cd src
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# 3. Install dependencies
pip install -r requirements/requirements.txt
# 4. Configure environment variables
cp ../.env.example .env
# Edit .env with your AWS credentials and settings
# 5. Run the application
python main.pyThe server will start on:
- Port 8000 for local development (default)
Create an isolated Python environment:
cd src
# Using venv (built-in)
python -m venv venv
source venv/bin/activate
# Or using virtualenv
virtualenv venv
source venv/bin/activate
# On Windows
venv\Scripts\activateInstall all required packages:
# Install base dependencies
pip install -r requirements/requirements.txt
# For development (includes testing, linting tools)
pip install -r requirements/requirements_dev.txt
# Verify installation
pip list | grep langchain
pip list | grep boto3Create a .env file in the src directory:
cp ../.env.example .envEdit .env with your settings:
# Deployment mode
DEPLOYMENT_MODE=local
# Agent selection
AGENT_NAME=kyc # Which agent to run
# AWS Configuration
AWS_REGION=us-east-1
AWS_ACCESS_KEY_ID=your-access-key-id
AWS_SECRET_ACCESS_KEY=your-secret-access-key
# Bedrock Configuration
BEDROCK_MODEL_ID=us.anthropic.claude-haiku-4-5-20251001-v1:0
# S3 Configuration
S3_BUCKET_NAME=your-bucket-name
# Application Configuration
APP_ENV=development
LOG_LEVEL=INFOImportant Notes:
- Use inference profile IDs (with
us.prefix) for Bedrock models - Ensure your AWS credentials have permissions for Bedrock and S3
- The S3 bucket should contain test customer data
Create sample customer data in S3:
# Create test data files
mkdir -p /tmp/test-data/customers/CUST001
# Create profile.json
cat > /tmp/test-data/customers/CUST001/profile.json << 'EOF'
{
"customer_id": "CUST001",
"company_name": "Acme Corporation",
"industry": "Technology",
"country": "United States",
"registration_date": "2020-01-15"
}
EOF
# Create credit.json
cat > /tmp/test-data/customers/CUST001/credit.json << 'EOF'
{
"credit_score": 750,
"annual_revenue": 5000000,
"debt_to_equity_ratio": 0.3,
"payment_history": "excellent",
"outstanding_debt": 500000
}
EOF
# Create compliance.json
cat > /tmp/test-data/customers/CUST001/compliance.json << 'EOF'
{
"kyc_status": "verified",
"aml_screening": "clear",
"sanctions_check": "clear",
"pep_status": "not_detected",
"beneficial_owners": ["John Doe", "Jane Smith"]
}
EOF
# Upload to S3
aws s3 sync /tmp/test-data/ s3://your-bucket-name/cd src
export DEPLOYMENT_MODE=local
export AGENT_NAME=kyc
python main.pyOutput:
INFO: Started server process [12345]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
curl http://localhost:8000/healthExpected response:
{
"status": "healthy",
"agent": "kyc_banking",
"deployment_mode": "local",
"timestamp": "2026-01-30T12:00:00Z"
}curl -X POST http://localhost:8000/invoke \
-H "Content-Type: application/json" \
-d '{
"customer_id": "CUST001",
"assessment_type": "full"
}' | jq '.'curl -X POST http://localhost:8000/invoke \
-H "Content-Type: application/json" \
-d '{
"customer_id": "CUST001",
"assessment_type": "credit_only"
}' | jq '.'curl -X POST http://localhost:8000/invoke \
-H "Content-Type: application/json" \
-d '{
"customer_id": "CUST001",
"assessment_type": "compliance_only"
}' | jq '.'Add breakpoints in your code:
# In src/agents/supervisor.py
def run_supervisor(state: dict) -> dict:
import pdb; pdb.set_trace() # Breakpoint
# Your code hereRun with debugger:
python -m pdb main.pyCreate .vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: FastAPI",
"type": "python",
"request": "launch",
"module": "uvicorn",
"args": [
"main:app",
"--reload",
"--host", "0.0.0.0",
"--port", "8000"
],
"cwd": "${workspaceFolder}/src",
"env": {
"DEPLOYMENT_MODE": "local",
"AGENT_NAME": "kyc_banking",
"AWS_REGION": "us-east-1"
},
"console": "integratedTerminal"
}
]
}Increase log verbosity:
export LOG_LEVEL=DEBUG
python main.pyView detailed logs:
# In your code
import logging
logger = logging.getLogger(__name__)
logger.debug("Detailed debug message")
logger.info("Info message")
logger.warning("Warning message")
logger.error("Error message")Edit files in src/:
adapters/- Deployment adapters (FastAPI, Lambda, AgentCore)core/- Registry and orchestration patternsagents/- Agent implementations (kyc, future agents)tools/- Tool implementationsconfig/- Configuration
# Restart the server (if not using --reload)
python main.py
# Test with curl
curl -X POST http://localhost:8000/invoke \
-H "Content-Type: application/json" \
-d '{"customer_id": "CUST001", "assessment_type": "full"}'pytest tests/Once satisfied with local testing:
# Deploy to AgentCore
./applications/fsi_foundry/scripts/deploy/deploy_agentcore.shTest the application in a containerized environment locally:
docker build --platform linux/amd64 \
--build-arg DEPLOYMENT_MODE=local \
-t ava:latest \
.docker run -d \
--name ava \
-p 8000:8000 \
-e AWS_REGION=us-east-1 \
-e AWS_ACCESS_KEY_ID=your-key \
-e AWS_SECRET_ACCESS_KEY=your-secret \
-e BEDROCK_MODEL_ID=us.anthropic.claude-haiku-4-5-20251001-v1:0 \
-e S3_BUCKET_NAME=your-bucket \
-e AGENT_NAME=kyc \
ava:latestcurl http://localhost:8000/health
curl -X POST http://localhost:8000/invoke \
-H "Content-Type: application/json" \
-d '{"customer_id": "CUST001", "assessment_type": "full"}'docker logs -f avadocker stop ava
docker rm avaSymptom: ModuleNotFoundError: No module named 'langchain'
Solution:
# Ensure virtual environment is activated
source venv/bin/activate
# Reinstall dependencies
pip install -r requirements/requirements.txtSymptom: NoCredentialsError: Unable to locate credentials
Solution:
# Set environment variables
export AWS_ACCESS_KEY_ID=your-key
export AWS_SECRET_ACCESS_KEY=your-secret
# Or configure AWS CLI
aws configureSymptom: AccessDeniedException: User is not authorized to perform: bedrock:InvokeModel
Solution:
- Ensure your AWS credentials have Bedrock permissions
- Verify the model is enabled in your AWS account
- Check the model ID is correct (use inference profile IDs)
Symptom: AccessDenied: Access Denied
Solution:
- Verify S3 bucket name is correct
- Ensure AWS credentials have S3 read permissions
- Check bucket policy allows your IAM user/role
Symptom: OSError: [Errno 48] Address already in use
Solution:
# Find process using the port
lsof -i :8000
# Kill the process
kill -9 <PID>
# Or use a different port
uvicorn main:app --port 8001Always use virtual environments to isolate dependencies:
python -m venv venv
source venv/bin/activateRegularly update dependencies:
pip install --upgrade -r requirements/requirements.txtNever hardcode credentials:
# Bad
bedrock_model_id = "us.anthropic.claude-haiku-4-5-20251001-v1:0"
# Good
bedrock_model_id = os.getenv("BEDROCK_MODEL_ID")Always test changes locally before deploying to AWS.
Add logging for debugging:
import logging
logger = logging.getLogger(__name__)
logger.info("Processing assessment for customer: %s", customer_id)try:
result = agent.run(input_data)
except Exception as e:
logger.error("Agent execution failed: %s", str(e))
raise- Testing Guide - Test your local setup
- Deployment Guides - Deploy to AWS
- Architecture Documentation - Understand the system design