Skip to content

Refactor Agent-Tool Interaction for Simplified Design and Centralized Tool Management #63

@solarfresh

Description

@solarfresh

Description:

The current design of the GraphBuilderAgent and its interaction with the MindMapGraphBuilder tool is overly complex. The MindMapGraphBuilder tool is instantiated within the agent itself, leading to tight coupling between the two components. This approach complicates sharing tools between agents and makes the system less scalable and maintainable.

To simplify the design and prepare for a future where agents can share a common set of tools, we need to refactor how agents access and use their tools.

Problem Statement:

  • Tight Coupling: The GraphBuilderAgent directly creates its MindMapGraphBuilder tool instance. This prevents other agents from using the same tool and requires redundant tool instantiation if multiple agents need the same functionality.
  • Scalability: As we add more agents and tools, this one-to-one relationship will lead to a complex and rigid architecture that is difficult to manage.
  • Maintenance: Changes to a tool's constructor or dependencies would require modifications to every agent that uses it, increasing maintenance overhead.

Proposed Solution (Bucket List Item):

Refactor the system to use a centralized Tool Manager or Tool Registry. This manager would be responsible for:

  1. Registering Tools: All available tools (like MindMapGraphBuilder) would be registered with the manager at startup.
  2. Providing Tools to Agents: Agents would request a tool instance from the manager by its name (e.g., tool_manager.get_tool('MindMapGraphBuilder')). This decouples the agent from the tool's creation logic.
  3. Handling Singleton or Shared Instances: The tool manager could be configured to return a new instance of a tool each time or to return a single, shared (singleton) instance for stateless tools.

Acceptance Criteria:

  • A ToolManager class is implemented to handle tool registration and retrieval.
  • The GraphBuilderAgent is modified to get its MindMapGraphBuilder tool from the new ToolManager instead of instantiating it directly.
  • The agent's __init__ method no longer creates tool instances.
  • The overall design is more modular, allowing for easier addition of new agents and tools in the future.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai-agentTasks specific to the development, behavior, or configuration of individual AI agents.enhancementNew feature or requesthelp wantedExtra attention is neededmulti-agentTasks involving coordination between multiple agents.orchestrationCoordinates and manages the workflow of multiple agents or components.tool-useTasks related to integrating and testing the use of external tools by AI agents.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions