A hierarchical multi-agent workflow system inspired by Michael Levin's work on morphogenetic competencies, designed for emerging technology research and under-discussed risk discovery.
This system implements a 4-tier hierarchical agent architecture with:
- Confidence-based decision making with strict policy enforcement
- Homeostasis loops for error detection and automatic escalation
- Multiscale memory (episodic, pattern, morphogenetic, cryptic)
- Goal-oriented coordination via JSON message envelopes
- Production-ready REST API and CLI interfaces
┌─────────────────────────────────────────────────────────────┐
│ TIER 1: Director │
│ (Planning, Error Correction, Escalation) │
└─────────────────────────────────────────────────────────────┘
│
┌─────────────────────┼─────────────────────┐
│ │ │
┌───────▼──────┐ ┌────────▼────────┐ ┌──────▼──────┐
│ Research │ │ Analysis │ │ Critique │
│ (Evidence) │ │ (Risks/Patterns)│ │ (Quality) │
└──────────────┘ └─────────────────┘ └─────────────┘
TIER 2: Specialist Agents
│ │ │
┌───────▼──────────────────────────────────────────────────┐
│ TIER 3: Executor Agents │
│ (fact_check, summarize, entity_extraction, etc.) │
└──────────────────────────────────────────────────────────┘
│
┌─────────────────────┴─────────────────────┐
│ TIER 4: RAG Agent │
│ (Semantic Search, Entity Extraction) │
└───────────────────────────────────────────┘
Click the Run button in Replit to start the FastAPI server automatically.
# Install dependencies
pip install -r requirements.txt
# Run the API server
uvicorn app.main:app --host 0.0.0.0 --port 8000
# Access the API
# - Swagger UI: http://localhost:8000/docs
# - Status Dashboard: http://localhost:8000/status# Run research objective from terminal
python cli.py "Research quantum dot displays and identify under-discussed risks"
# More examples
python cli.py "Analyze AI safety challenges in autonomous systems"
python cli.py "Investigate biosecurity risks in synthetic biology"Execute a research objective through the multi-agent workflow.
Request:
{
"objective": "Research emerging quantum computing technologies and risks"
}Response:
{
"objective": "Research emerging quantum computing technologies and risks",
"message_count": 42,
"final_confidence": 0.78,
"trace": [...]
}View live status dashboard with message trace visualization.
Health check endpoint.
# Run all tests
make test
# Or directly with pytest
pytest tests/ -v- test_envelope.py: Schema validation and confidence policy gates
- test_homeostasis.py: Stuck state detection and escalation after 2 cycles
- test_happy_path.py: Complete workflow integration test
Environment variables (see .env.example):
APP_NAME=mca-research-risk
DEBUG=true
RAG_ENABLED=true
HTTP_TIMEOUT=30
MAX_CYCLES=8
SESSION_SECRET=your-secret-here
All agent outputs include confidence scores ∈ [0,1]:
- ≥0.70: Proceed (note caveats)
- 0.40-0.69: Proceed only with verification plan
- <0.40: Refuse + list exact needs
Agents monitor their own progress:
- Track completion state across cycles
- Detect stuck states (no progress for ≥2 cycles)
- Automatically escalate to Director
- Trigger alternative approaches or resource requests
System alignment is enforced against these constant goals:
- Safety Alignment: Avoid harmful outputs
- Epistemic Rigor: Maintain high evidence standards
- Goal Persistence: Complete objectives despite obstacles
- Error Minimization: Detect and correct mistakes
- Cooperative Autonomy: Collaborate while maintaining independence
- Episodic: Recent event history (last 1000 events)
- Pattern: Learned problem-solving strategies
- Morphogenetic: Core alignment goals
- Cryptic: Emergent patterns and meta-insights
# Build
docker build -t mca-research-risk .
# Run
docker run -p 8000:8000 mca-research-riskTest with edge cases: vague objectives, conflicting requirements, missing data.
Measure ability to identify under-discussed risks not in training data.
Verify confidence scores correlate with actual accuracy.
Confirm workflow completes despite simulated agent failures.
Benchmark message throughput and MAX_CYCLES performance.
# Install dev dependencies
make install
# Format code
make format
# Lint
make lint
# Clean artifacts
make cleanAll inter-agent communication uses typed JSON envelopes:
MessageEnvelope(
message_type: "goal_directive | status_update | help_request | goal_complete | error_signal",
sender_agent: str,
recipient_agent: str,
priority: int (1-10),
timestamp: ISO-8601,
payload: {
goal_description: str,
success_criteria: List[str],
current_state: str,
confidence: float (0-1),
uncertainty_factors: List[str],
alternative_approaches: List[str],
resource_requirements: List[str],
expected_completion: str,
can_delegate: bool,
escalation_threshold: str,
notes: str # JSON-encoded artifacts
}
)Structured data passed in payload.notes:
- FactCheckResult: Claim verification with evidence
- SectionDraft: Research section with provenance
- HomeostasisReport: Error measurement and actions
Inspired by Michael Levin's work on:
- Multiscale competency in biological systems
- Goal-directed behavior in agent collectives
- Morphogenetic fields and pattern formation
MIT License - See LICENSE file for details.
- Fork the repository
- Create a feature branch
- Run tests:
make test - Submit a pull request
Built with: FastAPI • Pydantic • Python 3.11 • Rich • Pytest