AgentFlow is a multi-agent collaborative framework that orchestrates specialized AI agents to solve complex engineering analysis problems. It demonstrates long-chain reasoning and multi-agent collaboration — where a Planner decomposes problems, an Analyst performs mathematical modeling, a Coder generates simulation code, and a Reviewer validates results, all coordinated through an intelligent Orchestrator.
┌─────────────────────────────────────────────────────────┐
│ Orchestrator Agent │
│ (Workflow coordination & state management) │
└──────┬──────────┬──────────┬──────────┬─────────────────┘
│ │ │ │
▼ ▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
│ Planner │ │ Analyst │ │ Coder │ │ Reviewer │
│ Agent │ │ Agent │ │ Agent │ │ Agent │
├──────────┤ ├──────────┤ ├──────────┤ ├──────────┤
│ Problem │ │ Math & │ │ Code │ │ Result │
│ Decompo- │ │ Physics │ │ Genera- │ │ Validation│
│ sition │ │ Modeling │ │ tion │ │ & Refine │
└──────────┘ └──────────┘ └──────────┘ └──────────┘
│ │ │ │
└──────────┴──────────┴──────────┘
│
▼
┌─────────────────┐
│ Shared Context │
│ & Memory Store │
└─────────────────┘
- Long-chain reasoning: Problems are decomposed into 5-10+ sequential reasoning steps, with each agent building on the previous agent's output
- Multi-agent collaboration: 5 specialized agents communicate through a structured message-passing protocol
- Iterative refinement: The Reviewer agent can trigger re-analysis loops when results don't meet quality thresholds
- Real engineering applications: Built-in examples for beam deflection analysis, truss structure FEA, and thermal stress simulation
- Token-efficient orchestration: Designed to simulate high-volume LLM interactions — each full workflow consumes 50K-200K tokens
agentflow/
├── src/agentflow/
│ ├── __init__.py
│ ├── core/
│ │ ├── __init__.py
│ │ ├── orchestrator.py # Main workflow coordinator
│ │ ├── context.py # Shared state & memory
│ │ └── messaging.py # Inter-agent communication protocol
│ ├── agents/
│ │ ├── __init__.py
│ │ ├── base.py # Base agent class
│ │ ├── planner.py # Problem decomposition agent
│ │ ├── analyst.py # Math/physics modeling agent
│ │ ├── coder.py # Simulation code generation agent
│ │ └── reviewer.py # Quality validation agent
│ ├── examples/
│ │ ├── __init__.py
│ │ ├── beam_deflection.py # Cantilever beam analysis
│ │ ├── truss_fea.py # Truss structure FEA
│ │ └── thermal_stress.py # Thermal-structural coupling
│ └── utils/
│ ├── __init__.py
│ └── reporting.py # Result visualization & reporting
├── tests/
├── results/ # Simulation outputs
├── requirements.txt
└── README.md
# Install dependencies
pip install -r requirements.txt
# Run a beam deflection analysis (demonstrates full multi-agent workflow)
python -m agentflow.examples.beam_deflection
# Run truss structure FEA with iterative refinement
python -m agentflow.examples.truss_fea
# Run thermal-structural coupling analysis
python -m agentflow.examples.thermal_stressThe system receives a natural language description: "Analyze a 2m steel cantilever beam under 5kN tip load, determine max deflection and stress"
- Planner Agent → Decomposes into 7 sub-tasks: geometry modeling, material properties, loading analysis, analytical solution, FEA discretization, numerical solution, validation
- Analyst Agent → Computes analytical solution: δ_max = PL³/(3EI), σ_max = My/I
- Coder Agent → Generates 150+ lines of Python FEA code with mesh generation, stiffness matrix assembly, and solver
- Reviewer Agent → Validates FEA vs analytical results (error < 2%), checks mesh convergence
- Orchestrator → Compiles comprehensive engineering report with visualizations
Token consumption per run: ~85,000 tokens (demonstrating heavy AI usage)
This framework is designed for engineering scenarios requiring complex multi-step AI reasoning:
- Structural analysis & FEA simulation
- Thermal-mechanical coupling problems
- Fluid dynamics parameter studies
- Multi-physics optimization workflows
- Automated engineering report generation
AgentFlow is intentionally designed to stress-test LLM capabilities:
- Context management: Shared state across 5+ agents requires robust context handling
- Long-form reasoning: Each workflow involves 5-10 sequential reasoning steps
- Code generation quality: Agents must produce correct, runnable scientific Python code
- Self-correction: The Reviewer agent identifies errors and triggers re-generation loops
- Domain expertise: Requires cross-disciplinary knowledge (mechanics + numerical methods + programming)
MIT License — feel free to use, modify, and distribute.