Skip to content

Harsh-Sharma29/Devins-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Devin's Younger Brother

Autonomous AI Software Engineer β€” An enterprise-grade LangGraph pipeline that autonomously writes, executes, and debugs Python code inside an isolated Docker sandbox, with multi-model LLM failover.


Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     Streamlit Dashboard                      β”‚
β”‚          (app.py β€” Control Center + Live Console)            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚
                         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚               LangGraph State Machine                        β”‚
β”‚                  (src/core/graph.py)                          β”‚
β”‚                                                              β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚   β”‚ Planner  │──▸│  Coder   │──▸│ Terminal  │──▸│Debugger β”‚ β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β”‚
β”‚                                      β”‚               β”‚      β”‚
β”‚                                      β”‚   ◂────────── β”˜      β”‚
β”‚                                      β”‚  (repair loop,       β”‚
β”‚                                      β”‚   capped at 5)       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                       β”‚
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚   Docker Sandbox            β”‚
                         β”‚   (python:3.11-slim)        β”‚
                         β”‚   Ephemeral, read-only      β”‚
                         β”‚   10s execution timeout     β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Agent Pipeline

Stage Role Implementation
Planner Proposes target artifact and augments the user prompt src/core/graph.py
Coder Generates Python via LLM, sanitizes markdown fences, writes to disk src/agents/coder.py
Terminal Executes code in an ephemeral Docker container with 10s timeout src/agents/terminal.py
Debugger Analyzes errors, rewrites code, and re-runs (max 5 attempts) src/agents/debugger.py

Multi-Model LLM Failover

The system uses a two-tier LLM strategy implemented in src/core/llm_fallback.py:

  1. Primary: Google Gemini 2.5 Flash via ChatGoogleGenerativeAI
  2. Fallback: Meta Llama-3-8B-Instruct via ChatHuggingFace (triggered on 429 / RESOURCE_EXHAUSTED / 503)

A graceful Visual Portfolio Simulation fallback activates automatically if all backends are unavailable, ensuring the dashboard always renders a complete demonstration.


Prerequisites

  • Python 3.9+
  • Docker Desktop running (required for sandboxed code execution)
  • API keys configured in .env:
    GEMINI_API_KEY=your_gemini_api_key
    HUGGINGFACEHUB_API_TOKEN=your_hf_token

Quick Start

# 1. Clone the repository
git clone https://github.com/Harsh-Sharma29/Devin-s.git
cd Devin-s

# 2. Install pinned dependencies
pip install -r requirements.txt

# 3. Configure environment variables
cp .env.example .env
# Edit .env with your API keys

# 4. Launch the dashboard
python -m streamlit run app.py

The dashboard opens at http://localhost:8501.


Project Structure

β”œβ”€β”€ app.py                        # Streamlit dashboard entry point
β”œβ”€β”€ requirements.txt              # Pinned production dependencies
β”œβ”€β”€ .env                          # API keys (gitignored)
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”œβ”€β”€ graph.py              # LangGraph state machine & routing
β”‚   β”‚   β”œβ”€β”€ llm_fallback.py       # Multi-model LLM wrapper with failover
β”‚   β”‚   β”œβ”€β”€ config.py             # Configuration constants
β”‚   β”‚   β”œβ”€β”€ logger.py             # Logging configuration
β”‚   β”‚   └── prompts.py            # System prompt templates
β”‚   β”œβ”€β”€ agents/
β”‚   β”‚   β”œβ”€β”€ coder.py              # Code generation agent
β”‚   β”‚   β”œβ”€β”€ debugger.py           # Autonomous repair agent
β”‚   β”‚   β”œβ”€β”€ terminal.py           # Docker sandbox execution agent
β”‚   β”‚   └── planner.py            # Task planning agent
β”‚   └── tools/
β”‚       └── file_ops.py           # File I/O & Docker execution helpers
β”œβ”€β”€ Dockerfile                    # Container build config
β”œβ”€β”€ docker-compose.yml            # Multi-service orchestration
└── tests/                        # Test suite

Key Design Decisions

  • Python 3.9 Compatibility: A global importlib.metadata.packages_distributions monkey-patch in app.py isolates dependency conflicts from google-auth / langchain-core on older runtimes.
  • Immediate Termination Routing: The LangGraph route_from_terminal function returns "END" immediately when detected_errors is empty or is_verified is True, preventing unnecessary recursion loops.
  • Dual State Access: All agent nodes support both Pydantic model objects and raw dictionaries for maximum compatibility across LangGraph versions.
  • Session State Hygiene: On each pipeline execution, st.session_state buffers are fully reset before invocation to prevent stale error displays.

License

MIT

About

πŸ€– Autonomous AI Software Engineer using a LangGraph state machine to write, execute, and self-debug Python code inside an isolated Docker sandbox with multi-model LLM failover.

Topics

Resources

Stars

Watchers

Forks

Contributors