# woooodyy/agentgym architecture

> Architecture diagram of the GitHub repository woooodyy/agentgym, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/woooodyy/agentgym
- Repository: https://github.com/woooodyy/agentgym

## Overview

- Controller / Agent Manager: Represented by the “agentenv/agentenv/controller” package and core module (which includes agent, environment, task, and utility functions). This is the central hub that evaluates agents, connects to various environment servers, collects data, and performs training.
- Environment Services: Show the multiple environment implementations. Each “agentenv-...” folder (e.g., agentenv-webshop, agentenv-webarena, agentenv-alfworld, etc.) provides a standardized HTTP API with endpoints such as /createEnv, /observation, /available_actions, /step, and /reset. Each such environment server should be drawn as an independent microservice or container.
- EnvClients: These are the client-side facades that wrap the HTTP communication with environment servers so that the AgentController can call them in a uniform manner.
- Training and Evaluation Modules: Separate components for training (AgentEvol, behavioral cloning trainers, dpo trainers) and evaluation—this includes benchmark pipelines that use AgentEval and data collection from AgentTraj.
- Utility and Logging Services: Include the utility modules (dispersed under utils/ directories), logging, and distributed evaluation components.

##### Relationships and Interactions
- Data flow from the controller to “Training Modules” (trainer components in agentenv/agentenv/trainer) as well as the data flow toward “Benchmark Modules” that interact with external datasets (AgentEval, AgentTraj).
- That utilities, logging, and error handling modules “support” both the agent controller and environment handlers.

##### Architectural Patterns
- Microservice Architecture: The environments being separate services (each packaged as its own “agentenv-*” module) demonstrate a microservice or modular architecture.
- API-centric Communication: Emphasize the uniform interface (HTTP APIs such as /step, /reset, etc.) that governs interactions between agents (via EnvClients) and the different environments.
- Separation of Concerns: Clearly separate the domains—environment simulation, agent control, training, evaluation, data collection, and utility functions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Main Components
    AController["Agent Controller"]:::controller
    EnvClients["EnvClients (HTTP Wrappers)"]:::client

    %% Environment Services Subgraph
    subgraph "Environment Services"
        Alfworld["ALFWorld Server"]:::envservice
        BabyAI["BabyAI Server"]:::envservice
        LMrlGym["LMrlGym Server"]:::envservice
        SciWorld["SciWorld Server"]:::envservice
        SQLGym["SQLGym Server"]:::envservice
        TextCraft["TextCraft Server"]:::envservice
        WebArena["WebArena Server"]:::envservice
        WebShop["WebShop Server"]:::envservice
    end

    %% Training & Evaluation Modules Subgraph
    subgraph "Training & Evaluation"
        AgentEvol["AgentEvol Trainer"]:::trainer
        BCTrainer["Behavioral Cloning Trainer"]:::trainer
        DistributedEvaluator["Distributed Evaluator"]:::evaluator
        AgentEval["AgentEval (Benchmark)"]:::external
        AgentTraj["AgentTraj (Trajectory Data)"]:::external
    end

    %% Utility Modules Subgraph
    subgraph "Utilities"
        ControllerUtilities["Controller Utilities"]:::utility
        GeneralUtilities["General Utilities"]:::utility
    end

    %% Connections - Controller and Clients
    AController -->|"HTTP_API: createEnv,observation,step,reset"| EnvClients
    EnvClients -->|"HTTP_request"| Alfworld
    EnvClients -->|"HTTP_request"| BabyAI
    EnvClients -->|"HTTP_request"| LMrlGym
    EnvClients -->|"HTTP_request"| SciWorld
    EnvClients -->|"HTTP_request"| SQLGym
    EnvClients -->|"HTTP_request"| TextCraft
    EnvClients -->|"HTTP_request"| WebArena
    EnvClients -->|"HTTP_request"| WebShop

    %% Responses from Environment Services back to EnvClients
    Alfworld -->|"HTTP_response"| EnvClients
    BabyAI -->|"HTTP_response"| EnvClients
    LMrlGym -->|"HTTP_response"| EnvClients
    SciWorld -->|"HTTP_response"| EnvClients
    SQLGym -->|"HTTP_response"| EnvClients
    TextCraft -->|"HTTP_response"| EnvClients
    WebArena -->|"HTTP_response"| EnvClients
    WebShop -->|"HTTP_response"| EnvClients

    EnvClients -->|"aggregates_data"| AController

    %% Training & Evaluation Data Flow
    AController -->|"triggers_training"| AgentEvol
    AController -->|"triggers_training"| BCTrainer
    AgentEval -->|"benchmark_data"| DistributedEvaluator
    AgentTraj -->|"trajectory_data"| DistributedEvaluator
    DistributedEvaluator -->|"evaluation_results"| AController

    %% Utilities support
    ControllerUtilities -->|"supports"| AController
    GeneralUtilities -->|"supports"| AController

    %% Click Events
    click AController "https://github.com/woooodyy/agentgym/tree/main/agentenv/agentenv/controller"
    click EnvClients "https://github.com/woooodyy/agentgym/tree/main/agentenv/agentenv/envs"
    click Alfworld "https://github.com/woooodyy/agentgym/blob/main/agentenv-alfworld/agentenv_alfworld/server.py"
    click BabyAI "https://github.com/woooodyy/agentgym/blob/main/agentenv-babyai/agentenv_babyai/server.py"
    click LMrlGym "https://github.com/woooodyy/agentgym/blob/main/agentenv-lmrlgym/agentenv_lmrlgym/server.py"
    click SciWorld "https://github.com/woooodyy/agentgym/blob/main/agentenv-sciworld/agentenv_sciworld/server.py"
    click SQLGym "https://github.com/woooodyy/agentgym/blob/main/agentenv-sqlgym/agentenv_sqlgym/server.py"
    click TextCraft "https://github.com/woooodyy/agentgym/blob/main/agentenv-textcraft/agentenv_textcraft/server.py"
    click WebArena "https://github.com/woooodyy/agentgym/blob/main/agentenv-webarena/agentenv_webarena/server.py"
    click WebShop "https://github.com/woooodyy/agentgym/blob/main/agentenv-webshop/agentenv_webshop/server.py"
    click AgentEvol "https://github.com/woooodyy/agentgym/blob/main/agentenv/agentenv/trainer/agentevol_trainer.py"
    click BCTrainer "https://github.com/woooodyy/agentgym/blob/main/agentenv/agentenv/trainer/bc_trainer.py"
    click DistributedEvaluator "https://github.com/woooodyy/agentgym/blob/main/agentenv/agentenv/trainer/distributed_evaluator.py"
    click ControllerUtilities "https://github.com/woooodyy/agentgym/blob/main/agentenv/agentenv/controller/utils.py"
    click GeneralUtilities "https://github.com/woooodyy/agentgym/tree/main/agentenv/utils"

    %% Styling
    classDef controller fill:#ffcccc,stroke:#cc0000,stroke-width:2px;
    classDef client fill:#ffe6cc,stroke:#ff6600,stroke-width:2px;
    classDef envservice fill:#ccffcc,stroke:#339933,stroke-width:2px;
    classDef trainer fill:#cce5ff,stroke:#003399,stroke-width:2px;
    classDef evaluator fill:#e6ccff,stroke:#6600cc,stroke-width:2px;
    classDef external fill:#ffffcc,stroke:#999900,stroke-width:2px;
    classDef utility fill:#d9d9d9,stroke:#666666,stroke-width:2px;
```
