# mspoulaei/multi-agent-hpo architecture

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

- Interactive diagram: https://gitdiagram.com/mspoulaei/multi-agent-hpo
- Repository: https://github.com/mspoulaei/multi-agent-hpo

## Overview

Multi-agent HPO runs repeated proposal, training, diagnosis, and research rounds for an image classifier. The CLI initializes the run and invokes the LangGraph workflow; that workflow coordinates two consultants, a supervisor, the executor, an analyzer, and a researcher. Training produces metrics and plots, while analysis and search inform the next proposal. The README documents several workflow capabilities not fully visible in the excerpts; edges for those are cited to it. Source excerpts do not expose every graph transition, so only documented or directly evidenced relationships are shown.

Main entry points: [`src/graph/hpo_graph.py`](https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/graph/hpo_graph.py) (HPO Workflow), [`src/executor/train.py`](https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/executor/train.py) (Training Loop), [`src/agents/models.py`](https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/agents/models.py) (LLM Client), [`main.py`](https://github.com/mspoulaei/multi-agent-hpo/blob/main/main.py) (Run CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Run Entry"]
  node_cli["Run CLI<br/>[main.py]"]
  node_seed["Seed Setup<br/>[seed.py]"]
end

subgraph group_coordination["HPO Coordination"]
  node_workflow["HPO Workflow<br/>[hpo_graph.py]"]
  node_state["Workflow State<br/>[state.py]"]
  node_prompt_library["Agent Prompts<br/>[prompts.py]"]
  node_consultants["Consultants A/B<br/>[hpo_graph.py]"]
  node_supervisor["Supervisor<br/>[hpo_graph.py]"]
  node_llm_client["LLM Client<br/>[models.py]"]
end

subgraph group_training["Model Training"]
  node_executor["Trial Executor<br/>[hpo_graph.py]"]
  node_data["Data Loaders<br/>[data.py]"]
  node_trainer["Training Loop<br/>[train.py]"]
  node_resnet["ResNet-9<br/>[resnet9.py]"]
  node_plotting["Training Plots<br/>[plotting.py]"]
  node_io["Artifact I/O<br/>[io.py]"]
end

subgraph group_research["Analysis Research"]
  node_metrics["Metrics Analysis<br/>[metrics.py]"]
  node_analyzer["LLM Diagnosis<br/>[hpo_graph.py]"]
  node_researcher["Research Agent<br/>[hpo_graph.py]"]
  node_search["Web Search<br/>[google_search.py]"]
end

node_user(("Operator"))
node_gemini_search{{"Gemini Search"}}
node_google_cse{{"Google CSE"}}
node_gemini_llm{{"Gemini LLM"}}

node_user -->|"starts run"| node_cli
node_cli -->|"sets seed"| node_seed
node_cli -->|"builds and invokes"| node_workflow
node_workflow -->|"uses state"| node_state
node_workflow -->|"formats prompts"| node_prompt_library
node_workflow -->|"dispatches proposals"| node_consultants
node_workflow -->|"dispatches merge"| node_supervisor
node_workflow -->|"dispatches trial"| node_executor
node_workflow -->|"runs diagnosis"| node_analyzer
node_workflow -->|"dispatches research"| node_researcher
node_consultants -->|"requests completion"| node_llm_client
node_supervisor -->|"requests completion"| node_llm_client
node_analyzer -->|"requests analysis"| node_llm_client
node_researcher -->|"requests suggestions"| node_llm_client
node_llm_client -.->|"calls API"| node_gemini_llm
node_executor -->|"runs training"| node_trainer
node_trainer -->|"loads batches"| node_data
node_trainer -->|"trains model"| node_resnet
node_trainer -->|"computes scores"| node_metrics
node_trainer -->|"saves plots"| node_plotting
node_trainer -->|"saves summary"| node_io
node_workflow -->|"analyzes trajectories"| node_metrics
node_researcher -->|"queries web"| node_search
node_search -->|"uses grounded search"| node_gemini_search
node_search -->|"uses fallback search"| node_google_cse
node_researcher -->|"returns hints"| node_consultants

click node_cli "https://github.com/mspoulaei/multi-agent-hpo/blob/main/main.py"
click node_workflow "https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/graph/hpo_graph.py"
click node_state "https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/graph/state.py"
click node_prompt_library "https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/agents/prompts.py"
click node_consultants "https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/graph/hpo_graph.py"
click node_supervisor "https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/graph/hpo_graph.py"
click node_llm_client "https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/agents/models.py"
click node_executor "https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/graph/hpo_graph.py"
click node_data "https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/executor/data.py"
click node_trainer "https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/executor/train.py"
click node_resnet "https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/executor/model/resnet9.py"
click node_metrics "https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/executor/metrics.py"
click node_plotting "https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/utils/plotting.py"
click node_io "https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/utils/io.py"
click node_analyzer "https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/graph/hpo_graph.py"
click node_researcher "https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/graph/hpo_graph.py"
click node_search "https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/tools/google_search.py"
click node_seed "https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/utils/seed.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_cli,node_seed toneBlue
class node_workflow,node_state,node_prompt_library,node_consultants,node_supervisor,node_llm_client toneAmber
class node_executor,node_data,node_trainer,node_resnet,node_plotting,node_io toneMint
class node_metrics,node_analyzer,node_researcher,node_search toneRose
class node_user,node_gemini_search,node_google_cse,node_gemini_llm toneIndigo
```

## Components

### Run Entry

- [Run CLI](https://github.com/mspoulaei/multi-agent-hpo/blob/main/main.py): `main.py`
- [Seed Setup](https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/utils/seed.py): `src/utils/seed.py`

### HPO Coordination

- [HPO Workflow](https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/graph/hpo_graph.py): `src/graph/hpo_graph.py`
- [Workflow State](https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/graph/state.py): `src/graph/state.py`
- [Agent Prompts](https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/agents/prompts.py): `src/agents/prompts.py`
- [Consultants A/B](https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/graph/hpo_graph.py): `src/graph/hpo_graph.py`
- [Supervisor](https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/graph/hpo_graph.py): `src/graph/hpo_graph.py`
- [LLM Client](https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/agents/models.py): `src/agents/models.py`

### Model Training

- [Trial Executor](https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/graph/hpo_graph.py): `src/graph/hpo_graph.py`
- [Data Loaders](https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/executor/data.py): `src/executor/data.py`
- [Training Loop](https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/executor/train.py): `src/executor/train.py`
- [ResNet-9](https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/executor/model/resnet9.py): `src/executor/model/resnet9.py`
- [Training Plots](https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/utils/plotting.py): `src/utils/plotting.py`
- [Artifact I/O](https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/utils/io.py): `src/utils/io.py`

### Analysis Research

- [Metrics Analysis](https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/executor/metrics.py): `src/executor/metrics.py`
- [LLM Diagnosis](https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/graph/hpo_graph.py): `src/graph/hpo_graph.py`
- [Research Agent](https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/graph/hpo_graph.py): `src/graph/hpo_graph.py`
- [Web Search](https://github.com/mspoulaei/multi-agent-hpo/blob/main/src/tools/google_search.py): `src/tools/google_search.py`

### Other components

- **Operator**
- **Gemini Search**
- **Google CSE**
- **Gemini LLM**

## Connections

- Operator → Run CLI: starts run (evidence: `README.md`)
- Run CLI → Seed Setup: sets seed (evidence: `main.py`)
- Run CLI → HPO Workflow: builds and invokes (evidence: `main.py`)
- HPO Workflow → Workflow State: uses state (evidence: `src/graph/hpo_graph.py`)
- HPO Workflow → Agent Prompts: formats prompts (evidence: `src/graph/hpo_graph.py`)
- HPO Workflow → Consultants A/B: dispatches proposals (evidence: `README.md`)
- HPO Workflow → Supervisor: dispatches merge (evidence: `README.md`)
- HPO Workflow → Trial Executor: dispatches trial (evidence: `README.md`)
- HPO Workflow → LLM Diagnosis: runs diagnosis (evidence: `README.md`)
- HPO Workflow → Research Agent: dispatches research (evidence: `README.md`)
- Consultants A/B → LLM Client: requests completion (evidence: `src/graph/hpo_graph.py`)
- Supervisor → LLM Client: requests completion (evidence: `src/graph/hpo_graph.py`)
- LLM Diagnosis → LLM Client: requests analysis (evidence: `src/graph/hpo_graph.py`)
- Research Agent → LLM Client: requests suggestions (evidence: `src/graph/hpo_graph.py`)
- LLM Client → Gemini LLM: calls API
- Trial Executor → Training Loop: runs training (evidence: `src/graph/hpo_graph.py`)
- Training Loop → Data Loaders: loads batches (evidence: `src/executor/train.py`)
- Training Loop → ResNet-9: trains model (evidence: `src/executor/train.py`)
- Training Loop → Metrics Analysis: computes scores (evidence: `src/executor/train.py`)
- Training Loop → Training Plots: saves plots (evidence: `src/executor/train.py`)
- Training Loop → Artifact I/O: saves summary (evidence: `src/executor/train.py`)
- HPO Workflow → Metrics Analysis: analyzes trajectories (evidence: `README.md`)
- Research Agent → Web Search: queries web (evidence: `src/graph/hpo_graph.py`)
- Web Search → Gemini Search: uses grounded search (evidence: `src/tools/google_search.py`)
- Web Search → Google CSE: uses fallback search (evidence: `src/tools/google_search.py`)
- Research Agent → Consultants A/B: returns hints (evidence: `README.md`)
