# justinlietz93/agent_tools architecture

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

- Interactive diagram: https://gitdiagram.com/justinlietz93/agent_tools
- Repository: https://github.com/justinlietz93/agent_tools

## Overview

Based on your project’s file tree and README, this is a Python framework designed for building AI agent tools that harness Deepseek’s Reasoner to control system interactions through prompt engineering. The framework provides a set of base classes and wrappers (such as the DeepseekToolWrapper) to handle tool registration, schema conversion, and execution—facilitating communication with various tools (like file, shell, web browser, and more) via a structured API.

##### Project Type and Purpose
- That this is a framework for creating and managing “agent tools” that can be used to interact with different systems or APIs.
- That the framework leverages Deepseek’s Chain of Thought (CoT) reasoning to preprocess commands, convert tool schemas, and manage error handling and responses.

##### Main Components
a. Deepseek Integration:
- DeepseekToolWrapper: Acts as the intermediary between Deepseek’s analysis and tool execution (handles schema conversion, reasoning, and managing the tool calls).
b. Tools Subsystem:
- Base Tool Interface (tools/tool_base.py): The contract that all tools must follow.
- Individual Tool Implementations: Modules such as computer_tool, code_runner_tool, file_tool, shell_tool, web_browser_tool, etc. These are registered with the wrapper.
- Tool Manager (tools/tool_manager.py): Potentially responsible for managing the registration and life cycle of tools.
c. Testing & Documentation Layers (for context):
- “tests” directory: Demonstrates organized test categories including unit, integration, llm, and system tests.
- “docs” directory: Contains guidelines for setup, compatibility, and tool usage.
- “examples” directory: Includes usage examples that illustrate actual integration and execution flows.

##### Relationships and Interactions
- API call flow starting from a user (or calling system) input, feeding into the Deepseek Reasoner through the DeepseekToolWrapper.
- That the DeepseekToolWrapper registers and manages the various tool components.
- The Deepseek Reasoner processes the user’s input and supplies a Chain of Thought along with a structured tool call.
- The wrapper parses and distributes the call to the appropriate tool.
- The tool executes its action and returns a response (structured with status, message, and optional extra data) which travels back through the wrapper to be formatted with the reasoning.

##### Architectural Patterns and Design Principles
- Modular Design: Each tool is isolated in its own module and all implement a common interface.
- Interface-driven Development: Emphasize the abstract Tool class and enforced schema requirements.
- Plug-and-Play: Tools are registered dynamically at runtime via the tool manager/wrapper.
- Layered Communication: Illustrate the separation between the reasoning engine (Deepseek) and the tool execution logic.

##### Technologies, Frameworks, and Libraries
- Python 3 with a dependency structure defined in requirements.txt.
- Use of Deepseek’s Reasoner for advanced AI-driven reasoning.
- Testing environment via pytest (illustrated by the pytest.ini and tests folder).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global entities
    U["User/Client Input"]:::client

    %% Reasoning & Orchestration Layer
    subgraph "Reasoning & Orchestration"
        DR["Deepseek Reasoner<br/>(Chain-of-Thought)"]:::reasoning
        DTW["DeepseekToolWrapper<br/>(Schema Conversion & Management)"]:::wrapper
    end

    %% Tools Subsystem Layer
    subgraph "Tool Subsystem"
        TM["Tool Manager<br/>(Tool Registration)"]:::manager
        BTI["Base Tool Interface<br/>(Tool Contract)"]:::tool
        
        subgraph "Individual Tool Implementations"
            CT["Computer Tool"]:::tool
            CRT["Code Runner Tool"]:::tool
            FT["File Tool"]:::tool
            ST["Shell Tool"]:::tool
            WBT["Web Browser Tool"]:::tool
            WST["Web Search Tool"]:::tool
            AFT["Advanced File Tool"]:::tool
            DCT["Doc Check Tool"]:::tool
            PMT["Package Manager Tool"]:::tool
            RT["Requests Tool"]:::tool
        end
    end

    %% Ancillary Layers
    subgraph "Supporting Layers"
        TT["Testing<br/>(Pytest, etc.)"]:::test
        DOC["Documentation<br/>(Setup Guides, API Docs)"]:::docs
        EX["Examples<br/>(Usage Scenarios)"]:::docs
    end

    %% Data Flow / Relationships
    U -->|"input"| DR
    DR -->|"analyzes"| DTW
    DTW -->|"registers calls"| TM
    TM -->|"manages"| BTI
    DTW -->|"executes"| BTI
    BTI -->|"implements"| CT
    BTI -->|"implements"| CRT
    BTI -->|"implements"| FT
    BTI -->|"implements"| ST
    BTI -->|"implements"| WBT
    BTI -->|"implements"| WST
    BTI -->|"implements"| AFT
    BTI -->|"implements"| DCT
    BTI -->|"implements"| PMT
    BTI -->|"implements"| RT
    CT -->|"returns output"| DTW
    CRT -->|"returns output"| DTW
    FT -->|"returns output"| DTW
    ST -->|"returns output"| DTW
    WBT -->|"returns output"| DTW
    WST -->|"returns output"| DTW
    AFT -->|"returns output"| DTW
    DCT -->|"returns output"| DTW
    PMT -->|"returns output"| DTW
    RT -->|"returns output"| DTW
    DTW -->|"formats result"| DR
    DR -->|"sends response"| U

    %% Ancillary links (indicating support & testing)
    DOC --- U
    TT --- U
    EX --- U

    %% Click Events
    click DR "https://github.com/justinlietz93/agent_tools/blob/main/docs/Deepseek-reasoner.md"
    click DTW "https://github.com/justinlietz93/agent_tools/blob/main/tools/deepseek_wrapper.py"
    click BTI "https://github.com/justinlietz93/agent_tools/blob/main/tools/tool_base.py"
    click CT "https://github.com/justinlietz93/agent_tools/blob/main/tools/computer_tool.py"
    click CRT "https://github.com/justinlietz93/agent_tools/blob/main/tools/code_runner_tool.py"
    click FT "https://github.com/justinlietz93/agent_tools/blob/main/tools/file_tool.py"
    click ST "https://github.com/justinlietz93/agent_tools/blob/main/tools/shell_tool.py"
    click WBT "https://github.com/justinlietz93/agent_tools/blob/main/tools/web_browser_tool.py"
    click WST "https://github.com/justinlietz93/agent_tools/blob/main/tools/web_search_tool.py"
    click AFT "https://github.com/justinlietz93/agent_tools/blob/main/tools/advanced_file_tool.py"
    click DCT "https://github.com/justinlietz93/agent_tools/blob/main/tools/doc_check_tool.py"
    click PMT "https://github.com/justinlietz93/agent_tools/blob/main/tools/package_manager_tool.py"
    click RT "https://github.com/justinlietz93/agent_tools/blob/main/tools/requests_tool.py"
    click TM "https://github.com/justinlietz93/agent_tools/blob/main/tools/tool_manager.py"

    %% Styles
    classDef client fill:#f8961e,stroke:#000,stroke-width:2px;
    classDef reasoning fill:#f9c74f,stroke:#000,stroke-width:2px;
    classDef wrapper fill:#90be6d,stroke:#000,stroke-width:2px;
    classDef manager fill:#f94144,stroke:#000,stroke-width:2px;
    classDef tool fill:#577590,stroke:#fff,stroke-width:2px,fill-opacity:0.85;
    classDef test fill:#277da1,stroke:#fff,stroke-width:2px;
    classDef docs fill:#a8dadc,stroke:#000,stroke-width:2px;
```
