# dev-strzx9/agent architecture

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

- Interactive diagram: https://gitdiagram.com/dev-strzx9/agent
- Repository: https://github.com/dev-strzx9/agent

## Overview

This is a semiconductor MES query agent implemented as a node-based ReAct workflow. A user asks through the interactive CLI; extraction structures the request, repair conditionally fills missing identifiers and validates them, then the router selects equipment or lot lookups and reviews accumulated results until it sends the request to summarization. Lot lookups support parallel fan-out, and equipment results can supply lot IDs for a later router decision. The graph and shared state form the internal orchestration layer. The MES implementation shown is mock data; the README describes replacing it for a real system.

Main entry points: [`nodes/router/node.py`](https://github.com/dev-strzx9/agent/blob/main/nodes/router/node.py) (Action router), [`graph.py`](https://github.com/dev-strzx9/agent/blob/main/graph.py) (Graph orchestration), [`nodes/repair/node.py`](https://github.com/dev-strzx9/agent/blob/main/nodes/repair/node.py) (Identifier repair), [`nodes/fetch_lot/node.py`](https://github.com/dev-strzx9/agent/blob/main/nodes/fetch_lot/node.py) (Lot lookup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_cli["Interactive CLI<br/>[main.py]"]
end

subgraph group_pipeline["Query preparation"]
  node_extract["Query extraction<br/>[node.py]"]
  node_schemas["Validated query schemas<br/>[schemas.py]"]
  node_repair["Identifier repair<br/>[node.py]"]
end

subgraph group_react["ReAct workflow"]
  node_graph["Graph orchestration<br/>[graph.py]"]
  node_state["Shared agent state<br/>[state.py]"]
  node_router["Action router<br/>[node.py]"]
  node_equipment["Equipment lookup<br/>[node.py]"]
  node_lot["Lot lookup<br/>[node.py]"]
  node_summarize["Answer summarization<br/>[node.py]"]
end

subgraph group_services["Runtime services"]
  node_mes["Mock MES data<br/>[mock.py]"]
  node_llm_client["LLM client<br/>[llm_client.py]"]
  node_config["Runtime configuration<br/>[config.py]"]
end

node_user(("User"))
node_llm_service{{"OpenAI-compatible LLM API"}}

node_user -->|"asks"| node_cli
node_cli -->|"invokes"| node_graph
node_graph -->|"starts"| node_extract
node_graph -->|"dispatches"| node_repair
node_graph -->|"dispatches"| node_router
node_graph -->|"dispatches"| node_equipment
node_graph -->|"dispatches"| node_lot
node_graph -->|"dispatches"| node_summarize
node_extract -->|"passes queries"| node_repair
node_repair -->|"passes validated queries"| node_router
node_extract -->|"validates with"| node_schemas
node_extract -->|"requests extraction"| node_llm_client
node_repair -->|"validates with"| node_schemas
node_repair -->|"repairs with"| node_llm_client
node_repair -->|"checks identifiers"| node_mes
node_router -->|"requests decision"| node_llm_client
node_router -->|"selects lookup"| node_equipment
node_router -->|"selects lookup"| node_lot
node_router -->|"selects finish"| node_summarize
node_equipment -->|"reads equipment"| node_mes
node_lot -->|"reads lots"| node_mes
node_equipment -->|"returns results"| node_router
node_lot -->|"returns results"| node_router
node_summarize -->|"writes answer"| node_llm_client
node_summarize -->|"returns answer"| node_cli
node_llm_client -->|"calls API"| node_llm_service
node_llm_client -->|"loads settings"| node_config
node_lot -->|"loads fanout limit"| node_config
node_router -->|"loads turn limit"| node_config
node_extract -->|"reads and updates"| node_state
node_repair -->|"reads and updates"| node_state
node_router -->|"reads and updates"| node_state
node_equipment -->|"reads and updates"| node_state
node_lot -->|"reads and updates"| node_state
node_summarize -->|"reads and updates"| node_state

click node_cli "https://github.com/dev-strzx9/agent/blob/main/main.py"
click node_graph "https://github.com/dev-strzx9/agent/blob/main/graph.py"
click node_state "https://github.com/dev-strzx9/agent/blob/main/state.py"
click node_extract "https://github.com/dev-strzx9/agent/blob/main/nodes/extract/node.py"
click node_schemas "https://github.com/dev-strzx9/agent/blob/main/schemas.py"
click node_repair "https://github.com/dev-strzx9/agent/blob/main/nodes/repair/node.py"
click node_router "https://github.com/dev-strzx9/agent/blob/main/nodes/router/node.py"
click node_equipment "https://github.com/dev-strzx9/agent/blob/main/nodes/fetch_equipment/node.py"
click node_lot "https://github.com/dev-strzx9/agent/blob/main/nodes/fetch_lot/node.py"
click node_summarize "https://github.com/dev-strzx9/agent/blob/main/nodes/summarize/node.py"
click node_mes "https://github.com/dev-strzx9/agent/blob/main/mes/mock.py"
click node_llm_client "https://github.com/dev-strzx9/agent/blob/main/llm_client.py"
click node_config "https://github.com/dev-strzx9/agent/blob/main/config.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_user toneBlue
class node_extract,node_schemas,node_repair toneAmber
class node_graph,node_state,node_router,node_equipment,node_lot,node_summarize,node_llm_service toneMint
class node_mes,node_llm_client,node_config toneRose
```

## Components

### User interface

- [Interactive CLI](https://github.com/dev-strzx9/agent/blob/main/main.py): `main.py`

### Query preparation

- [Query extraction](https://github.com/dev-strzx9/agent/blob/main/nodes/extract/node.py): `nodes/extract/node.py`
- [Validated query schemas](https://github.com/dev-strzx9/agent/blob/main/schemas.py): `schemas.py`
- [Identifier repair](https://github.com/dev-strzx9/agent/blob/main/nodes/repair/node.py): `nodes/repair/node.py`

### ReAct workflow

- [Graph orchestration](https://github.com/dev-strzx9/agent/blob/main/graph.py): `graph.py`
- [Shared agent state](https://github.com/dev-strzx9/agent/blob/main/state.py): `state.py`
- [Action router](https://github.com/dev-strzx9/agent/blob/main/nodes/router/node.py): `nodes/router/node.py`
- [Equipment lookup](https://github.com/dev-strzx9/agent/blob/main/nodes/fetch_equipment/node.py): `nodes/fetch_equipment/node.py`
- [Lot lookup](https://github.com/dev-strzx9/agent/blob/main/nodes/fetch_lot/node.py): `nodes/fetch_lot/node.py`
- [Answer summarization](https://github.com/dev-strzx9/agent/blob/main/nodes/summarize/node.py): `nodes/summarize/node.py`

### Runtime services

- [Mock MES data](https://github.com/dev-strzx9/agent/blob/main/mes/mock.py): `mes/mock.py`
- [LLM client](https://github.com/dev-strzx9/agent/blob/main/llm_client.py): `llm_client.py`
- [Runtime configuration](https://github.com/dev-strzx9/agent/blob/main/config.py): `config.py`

### Other components

- **User**
- **OpenAI-compatible LLM API**

## Connections

- User → Interactive CLI: asks (evidence: `README.md`)
- Interactive CLI → Graph orchestration: invokes (evidence: `main.py`)
- Graph orchestration → Query extraction: starts (evidence: `graph.py`)
- Graph orchestration → Identifier repair: dispatches (evidence: `graph.py`)
- Graph orchestration → Action router: dispatches (evidence: `graph.py`)
- Graph orchestration → Equipment lookup: dispatches (evidence: `graph.py`)
- Graph orchestration → Lot lookup: dispatches (evidence: `graph.py`)
- Graph orchestration → Answer summarization: dispatches (evidence: `graph.py`)
- Query extraction → Identifier repair: passes queries
- Identifier repair → Action router: passes validated queries
- Query extraction → Validated query schemas: validates with (evidence: `nodes/extract/node.py`)
- Query extraction → LLM client: requests extraction (evidence: `nodes/extract/node.py`)
- Identifier repair → Validated query schemas: validates with (evidence: `nodes/repair/node.py`)
- Identifier repair → LLM client: repairs with (evidence: `nodes/repair/node.py`)
- Identifier repair → Mock MES data: checks identifiers (evidence: `nodes/repair/node.py`)
- Action router → LLM client: requests decision (evidence: `nodes/router/node.py`)
- Action router → Equipment lookup: selects lookup
- Action router → Lot lookup: selects lookup
- Action router → Answer summarization: selects finish
- Equipment lookup → Mock MES data: reads equipment (evidence: `nodes/fetch_equipment/node.py`)
- Lot lookup → Mock MES data: reads lots (evidence: `nodes/fetch_lot/node.py`)
- Equipment lookup → Action router: returns results
- Lot lookup → Action router: returns results
- Answer summarization → LLM client: writes answer (evidence: `nodes/summarize/node.py`)
- Answer summarization → Interactive CLI: returns answer (evidence: `main.py`)
- LLM client → OpenAI-compatible LLM API: calls API (evidence: `llm_client.py`)
- LLM client → Runtime configuration: loads settings (evidence: `llm_client.py`)
- Lot lookup → Runtime configuration: loads fanout limit (evidence: `nodes/fetch_lot/node.py`)
- Action router → Runtime configuration: loads turn limit (evidence: `nodes/router/node.py`)
- Query extraction → Shared agent state: reads and updates (evidence: `nodes/extract/node.py`)
- Identifier repair → Shared agent state: reads and updates (evidence: `nodes/repair/node.py`)
- Action router → Shared agent state: reads and updates (evidence: `nodes/router/node.py`)
- Equipment lookup → Shared agent state: reads and updates (evidence: `nodes/fetch_equipment/node.py`)
- Lot lookup → Shared agent state: reads and updates (evidence: `nodes/fetch_lot/node.py`)
- Answer summarization → Shared agent state: reads and updates (evidence: `nodes/summarize/node.py`)
