A production-deployed multi-agent decision system combining cognitive-emotional debate with adaptive reasoning weights
Live Demo β’ Architecture β’ Features β’ Getting Started
P-CABA represents a breakthrough in AI decision-making by orchestrating structured debates between cognitive and emotional reasoning agents. Unlike traditional AI assistants that provide single-perspective answers, P-CABA leverages Amazon Bedrock's AgentCore SDK and Strands SDK to enable multi-turn conversations, ethical validation, and adaptive learningβall deployed in production on AWS ECS.
Human decision-making is never purely logical or purely emotionalβit's a dynamic balance. P-CABA mirrors this by:
- π§ Cognitive Agent (AgentCore SDK): Deep analytical reasoning with Ethics and Social action groups
- β€οΈ Emotional Agent: Sentiment analysis and empathy-driven perspectives
- π€ Debate Phase (Strands SDK): Multi-turn argument exchange using Amazon Nova Micro
- βοΈ Adaptive Weights: Context-aware balance (e.g., 70% cognitive / 30% emotional for healthcare)
- π Real Actions: Executes decisions via AWS Lambda, SES, and external APIs
Built for: Healthcare decisions, business strategy, legal analysis, and complex life choices
- 9 AWS Services: ECS Fargate, ALB, ECR, Bedrock, Lambda, SES, CloudWatch, 3 Knowledge Bases
- 4 Bedrock Models: Claude 3.5 Sonnet (cognitive), Claude 3 Haiku (emotional), Titan Embeddings (RAG), Nova Micro (synthesis)
- Auto-scaling: 1-4 ECS tasks with health checks and monitoring
- Public Endpoint:
http://p-caba-alb-381387112.us-east-1.elb.amazonaws.com
- AgentCore SDK: Cognitive reasoning agent with Ethics + Social action groups calling real FDA and Yahoo Finance APIs
- Strands SDK: Multi-turn conversational debate synthesis using Amazon Nova Micro
- First-of-its-kind: Combines structured reasoning (AgentCore) with conversational AI (Strands) in production
- Adaptive Weights: System learns optimal cognitive/emotional balance per domain (healthcare: 70/30, legal: 50/50)
- Knowledge Base RAG: 3 domain-specific collections (healthcare, business, legal) with 100+ documents each
- Real-World Actions: FDA drug lookups, market analysis, Lambda-powered scheduling, email notifications
- 6-Tab Interface: Analysis, Graph, Debate, Memory, Adaptive Weights, Executor
- Visual Agent Flow: Hierarchical graph showing timing and confidence across 7 agents
- Color-Coded Debate: Blue (cognitive) vs Pink (emotional) with common ground highlighting
- Email Summaries: Professional notifications with reasoning balance (e.g., "π§ Cognitive 70% | β€οΈ Emotional 30%")
Production deployment on AWS: ALB β ECS Fargate β Bedrock (4 models) β 3 Knowledge Bases β Lambda β SES β CloudWatch
Components:
- Load Balancer: Application Load Balancer for public access
- Compute: ECS Fargate (0.5 vCPU / 1GB, auto-scaling 1-4 tasks)
- Container Registry: ECR with AMD64 Docker images
- AI/ML: Amazon Bedrock (Sonnet, Haiku, Titan, Nova) + AgentCore + Strands SDK
- Data: 3 Knowledge Bases with Titan Embeddings for RAG (healthcare, business, legal)
- Serverless: Lambda functions for actions (consultation scheduling, document generation)
- Communication: SES for email notifications with reasoning balance
- Monitoring: CloudWatch Logs + Metrics with custom dashboards
Multi-agent workflow with debate: Controller β Cognitive (AgentCore) β Emotional β Debate (Strands SDK) β Synthesizer β Executor
Workflow:
User Query
β
[Controller Agent]
βββ [Cognitive Agent (AgentCore SDK)]
β ββ Ethics Sub-Agent (moral validation)
β ββ Social Sub-Agent (community impact)
β ββ Tools: FDA API, Yahoo Finance, Knowledge Base RAG
β
βββ [Emotional Agent]
ββ Sentiment Sub-Agent (empathy analysis)
ββ Past Experience Sub-Agent (historical context)
β
[Debate Phase (Strands SDK + Nova Micro)]
ββ Turn 1: Cognitive presents evidence
ββ Turn 2: Emotional counters with empathy
ββ Turn 3: Common ground synthesis
β
[Synthesizer Agent]
ββ Weighted final decision (e.g., 70% cognitive / 30% emotional)
β
[Executor Agent]
ββ Lambda: Schedule consultation
ββ SES: Send email notification
ββ External APIs: Real-time data fetching
Key Technologies:
- AgentCore SDK: Structured reasoning with action groups
- Strands SDK: Conversational multi-turn debate
- FAISS Memory: Vector storage for conversation context
- Plotly: Interactive agent activation visualizations
- Python 3.11+
- AWS Account with Bedrock access (for production) OR Ollama (for local development)
- Docker (optional, for containerized deployment)
# 1. Clone repository
git clone https://github.com/saiakhil2012/dynamic-multiagent-brain.git
cd dynamic-multiagent-brain
# 2. Install dependencies
pip install -r requirements.txt
# 3. Start Ollama server
ollama serve
# 4. Configure for Ollama
# Edit config.yaml:
provider: "ollama"
ollama:
model: "tinyllama:latest"
base_url: "http://localhost:11434"
# 5. Run application
streamlit run streamlit_app.py# 1. Configure AWS credentials
aws configure
# Enter: Access Key, Secret Key, Region (us-east-1), Output (json)
# 2. Update config.yaml
provider: "bedrock"
bedrock:
model: "amazon.nova-micro-v1:0"
region: "us-east-1"
agents:
use_agentcore: true
use_strands: true
# 3. Verify Bedrock access
aws bedrock list-foundation-models --region us-east-1
# 4. Run application
streamlit run streamlit_app.py
# 5. Access at http://localhost:8501# 1. Build Docker image
docker buildx build --platform linux/amd64 -t p-caba-ui . --load
# 2. Run container
docker run -p 8501:8501 \
-v ~/.aws:/root/.aws \
-e AWS_REGION=us-east-1 \
p-caba-ui
# 3. Access at http://localhost:8501# See AWS_MIGRATION.md for full deployment guide
# Includes: ECR push, ECS cluster setup, ALB configuration, IAM rolesQuery:
"Should I approve an experimental aspirin-based drug for high-risk heart attack patients?"
What P-CABA Does:
- Cognitive Agent (AgentCore) calls FDA OpenFDA API to check drug safety data
- Ethics Sub-Agent validates moral implications of experimental treatment
- Social Sub-Agent assesses community health impact
- Emotional Agent analyzes patient suffering and quality-of-life concerns
- Debate (Strands SDK) produces multi-turn argument exchange
- Synthesizer weights cognitive (70%) vs emotional (30%) for balanced decision
- Executor schedules Lambda consultation and sends email notification
Output:
- Detailed analysis with citations from FDA database
- Ethical validation report
- Emotional impact assessment
- Final recommendation with confidence score
- Professional email summary with reasoning balance
Query:
"Should I lay off 100 employees or cut everyone's salary by 20%? We have 8 months runway."
What P-CABA Does:
- Cognitive Agent queries Yahoo Finance API for market conditions
- Knowledge Base RAG retrieves business best practices from 100+ documents
- Emotional Agent analyzes employee morale and retention concerns
- Debate balances financial survival vs team impact
- Executor generates decision report and sends stakeholder email
Query:
"Should we accept the $2M settlement offer or proceed to trial?"
What P-CABA Does:
- Cognitive Agent analyzes legal precedents from Knowledge Base
- Emotional Agent considers client stress and public relations
- Debate weighs risk/reward tradeoffs
- Executor schedules Lambda-powered consultation with legal team
ChatGPT-like conversation flow with session management and thinking state indicators
| Adaptive Weights Tab | Executor Actions Tab |
|---|---|
![]() |
![]() |
| Real-time cognitive vs emotional balance with orange/green visualization | Real-world actions: Lambda, SES, FDA API, Yahoo Finance |
-
π Analysis Tab
- Color-coded cognitive (blue) vs emotional (pink) reasoning
- Sub-agent contributions (Ethics, Social, Sentiment, Past Experience)
- Tool usage results (FDA API, Yahoo Finance, Knowledge Base)
- Final synthesized decision
-
π Agent Activation Graph
- Hierarchical visualization of 7 agents
- Timing breakdown (cognitive: 3.2s, emotional: 2.8s, debate: 1.5s, etc.)
- Confidence scores at each stage
- Data flow arrows showing information passing
-
π¬ Debate Tab
- Multi-turn conversation between cognitive and emotional agents
- Turn-by-turn arguments with colored backgrounds
- Common ground identification (green highlight)
- Final resolution (gold highlight)
-
π§ Memory Tab
- FAISS vector storage showing relevant past conversations
- Semantic search results with cosine similarity scores
- Conversation history with timestamps
-
βοΈ Adaptive Weights Tab (shown above)
- Real-time cognitive vs emotional weight distribution
- Orange (cognitive) and green (emotional) progress bars
- Historical weight changes over time (Plotly line chart)
- Domain-specific weight patterns
-
β‘ Executor Tab (shown above)
- Real-world actions taken (Lambda, SES, APIs)
- Timing and success/failure status
- Email notification previews
- Execution logs
- π‘ Quick Test Prompts: 16 curated examples across healthcare, business, legal
- π§ Email Notifications: Enable/disable with email input
- π¨ Session Management: ChatGPT-like session switching
- π Statistics: Query count, average confidence, total reasoning time
"Should I accept a high-paying job at a company with questionable environmental practices?"
Expected: Cognitive agent argues for career advancement, emotional agent raises ethics concerns, synthesizer balances both perspectives.
"What's the latest FDA approval for heart medication and should we invest in the company?"
Expected: FDA OpenFDA API call + Yahoo Finance API call + Knowledge Base RAG + synthesized investment recommendation.
"What did we discuss about drug approvals earlier?"
Expected: FAISS returns relevant past conversations with similarity scores, enabling context-aware responses.
"Should our hospital implement AI-assisted triage in the emergency room?"
Expected: Healthcare domain triggers 70% cognitive weighting, with ethics validation and patient safety analysis.
dynamic-multiagent-brain/
βββ agents/
β βββ cognitive_agent.py # AgentCore SDK integration
β βββ emotional_agent.py # Sentiment + empathy reasoning
β βββ synthesizer_agent.py # Strands SDK debate synthesis
β βββ real_executor_agent.py # Lambda, SES, API execution
β βββ rag_helper.py # Knowledge Base RAG queries
β βββ sub_agents/
β β βββ ethics_agent.py # Moral validation
β β βββ social_agent.py # Community impact
β β βββ sentiment_agent.py # Emotional analysis
β β βββ past_experience_agent.py # Historical context
β βββ tools/
β βββ calculator.py # Mathematical operations
β βββ weather.py # Weather data (Open-Meteo)
β βββ web_search.py # DuckDuckGo search
βββ controller/
β βββ adaptive_controller.py # Orchestration + weight management
βββ domains/
β βββ config.py # Domain-specific configurations
β βββ knowledge_base.py # Bedrock Knowledge Base integration
βββ memory/
β βββ faiss_memory.py # Vector storage
β βββ short_term_memory.py # Session context
β βββ long_term_memory.py # Persistent storage
βββ llm/
β βββ providers.py # LLM abstraction (Ollama β Bedrock)
βββ config/
β βββ config.yaml # Configuration file
β βββ loader.py # Config parser
βββ utils/
β βββ logger.py # Logging utilities
β βββ visualization.py # Plotly chart helpers
βββ streamlit_app.py # Main UI application
βββ agent_activation_viz.py # Hierarchical graph visualization
βββ Dockerfile # Multi-stage Docker build
βββ requirements.txt # Python dependencies
βββ README.md # This file
llm:
provider: bedrock # Options: bedrock, ollama, sagemaker
bedrock:
model: amazon.nova-micro-v1:0
region: us-east-1
agents:
use_agentcore: true # Enable AgentCore SDK for cognitive agent
use_strands: true # Enable Strands SDK for debate synthesis
cognitive:
enabled: true
sub_agents: [ethics, social]
emotional:
enabled: true
sub_agents: [sentiment, past_experience]
memory_provider: dynamodb # Options: dynamodb, local
aws:
region: us-east-1
lambda: true
api_gateway: false# AWS Credentials (required for Bedrock)
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_REGION=us-east-1
# Optional: Override model
BEDROCK_MODEL=amazon.nova-pro-v1:0
# Optional: SES email sender
SES_SENDER_EMAIL=noreply@yourdomain.com# Test LLM providers
python test_llm_providers.py
# Test end-to-end workflow
python test_end_to_end.py
# Test Knowledge Base integration
python test_knowledge_base.py- Create new file in
agents/sub_agents/your_agent.py - Extend
SubAgentbase class - Implement
reason()method - Register in
cognitive_agent.pyoremotional_agent.py
from agents.sub_agents.base_sub_agent import SubAgent
class YourAgent(SubAgent):
def __init__(self):
super().__init__("Your Agent Name")
def reason(self, input_data):
# Your reasoning logic
return {
"agent": self.name,
"analysis": "Your analysis",
"confidence": 0.85
}- Create new file in
agents/tools/your_tool.py - Implement function with proper error handling
- Register in
cognitive_agent.pytool selection logic
def your_tool(param1, param2):
"""Your tool description"""
try:
# Tool logic
return {"result": "success", "data": result}
except Exception as e:
return {"error": str(e)}# Standard build
docker build -t p-caba-ui .
# Multi-platform build (for ECS)
docker buildx build --platform linux/amd64 -t p-caba-ui . --load
# Push to ECR
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin <account>.dkr.ecr.us-east-1.amazonaws.com
docker tag p-caba-ui:latest <account>.dkr.ecr.us-east-1.amazonaws.com/p-caba-ui:latest
docker push <account>.dkr.ecr.us-east-1.amazonaws.com/p-caba-ui:latest- Cognitive Agent: 3.2 seconds (includes AgentCore action groups + FDA API)
- Emotional Agent: 2.8 seconds (Sentiment + Past Experience)
- Debate Phase: 1.5 seconds (Strands SDK multi-turn synthesis)
- Synthesizer: 2.1 seconds (Nova Micro final decision)
- Executor: 2.3 seconds (Lambda + SES + APIs)
- Total: ~12 seconds for comprehensive decision
- Claude 3.5 Sonnet (cognitive): $0.015
- Claude 3 Haiku (emotional): $0.008
- Amazon Titan Embeddings (RAG): $0.002
- Amazon Nova Micro (synthesis): $0.003
- Total: ~$0.03 per decision
- ECS Auto-scaling: 1-4 tasks based on CPU/memory
- Concurrent Users: 50+ with 4 tasks (tested)
- Knowledge Base: 100+ documents per domain (healthcare, business, legal)
- Memory Capacity: FAISS supports millions of vectors
Contributions are welcome! Here's how to get started:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow PEP 8 style guide for Python
- Add docstrings to all functions/classes
- Include tests for new features
- Update README.md with new capabilities
- AWS_MIGRATION.md - Full ECS deployment guide
- TESTING_GUIDE.md - Comprehensive testing instructions
- TOOL_INTEGRATION_COMPLETE.md - External tool setup
- LangGraph - Agent orchestration framework
- FAISS - Vector similarity search
- Streamlit - Python web framework for ML apps
This project is licensed under the MIT License - see the LICENSE file for details.
- AWS Bedrock Team for AgentCore SDK and Strands SDK
- Anthropic for Claude 3.5 Sonnet and Claude 3 Haiku models
- Amazon for Nova Micro and Titan Embeddings
- LangChain Community for LangGraph framework
- Streamlit for the amazing web framework
Sai Akhil Malepati
- π GitHub: @saiakhil2012
- π§ Email: saiakhil1995@gmail.com
- πΌ LinkedIn: Connect with me
- π Portfolio: View my work
β If you find this project useful, please consider giving it a star! β
Built with β€οΈ using AWS Bedrock, AgentCore SDK, Strands SDK, and Python




