DATAGEN Documentation

repository·main·Indexed 23 days ago

https://github.com/starpig1129/datagen

An AI-powered multi-agent platform for automated data analysis, research, and report generation. Built with LangGraph, DATAGEN coordinates specialized agents—including hypothesis, code, process, searcher, visualization, and quality review agents—to handle complex workflows. It features a three-level progressive disclosure loading strategy for agent configurations and integrates with the Model Context Protocol (MCP) for filesystem, web-search, and GitHub services.

Tokens
15.6K
Snippets
33
Records
82
Agent score
83%

What's inside DATAGEN

  1. How DATAGEN loads agent configurations (Progressive Disclosure)

    main

    DATAGEN uses a three-level loading strategy to optimize the Context Window, loading more information only when necessary:

    1. Level 1: Metadata (Loaded at system startup)

      • Contains only name and description.
      • Very lightweight (~100 tokens).
    2. Level 2: Instructions (Loaded when agent is triggered)

      • Full system prompt from AGENT.md content.
      • Auto-injected global rules.
    3. Level 3: Resources (Loaded when agent calls lookup_skill)

      • Full SKILL.md content.
      • MCP server resources.
      • External files.
  2. How DATAGEN's Progressive Disclosure works

    main

    DATAGEN optimizes Context Window usage through a three-level loading strategy called Progressive Disclosure. This ensures minimal startup costs and prevents context overflow by only loading detailed information when necessary.

    1. Level 1: Metadata (Loaded at startup, ~100 tokens): Includes the agent name, description, and a list of available skill names.
    2. Level 2: Instructions (Loaded when the agent is triggered): Includes the full AGENT.md content and auto-injected global rules.
    3. Level 3: Resources (Loaded on demand via lookup_skill): Includes full SKILL.md content, MCP server resources, and external files.
    ┌─────────────────────────────────────────────────────────────────┐
    │                                                                 │
    │   Level 1: Metadata                 ← Loaded at startup (~100 tokens) │
    │   ─────────────────                                             │
    │   • Agent name, description                                     │
    │   • Available skills list (names only)                          │
    │                                                                 │
    │             ▼                                                   │
    │                                                                 │
    │   Level 2: Instructions             ← Loaded when agent triggered │
    │   ─────────────────                                             │
    │   • Full AGENT.md content                                       │
    │   • Auto-injected global rules                                   │
    │                                                                 │
    │             ▼                                                   │
    │                                                                 │
    │   Level 3: Resources                ← Loaded on demand (via lookup_skill) │
    │   ─────────────────                                             │
    │   • Full SKILL.md content                                       │
    │   • MCP server resources                                        │
    │   • External files                                              │
    │                                                                 │
    └─────────────────────────────────────────────────────────────────┘
  3. Understand the DATAGEN multi-agent workflow

    main

    DATAGEN uses LangGraph to manage a state graph that coordinates several specialized agents. The typical research workflow follows these steps:

    1. Hypothesis Generation: The hypothesis_agent generates research hypotheses.
    2. Human Intervention: The user chooses whether to continue with the hypothesis or regenerate it.
    3. Processing: A coordinated effort involving:
      • code_agent: Writes data analysis code.
      • process_agent: Supervises the research process.
      • searcher_agent: Conducts web/literature searches.
      • visualization_agent: Creates data visualizations.
      • note_agent: Records the research process for state tracking.
    4. Quality Review: The quality_review_agent performs a review.
    5. Revision: The system revises the output as needed based on the review.
  4. Configure the directory structure for Skills

    main

    All skills must be stored within the config/skills/ directory. Each skill requires its own subdirectory named after the skill, containing a mandatory SKILL.md file.

    Standard Structure:

    config/skills/
    └── {skill-name}/
        └── SKILL.md       # Skill definition file (required)

    Multi-File Structure: For complex skills, you can include additional files like documentation or scripts within the same directory:

    config/skills/advanced-skill/
    ├── SKILL.md           # Main instruction file
    ├── REFERENCE.md       # Detailed reference
    └── scripts/
        └── helper.py      # Helper scripts

    You can reference these files in your SKILL.md using standard Markdown links, e.g., [REFERENCE.md](REFERENCE.md).

  5. How Agent Skills work via progressive disclosure

    main

    Skills are reusable knowledge modules that provide agents with domain-specific expertise. To optimize context window usage, DATAGEN uses a progressive disclosure mechanism:

    1. Level 1 (System Startup): The agent is only aware of the skill's name and description.
    2. Level 2 (On Demand): The agent retrieves the full content of the skill by calling lookup_skill("{skill-name}") only when the specific expertise is required.

    This approach prevents unnecessary context window consumption by not loading full skill instructions until they are actually needed for a task.

  6. Understand the DATAGEN directory structure

    main

    DATAGEN uses a specific directory hierarchy to manage LLM settings, shared skills, and individual agent configurations. Use this structure to organize your files:

    • config/agent_models.yaml: Defines LLM Provider and model settings.
    • config/mcp.yaml: Global configuration for MCP servers.
    • config/skills/{skill-name}/SKILL.md: A repository of shared, reusable knowledge modules.
    • config/agents/_shared/rules.md: Global rules that are automatically injected into agents.
    • config/agents/{agent_name}/AGENT.md: The specific system prompt for an agent.
    • config/agents/{agent_name}/config.yaml: Agent-specific settings for tools, skills, and MCP configurations.
    config/
    ├── agent_models.yaml          # LLM Provider and model settings
    ├── mcp.yaml                   # MCP server global configuration
    │
    ├── skills/                    # Shared skills repository
    │   └── {skill-name}/
    │       └── SKILL.md
    │
    └── agents/                    # Agent-specific configurations
        ├── _shared/
        │   └── rules.md           # Global rules (auto-injected)
    │   
        └── {agent_name}/
            ├── AGENT.md           # System prompt
            └── config.yaml        # Tools, skills, MCP settings
  7. Configure an existing agent's behavior

    main

    You can modify the behavior of any of the 9 existing agents without changing the source code by editing their specific configuration files. This involves two main steps: modifying the system prompt and adjusting the available tools.

    1. Modify System Prompt

    Edit the AGENT.md file located in the agent's specific directory: config/agents/{agent_name}/AGENT.md. You can add custom instructions under a ## Custom Instructions header.

    2. Modify Available Tools

    Edit the config.yaml file in the agent's directory: config/agents/{agent_name}/config.yaml. Add or remove tool names from the tools list.

    3. Apply Changes

    Restart the system to load the new configurations:

    python main.py
    # Code Agent
    
    You are a Python programmer specializing in data processing...
    
    ## Custom Instructions
    [Add your custom instructions here]
    tools:
      - execute_code
      - read_document
      - wikipedia        # Add research tools
      - arxiv
  8. Add a custom tool to the ToolFactory

    main

    To extend the agent's capabilities with a new tool, follow these three steps:

    1. Create the tool function in src/tools/.
    2. Register the tool in src/tools/factory.py within the ToolFactory._registry dictionary.
    3. Add the tool name to the agent's config.yaml under the tools list.
    # 2. Register in src/tools/factory.py
    from .my_tools import my_custom_tool
    
    class ToolFactory:
        _registry = {
            # ... existing tools ...
            "my_custom_tool": my_custom_tool,
        }
  9. Organize agent configuration files

    main

    Each agent in DATAGEN requires a dedicated directory within config/agents/{agent_name}/. This directory must contain two mandatory files:

    1. AGENT.md: Contains the system prompt and metadata.
    2. config.yaml: Defines the agent's capabilities, tools, and skills.

    Directory Structure:

    config/agents/{agent_name}/
    ├── AGENT.md       # System prompt (required)
    └── config.yaml    # Capabilities config (required)
  10. Install DATAGEN

    main

    To install DATAGEN, you need Python 3.10 or higher. Follow these steps to set up your environment using Conda:

    1. Clone the repository:
      git clone https://github.com/starpig1129/DATAGEN.git
    2. Create and activate a Conda virtual environment:
      conda create -n datagen python=3.10
      conda activate datagen
    3. Install dependencies:
      pip install -r requirements.txt
    4. Set up environment variables by renaming .env Example to .env and filling in the required values.
    git clone https://github.com/starpig1129/DATAGEN.git
    conda create -n datagen python=3.10
    conda activate datagen
    pip install -r requirements.txt
  11. Add global rules for all agents

    main

    To enforce rules across the entire agent system (such as output formatting or security guidelines), edit the shared rules file at config/agents/_shared/rules.md. Every agent will automatically incorporate these rules into their operation.

    # Global Rules
    
    ## Output Format
    - All code must include type hints
    - Use Google Style docstrings
    
    ## Security Guidelines
    - Do not execute file deletion operations
    - Sensitive data must be anonymized