# thudm/agentbench architecture

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

- Interactive diagram: https://gitdiagram.com/thudm/agentbench
- Repository: https://github.com/thudm/agentbench

## Overview

##### Main Components
- Client Components:
- The src/client directory includes the agent implementation (agent.py), API client modules, and test drivers (agent_test.py). This is where the agents (e.g., OpenAI chat agent, fastchat client, HTTP agents) are configured and initiated.
- Task Server & Orchestration:
- The src/server directory comprises a task controller (task_controller.py), workers (task_worker.py), and task definitions under src/server/tasks. Each task (e.g., alfworld, avalon, card_game, dbbench, knowledgegraph, ltp, mind2web, os_interaction, webshop) is an independent module with its own logic, agents, configurations, prompts, and utilities.
- Configurations & Data:
- The configs folder provides YAML configurations for agents, task assignments, and starting tasks. Data files are organized in the data directory for each specific task/environment.
- Supporting Scripts & Utilities:
- The assigner (src/assigner.py) is used to push tasks.
- Utility modules (src/utils and src/typings) add helper functionalities and definitions.
- External Dependencies & Docker:
- The README and data/os_interaction directories indicate Docker-based setups for external environments (e.g., ubuntu, mysql images) and potential integrations with external services like

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Components
    subgraph "Client Components"
        CA["Agent Implementation"] 
        CT["Test Drivers"]
        FC["FastChat Client"]
        HA["HTTP Agent"]
        CLAU["Claude Agent"]
    end

    %% Task Server & Orchestration
    subgraph "Task Server & Orchestration"
        TC["Task Controller"]
        TW["Task Worker"]
        subgraph "Task Definitions"
            ALF["Alfworld Task"]
            AVAL["Avalon Task"]
            CG["Card Game Task"]
            DBB["DBBench Task"]
            KG["Knowledgegraph Task"]
            LTP_NODE["LTP Task"]
            M2W["Mind2Web Task"]
            OSI["OS Interaction Task"]
            WS["Webshop Task"]
        end
    end

    %% Configurations & Data
    subgraph "Configurations & Data"
        YA["Agent Configs"]
        YAS["Assignments Configs"]
        YT["Tasks Configs"]
        YST["Start Task"]
        DF["Data Files"]
    end

    %% Supporting Scripts & Utilities
    subgraph "Supporting Scripts & Utilities"
        TA["Task Assigner"]
        UT["Utilities"]
        TY["Typings"]
    end

    %% External Dependencies & Docker
    subgraph "External Dependencies & Docker"
        DS["Docker Setups"]
        ES["External Services"]
    end

    %% Relationships
    CA -->|"sends_request"| TC
    CT -->|"triggers"| TC

    TC -->|"orchestrates"| TW
    TC -->|"loads"| ALF
    TC -->|"loads"| AVAL
    TC -->|"loads"| CG
    TC -->|"loads"| DBB
    TC -->|"loads"| KG
    TC -->|"loads"| LTP_NODE
    TC -->|"loads"| M2W
    TC -->|"loads"| OSI
    TC -->|"loads"| WS

    YA -->|"provides_config"| CA
    YST -->|"provides_startup"| CA
    YAS -->|"guides_assignments"| TC
    YT -->|"defines_tasks"| TC
    DF -->|"supplies_data"| ALF

    TA -->|"pushes_tasks"| TC

    UT ---|"common_helpers"| CA
    UT ---|"common_helpers"| TC
    TY ---|"shared_definitions"| CA
    TY ---|"shared_definitions"| TC

    DS -->|"env_setup"| TW
    ES -->|"service_integration"| TW

    %% Click Events for Client Components
    click CA "https://github.com/thudm/agentbench/blob/main/src/client/agent.py"
    click CT "https://github.com/thudm/agentbench/blob/main/src/client/agent_test.py"
    click FC "https://github.com/thudm/agentbench/blob/main/src/client/agents/fastchat_client.py"
    click HA "https://github.com/thudm/agentbench/blob/main/src/client/agents/http_agent.py"
    click CLAU "https://github.com/thudm/agentbench/blob/main/src/client/agents/claude_agent.py"

    %% Click Events for Task Server & Orchestration
    click TC "https://github.com/thudm/agentbench/blob/main/src/server/task_controller.py"
    click TW "https://github.com/thudm/agentbench/blob/main/src/server/task_worker.py"
    click ALF "https://github.com/thudm/agentbench/tree/main/src/server/tasks/alfworld"
    click AVAL "https://github.com/thudm/agentbench/tree/main/src/server/tasks/avalon"
    click CG "https://github.com/thudm/agentbench/tree/main/src/server/tasks/card_game"
    click DBB "https://github.com/thudm/agentbench/tree/main/src/server/tasks/dbbench"
    click KG "https://github.com/thudm/agentbench/tree/main/src/server/tasks/knowledgegraph"
    click LTP_NODE "https://github.com/thudm/agentbench/tree/main/src/server/tasks/ltp"
    click M2W "https://github.com/thudm/agentbench/tree/main/src/server/tasks/mind2web"
    click OSI "https://github.com/thudm/agentbench/tree/main/src/server/tasks/os_interaction"
    click WS "https://github.com/thudm/agentbench/tree/main/src/server/tasks/webshop"

    %% Click Events for Configurations & Data
    click YA "https://github.com/thudm/agentbench/tree/main/configs/agents"
    click YAS "https://github.com/thudm/agentbench/tree/main/configs/assignments"
    click YT "https://github.com/thudm/agentbench/tree/main/configs/tasks"
    click YST "https://github.com/thudm/agentbench/blob/main/configs/start_task.yaml"
    click DF "https://github.com/thudm/agentbench/tree/main/data"

    %% Click Events for Supporting Scripts & Utilities
    click TA "https://github.com/thudm/agentbench/blob/main/src/assigner.py"
    click UT "https://github.com/thudm/agentbench/tree/main/src/utils"
    click TY "https://github.com/thudm/agentbench/tree/main/src/typings"

    %% Click Events for External Dependencies & Docker
    click DS "https://github.com/thudm/agentbench/tree/main/data/os_interaction/res/dockerfiles"
    click ES "https://github.com/thudm/agentbench/tree/main/data/os_interaction"

    %% Styles
    class CA,CT,FC,HA,CLAU client
    class TC,TW,ALF,AVAL,CG,DBB,KG,LTP_NODE,M2W,OSI,WS server
    class YA,YAS,YT,YST,DF config
    class TA,UT,TY supporting
    class DS,ES external

    classDef client fill:#AED6F1,stroke:#2471A3,stroke-width:2px;
    classDef server fill:#F9E79F,stroke:#D4AC0D,stroke-width:2px;
    classDef config fill:#A9DFBF,stroke:#27AE60,stroke-width:2px;
    classDef supporting fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
```
