Spec2Sim-Agent

AI-Powered Multi-Agent System for Automated Specification Verification

Transform natural language system specifications into verified simulation code in seconds—automatically.

The Problem

Manual specification translation is error-prone, time-consuming, and repetitive

Manual Translation Burden

Converting ambiguous natural language text into rigorous state machine logic requires significant engineering effort.

Boilerplate Code

Writing repetitive simulation scaffolding for every requirement slows down development cycles.

Verification Gap

No automated way to verify that generated code matches the original specification intent.

Iteration Overhead

Hours spent debugging and validating correctness for each specification change.

Result: Manual implementation requires writing boilerplate code, debugging state machines, and validating behavior—a time-consuming and error-prone process.

Interactive Demo

See how Spec2Sim-Agent transforms natural language into verified simulation code

Input: Specification


                

Output 1: State Diagram (JSON)


                

Output 2: Simulation Code


                

Output 3: Execution Logs


                

Multi-Agent Architecture

Three specialized agents working together with intelligent self-healing

Agent Pipeline

1

Analyst Agent

Extracts structured JSON specifications from natural language requirements

2

Architect Agent

Generates complete SimPy simulation code with state machines and test scenarios

3

Verifier Agent

Executes code in MCP sandbox and validates against original specification

Self-Healing Loop

Automatic Error Detection

When verification fails, the Verifier analyzes execution logs and identifies the root cause of errors.

Intelligent Feedback

Error details and execution traces are sent back to the Architect with specific suggestions for fixes.

Code Regeneration

The Architect uses the feedback to regenerate corrected code, learning from previous mistakes.

Retry Decision

AI determines if the error is fixable (retry) or indicates a fundamental specification issue (abort).

Key Innovation: This feedback loop eliminates manual debugging. Unlike traditional code generation that fails silently, our system automatically corrects errors through intelligent agent collaboration.

Dual-Process Architecture

Process 1: Agent Orchestration

Main process running three AI agents (Analyst, Architect, Verifier) coordinating workflow and managing the self-healing loop.

Process 2: Simulation Execution

Subprocess running MCP server that executes SimPy code in an isolated sandbox and captures all logs.

Communication: MCP Protocol

Processes communicate via Model Context Protocol over stdio, ensuring secure and standardized code execution.

Benefits: Security & Isolation

Simulation crashes don't affect agents. Potentially unsafe code runs in a separate isolated environment.

Technology Stack

AI Framework

Google ADK with Gemini 2.5 Flash Lite for intelligent agent orchestration

Simulation Engine

SimPy for discrete-event simulation and state machine modeling

Secure Execution

Model Context Protocol (MCP) for sandboxed code execution

User Interface

Streamlit for real-time visualization and interactive demonstrations

Performance Results

Tested on 3 industrial control systems with 100% success rate

100%
Success Rate
41.39s
Avg Time
~2min
Completion
3/3
Demos Pass

Detailed Results

Demo Time Status Code Lines Complexity
Traffic Light 17.36s PASS 113 Time-driven FSM
BMS Precharge 79.89s PASS 205 Voltage monitoring
Elevator Control 26.91s PASS 136 Multi-floor logic
Measured Performance: Average completion time of 41.39 seconds with 100% verified correctness across all test cases.

Cloud Deployment

Successfully deployed to Google Cloud Vertex AI Agent Engine

Deployment Architecture

Local Version

Full Functionality: Dual-process architecture with complete SimPy execution via MCP server. All agents and self-healing loop fully operational.

Cloud Version

Demonstration: Single-process deployment showcasing multi-agent conversation flow and explaining system architecture capabilities.

Agent Engine Limitation

Constraint: Cannot launch subprocesses via subprocess.Popen(), preventing MCP server execution in the default container environment.

Production Options

Solutions: Deploy to Cloud Run (with process management), GKE (Kubernetes), or separate services for full functionality.

Note: The cloud deployment demonstrates the multi-agent architecture concept. Full simulation capabilities with the self-healing loop remain available in the local version.