# kohjingyu/search-agents architecture

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

- Interactive diagram: https://gitdiagram.com/kohjingyu/search-agents
- Repository: https://github.com/kohjingyu/search-agents

## Overview

##### Component Relationships

- Agent → Browser Environment (Action execution)
- Browser Environment → Agent (State/Observation feedback)
- Agent → LLM Integration (Query/Response flow)
- Agent → Evaluation System (Performance monitoring)

##### Key Subsystems to Detail

a. Agent Module:
- [Agent Core] → [Prompts Manager] → [Value Function]
- ↓
- [Tree Search Algorithm]

b. Browser Environment:
- [Actions Handler] → [JavaScript Executor]
- → [Environment Config]
- → [Trajectory Tracker]

c. LLM Integration:
- [Provider Interface] → [Model Config]
- → [Tokenization]

##### Technical Details

- Python 3.10/3.11 runtime requirement
- External API dependencies (OpenAI, etc.)
- Docker container boundaries
- File storage for trajectories and results

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Core["Core Agent System"]
        Agent["Main Agent"]
        ValueFunc["Value Function"]
        PromptMgr["Prompts Management"]
        PromptTemp["Prompt Templates"]
        
        Agent --> ValueFunc
        Agent --> PromptMgr
        PromptMgr --> PromptTemp
    end

    subgraph Env["Environment Layer"]
        BrowserEnv["Browser Environment"]
        ActionProc["Action Processor"]
        JSHandler["JavaScript Handlers"]
        EnvConfig["Environment Config"]
        TrajTrack["Trajectory Tracking"]
        
        BrowserEnv --> ActionProc
        BrowserEnv --> JSHandler
        BrowserEnv --> EnvConfig
        BrowserEnv --> TrajTrack
    end

    subgraph LLM["Language Model Integration"]
        OpenAI["OpenAI Provider"]
        Gemini["Gemini Provider"]
        HF["HuggingFace Provider"]
        Token["Tokenization"]
        ModelConfig["Model Configuration"]
        
        OpenAI --> Token
        Gemini --> Token
        HF --> Token
        Token --> ModelConfig
    end

    subgraph Eval["Evaluation System"]
        EvalHarness["Evaluation Harness"]
        HelperFunc["Helper Functions"]
        TestConfig["Test Configurations"]
        
        EvalHarness --> HelperFunc
        EvalHarness --> TestConfig
    end

    Core --> Env
    Env --> Core
    Core --> LLM
    Core --> Eval
    Eval --> Core

    %% Click events for component mapping
    click Agent "https://github.com/kohjingyu/search-agents/blob/main/agent/agent.py"
    click ValueFunc "https://github.com/kohjingyu/search-agents/blob/main/agent/value_function.py"
    click PromptMgr "https://github.com/kohjingyu/search-agents/blob/main/agent/prompts/prompt_constructor.py"
    click PromptTemp "https://github.com/kohjingyu/search-agents/tree/main/agent/prompts/jsons"
    click BrowserEnv "https://github.com/kohjingyu/search-agents/blob/main/browser_env/envs.py"
    click ActionProc "https://github.com/kohjingyu/search-agents/blob/main/browser_env/actions.py"
    click JSHandler "https://github.com/kohjingyu/search-agents/tree/main/browser_env/javascript"
    click EnvConfig "https://github.com/kohjingyu/search-agents/blob/main/browser_env/env_config.py"
    click TrajTrack "https://github.com/kohjingyu/search-agents/blob/main/browser_env/trajectory.py"
    click OpenAI "https://github.com/kohjingyu/search-agents/blob/main/llms/providers/openai_utils.py"
    click Gemini "https://github.com/kohjingyu/search-agents/blob/main/llms/providers/gemini_utils.py"
    click HF "https://github.com/kohjingyu/search-agents/blob/main/llms/providers/hf_utils.py"
    click Token "https://github.com/kohjingyu/search-agents/blob/main/llms/tokenizers.py"
    click ModelConfig "https://github.com/kohjingyu/search-agents/blob/main/llms/lm_config.py"
    click EvalHarness "https://github.com/kohjingyu/search-agents/blob/main/evaluation_harness/evaluators.py"
    click HelperFunc "https://github.com/kohjingyu/search-agents/blob/main/evaluation_harness/helper_functions.py"
    click TestConfig "https://github.com/kohjingyu/search-agents/tree/main/config_files"

    classDef core fill:#2374f7,stroke:#fff,stroke-width:2px,color:#fff
    classDef env fill:#47d147,stroke:#fff,stroke-width:2px,color:#fff
    classDef llm fill:#ffd700,stroke:#fff,stroke-width:2px,color:#000
    classDef eval fill:#ff8c00,stroke:#fff,stroke-width:2px,color:#fff

    class Agent,ValueFunc,PromptMgr,PromptTemp core
    class BrowserEnv,ActionProc,JSHandler,EnvConfig,TrajTrack env
    class OpenAI,Gemini,HF,Token,ModelConfig llm
    class EvalHarness,HelperFunc,TestConfig eval
```
