# ajamshid2000/agent-smith architecture

> Architecture diagram of the GitHub repository ajamshid2000/agent-smith, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ajamshid2000/agent-smith
- Repository: https://github.com/ajamshid2000/agent-smith

## Overview

Agent Smith solves MBPP function-writing tasks and SWE-bench repository issues through a Thought→Code→Observation agent loop, returning a function or patch with execution metrics. The SWE-bench runner prepares a Docker task environment and exposes repository operations through MCP; MBPP uses benchmark tools for function-level execution. The separate Moulinette CLI dumps tasks and validates solutions for both benchmarks, including metrics checks. Edges reflect the README and shown/indexed source references; unsampled wiring is omitted or marked unverified.

Main entry points: [`agent_smith/loop.py`](https://github.com/ajamshid2000/agent-smith/blob/main/agent_smith/loop.py) (Reasoning loop), [`agent_swebench.py`](https://github.com/ajamshid2000/agent-smith/blob/main/agent_swebench.py) (SWE-bench runner), [`moulinette/moulinette/__main__.py`](https://github.com/ajamshid2000/agent-smith/blob/main/moulinette/moulinette/__main__.py) (Evaluation CLI), [`agent_mbpp.py`](https://github.com/ajamshid2000/agent-smith/blob/main/agent_mbpp.py) (MBPP runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_agent["Agent runtime"]
  node_loop["Reasoning loop<br/>[loop.py]"]
  node_extract["Response extraction<br/>[extract.py]"]
  node_provider["LLM provider<br/>[providers.py]"]
  node_agent_models["Agent data models<br/>[models.py]"]
end

subgraph group_tools["Sandbox and tools"]
  node_sandbox["Code sandbox<br/>[sandbox.py]"]
  node_mcp_client["MCP client<br/>[mcp.py]"]
  node_mbpp_tools["MBPP tools<br/>[mcp_tools_mbpp.py]"]
  node_swe_tools["SWE-bench tools"]
  node_docker["Task Docker container"]
end

subgraph group_bench["Benchmark runners"]
  node_mbpp_runner["MBPP runner<br/>[agent_mbpp.py]"]
  node_swe_runner["SWE-bench runner<br/>[agent_swebench.py]"]
end

subgraph group_eval["Moulinette evaluation"]
  node_moulinette_cli["Evaluation CLI<br/>[__main__.py]"]
  node_moulinette_models["Evaluation models<br/>[models.py]"]
  node_public_models["Solution contract<br/>[models_public.py]"]
  node_mbpp_interact["MBPP evaluator<br/>[interact.py]"]
  node_swe_interact["SWE-bench evaluator<br/>[interact.py]"]
end

node_user(("Benchmark user"))
node_model_api{{"Compatible model API"}}
node_docker_eval["Evaluation containers"]

node_user -->|"starts task"| node_mbpp_runner
node_user -->|"starts task"| node_swe_runner
node_mbpp_runner -->|"runs loop"| node_loop
node_swe_runner -->|"runs loop"| node_loop
node_loop -.->|"requests completions"| node_provider
node_provider -->|"sends requests"| node_model_api
node_loop -->|"executes code"| node_sandbox
node_loop -.->|"uses extraction"| node_extract
node_loop -.->|"records metrics"| node_agent_models
node_sandbox -->|"proxies tool calls"| node_mcp_client
node_swe_runner -->|"discovers tools"| node_mcp_client
node_mbpp_runner -.->|"configures tools"| node_mbpp_tools
node_swe_runner -->|"routes operations"| node_swe_tools
node_swe_runner -->|"starts task image"| node_docker
node_swe_tools -->|"operates in container"| node_docker
node_user -->|"requests evaluation"| node_moulinette_cli
node_moulinette_cli -->|"loads models"| node_moulinette_models
node_moulinette_models -->|"extends contract"| node_public_models
node_moulinette_cli -->|"validates MBPP"| node_mbpp_interact
node_moulinette_cli -->|"validates patches"| node_swe_interact
node_swe_interact -->|"evaluates patch"| node_docker_eval

click node_mbpp_runner "https://github.com/ajamshid2000/agent-smith/blob/main/agent_mbpp.py"
click node_swe_runner "https://github.com/ajamshid2000/agent-smith/blob/main/agent_swebench.py"
click node_loop "https://github.com/ajamshid2000/agent-smith/blob/main/agent_smith/loop.py"
click node_extract "https://github.com/ajamshid2000/agent-smith/blob/main/agent_smith/extract.py"
click node_provider "https://github.com/ajamshid2000/agent-smith/blob/main/agent_smith/providers.py"
click node_agent_models "https://github.com/ajamshid2000/agent-smith/blob/main/agent_smith/models.py"
click node_sandbox "https://github.com/ajamshid2000/agent-smith/blob/main/agent_smith/sandbox.py"
click node_mcp_client "https://github.com/ajamshid2000/agent-smith/blob/main/agent_smith/mcp.py"
click node_mbpp_tools "https://github.com/ajamshid2000/agent-smith/blob/main/mcp_tools_mbpp.py"
click node_swe_tools "https://github.com/ajamshid2000/agent-smith/blob/main/mcp_tools_swebench.py"
click node_moulinette_cli "https://github.com/ajamshid2000/agent-smith/blob/main/moulinette/moulinette/__main__.py"
click node_moulinette_models "https://github.com/ajamshid2000/agent-smith/blob/main/moulinette/moulinette/models.py"
click node_public_models "https://github.com/ajamshid2000/agent-smith/blob/main/moulinette/models_public.py"
click node_mbpp_interact "https://github.com/ajamshid2000/agent-smith/blob/main/moulinette/moulinette/mbpp/interact.py"
click node_swe_interact "https://github.com/ajamshid2000/agent-smith/blob/main/moulinette/moulinette/swebench/interact.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_loop,node_extract,node_provider,node_agent_models,node_user toneBlue
class node_sandbox,node_mcp_client,node_mbpp_tools,node_swe_tools,node_docker toneAmber
class node_mbpp_runner,node_swe_runner,node_model_api toneMint
class node_moulinette_cli,node_moulinette_models,node_public_models,node_mbpp_interact,node_swe_interact toneRose
class node_docker_eval toneIndigo
```

## Components

### Agent runtime

- [Reasoning loop](https://github.com/ajamshid2000/agent-smith/blob/main/agent_smith/loop.py): `agent_smith/loop.py`
- [Response extraction](https://github.com/ajamshid2000/agent-smith/blob/main/agent_smith/extract.py): `agent_smith/extract.py`
- [LLM provider](https://github.com/ajamshid2000/agent-smith/blob/main/agent_smith/providers.py): `agent_smith/providers.py`
- [Agent data models](https://github.com/ajamshid2000/agent-smith/blob/main/agent_smith/models.py): `agent_smith/models.py`

### Sandbox and tools

- [Code sandbox](https://github.com/ajamshid2000/agent-smith/blob/main/agent_smith/sandbox.py): `agent_smith/sandbox.py`
- [MCP client](https://github.com/ajamshid2000/agent-smith/blob/main/agent_smith/mcp.py): `agent_smith/mcp.py`
- [MBPP tools](https://github.com/ajamshid2000/agent-smith/blob/main/mcp_tools_mbpp.py): `mcp_tools_mbpp.py`
- [SWE-bench tools](https://github.com/ajamshid2000/agent-smith/blob/main/mcp_tools_swebench.py): `mcp_tools_swebench.py`
- **Task Docker container**

### Benchmark runners

- [MBPP runner](https://github.com/ajamshid2000/agent-smith/blob/main/agent_mbpp.py): `agent_mbpp.py`
- [SWE-bench runner](https://github.com/ajamshid2000/agent-smith/blob/main/agent_swebench.py): `agent_swebench.py`

### Moulinette evaluation

- [Evaluation CLI](https://github.com/ajamshid2000/agent-smith/blob/main/moulinette/moulinette/__main__.py): `moulinette/moulinette/__main__.py`
- [Evaluation models](https://github.com/ajamshid2000/agent-smith/blob/main/moulinette/moulinette/models.py): `moulinette/moulinette/models.py`
- [Solution contract](https://github.com/ajamshid2000/agent-smith/blob/main/moulinette/models_public.py): `moulinette/models_public.py`
- [MBPP evaluator](https://github.com/ajamshid2000/agent-smith/blob/main/moulinette/moulinette/mbpp/interact.py): `moulinette/moulinette/mbpp/interact.py`
- [SWE-bench evaluator](https://github.com/ajamshid2000/agent-smith/blob/main/moulinette/moulinette/swebench/interact.py): `moulinette/moulinette/swebench/interact.py`

### Other components

- **Benchmark user**
- **Compatible model API**
- **Evaluation containers**

## Connections

- Benchmark user → MBPP runner: starts task (evidence: `README.md`)
- Benchmark user → SWE-bench runner: starts task (evidence: `README.md`)
- MBPP runner → Reasoning loop: runs loop (evidence: `agent_mbpp.py`)
- SWE-bench runner → Reasoning loop: runs loop (evidence: `agent_swebench.py`)
- Reasoning loop → LLM provider: requests completions (evidence: `agent_smith/loop.py`)
- LLM provider → Compatible model API: sends requests (evidence: `agent_smith/providers.py`)
- Reasoning loop → Code sandbox: executes code (evidence: `agent_smith/loop.py`)
- Reasoning loop → Response extraction: uses extraction (evidence: `agent_smith/loop.py`)
- Reasoning loop → Agent data models: records metrics (evidence: `agent_smith/loop.py`)
- Code sandbox → MCP client: proxies tool calls (evidence: `agent_smith/sandbox.py`)
- SWE-bench runner → MCP client: discovers tools (evidence: `agent_swebench.py`)
- MBPP runner → MBPP tools: configures tools
- SWE-bench runner → SWE-bench tools: routes operations (evidence: `README.md`)
- SWE-bench runner → Task Docker container: starts task image (evidence: `agent_swebench.py`)
- SWE-bench tools → Task Docker container: operates in container (evidence: `README.md`)
- Benchmark user → Evaluation CLI: requests evaluation (evidence: `README.md`)
- Evaluation CLI → Evaluation models: loads models (evidence: `moulinette/moulinette/__main__.py`)
- Evaluation models → Solution contract: extends contract (evidence: `moulinette/moulinette/models.py`)
- Evaluation CLI → MBPP evaluator: validates MBPP (evidence: `moulinette/moulinette/__main__.py`)
- Evaluation CLI → SWE-bench evaluator: validates patches (evidence: `moulinette/moulinette/__main__.py`)
- SWE-bench evaluator → Evaluation containers: evaluates patch
