Skip to main content

Overview

The RepoMasterAgent is the primary agent class in RepoMaster that orchestrates multiple specialized agents to solve user tasks. It can search for relevant GitHub repositories, analyze repository content, perform web searches, and provide general programming assistance through collaboration between scheduler and user agents.

Class Definition

class RepoMasterAgent:
    """
    RepoMaster agent for searching and utilizing GitHub repositories to solve user tasks.
    
    This agent can search for relevant GitHub repositories based on user tasks, analyze repository content,
    and generate solutions. The main work is accomplished through collaboration between scheduler agent and user agent.
    """

Constructor

__init__()

Initialize a new RepoMasterAgent instance.
def __init__(self, llm_config=None, code_execution_config=None)
llm_config
dict
default:"None"
Language model configuration containing model settings, API keys, and other LLM parameters. See Configuration Guide for details.
code_execution_config
dict
default:"None"
Code execution configuration containing:
  • work_dir (str): Working directory for code execution
  • use_docker (bool): Whether to use Docker for code execution

Example

from src.core.agent_scheduler import RepoMasterAgent
from configs.oai_config import get_llm_config

llm_config = get_llm_config()
code_execution_config = {
    "work_dir": "/path/to/work/directory",
    "use_docker": False
}

repo_master = RepoMasterAgent(
    llm_config=llm_config,
    code_execution_config=code_execution_config
)

Methods

solve_task_with_repo()

Main entry point for solving tasks using RepoMaster’s intelligent multi-agent system.
def solve_task_with_repo(self, task: str) -> str
task
str
required
Detailed task description that the user needs to solve
result
str
Complete solution report including analysis methods, execution results, and recommendations

Features

  • Three Working Modes:
    1. Web Search Mode: Search the internet for real-time information, current events, or general knowledge
    2. Repository Mode: Search and use GitHub repositories or local repositories for specialized tasks with hierarchical analysis
    3. General Code Assistant Mode: Provide programming assistance without specific repositories
  • Auto-Mode Detection:
    • Detects real-time information needs → Web Search Mode
    • Detects repository paths/URLs (GitHub or local) → Repository Mode
    • Detects general programming questions → General Code Assistant Mode
    • Default behavior → Repository Mode

Example

# Example from launcher.py
agent = RepoMasterAgent(
    llm_config=llm_config,
    code_execution_config=execution_config
)

# Automatic mode selection - web search
result = agent.solve_task_with_repo("What is the stock price of APPLE?")

# Automatic mode selection - repository task
result = agent.solve_task_with_repo(
    "Help me convert '/data/DeepResearcher.pdf' to markdown and save"
)

run_repository_agent()

Unified interface for executing user tasks based on a specified repository (GitHub or local).
def run_repository_agent(
    self,
    task_description: str,
    repository: str,
    input_data: Optional[str] = None,
    repo_type: Optional[str] = None
)
task_description
str
required
Task description that the user needs to solve, maintaining completeness without omitting information
repository
str
required
Repository path or URL. Can be:
  • GitHub repository URL (format: https://github.com/owner/repo)
  • Local repository absolute path (e.g., /path/to/my/project)
input_data
str
default:"None"
JSON string representing local input data. Format:
[{"path": "local_input_data_path", "description": "input_data_description"}]
Required when the task explicitly mentions using local files as input. Pass empty list [] if no input data needed.
repo_type
str
default:"None"
Repository type: 'github' or 'local'. If not specified, automatically detected based on the repository parameter.
result
str
Result of agent executing the task, containing task completion status and output content description

Process

  1. Automatically detect repository type or use specified type
  2. Validate repository path or URL validity
  3. Validate and process input data
  4. Initialize task environment (create working directory, clone or copy repository)
  5. Run code agent to analyze and execute tasks

Example

# Example from agent_scheduler.py
result = repo_master.run_repository_agent(
    task_description='Extract all text content from the first page of a PDF file and save it to a txt file. The input PDF file path is: GitTaskBench/queries/PDFPlumber_01/input/PDFPlumber_01_input.pdf',
    repository='https://github.com/spatie/pdf-to-text',
    input_data=None
)

run_general_code_assistant()

Provide general programming assistance without requiring a specific repository.
def run_general_code_assistant(
    self,
    task_description: str,
    work_directory: Optional[str] = None
)
task_description
str
required
Programming task or question that needs general coding assistance
work_directory
str
default:"None"
Specific working directory for code execution. If not provided, uses default work directory.
result
str
Result containing programming guidance, code examples, and execution results

Capabilities

This method creates a clean workspace and uses the code exploration agent to help with:
  • General programming questions and guidance
  • Writing and executing code snippets
  • Debugging and troubleshooting
  • Creating examples and demonstrations
  • Algorithm implementations
  • Code explanations and tutorials

Example

# Example from launcher.py
result = agent.run_general_code_assistant(
    task_description="Write a Python function to calculate fibonacci numbers",
    work_directory="/path/to/work/dir"
)
Perform general web search to find real-time information or solve general problems that don’t require code.
async def web_search(self, query: str) -> str
query
str
required
Query for general web search to get real-time information or answer non-code-related questions
result
str
Formatted search result information with analysis and answers based on web search

Features

  • Search the internet and generate answers based on results
  • Provide real-time information about current events and latest data
  • Return formatted search result information
  • Access information beyond the model’s knowledge cutoff date

Example

import asyncio

# This method is typically called internally by solve_task_with_repo
result = asyncio.run(agent.web_search("Latest AI developments in 2024"))
Search for relevant code repositories on GitHub based on task description.
async def github_repo_search(self, task: str) -> str
task
str
required
Description of tasks that need to be solved through GitHub repositories, used to search for the most relevant code libraries
result
str
A JSON string containing a list of the most matching repository information with format:
[
  {
    "repo_name": "repo_name",
    "repo_url": "repo_url",
    "repo_description": "repo_description"
  }
]

Process

  1. Search for the most relevant GitHub repositories based on task description
  2. Carefully read the README file of each repository
  3. Determine whether the code can solve the task based on README
  4. Select top 5 repositories most suitable to solve the task
  5. Return results in JSON format

Example

import asyncio

# This method is typically called internally by the scheduler agent
result = asyncio.run(agent.github_repo_search(
    "Find a Python library for PDF text extraction"
))

initialize_agents()

Initialize scheduler agent and user proxy agent for task orchestration.
def initialize_agents(self, **kwargs)
This method is called automatically during __init__() and sets up:
  • scheduler: ExtendedAssistantAgent for task planning and tool selection
  • user_proxy: ExtendedUserProxyAgent for tool execution and result collection

register_tools()

Register the enhanced toolkit required by the agent.
def register_tools(self)
This method is called automatically during __init__() and registers:
  • web_search: Web search functionality
  • run_repository_agent: Unified repository processing mode
  • run_general_code_assistant: General code assistant mode
  • github_repo_search: GitHub repository search

Complete Usage Example

import os
import uuid
from pathlib import Path
from dotenv import load_dotenv
from configs.oai_config import get_llm_config
from src.core.agent_scheduler import RepoMasterAgent

# Setup environment
load_dotenv("configs/.env")
llm_config = get_llm_config()

# Create working directory
work_dir = os.path.join(os.getcwd(), "coding", str(uuid.uuid4()))
code_execution_config = {
    "work_dir": work_dir,
    "use_docker": False
}

# Initialize RepoMasterAgent
repo_master = RepoMasterAgent(
    llm_config=llm_config,
    code_execution_config=code_execution_config
)

# Use unified interface (automatic mode selection)
result = repo_master.solve_task_with_repo(
    "What is the stock price of APPLE?"
)
print(result)

# Use repository agent directly
result = repo_master.run_repository_agent(
    task_description="Extract text from PDF first page",
    repository="https://github.com/spatie/pdf-to-text",
    input_data='[{"path": "input.pdf", "description": "PDF file to process"}]'
)
print(result)

# Use general code assistant
result = repo_master.run_general_code_assistant(
    task_description="Create a Python script to merge multiple CSV files",
    work_directory=work_dir
)
print(result)

Architecture

The RepoMasterAgent orchestrates multiple components:
  • Scheduler Agent: Analyzes tasks, creates plans, and selects appropriate tools
  • User Proxy Agent: Executes tools and collects results
  • Deep Search Agent: Handles web searches and GitHub repository searches
  • Code Explorer: Provides general programming assistance and code execution
  • Task Manager & Agent Runner: Manages repository-based task execution

See Also

Build docs developers (and LLMs) love