OctoTools Documentation

repository·main·Indexed 23 days ago

https://github.com/octotools/octotools

An agentic framework for complex reasoning using extensible tool cards, a hierarchical planner, and an executor. OctoTools provides a training-free way to integrate diverse tools into LLM workflows and supports multiple engines including OpenAI, Anthropic, TogetherAI, vLLM, and Ollama. The octotoolkit package (v0.3.6) includes specialized tools for Google Search, text detection, and object detection.

Tokens
24.6K
Snippets
48
Records
94
Agent score
80%

What's inside OctoTools

  1. What is Memory in OctoTools?

    main

    Memory acts as a project logbook or scratchpad for the octotools system. It does not perform reasoning or actions itself; instead, it serves as a centralized container that records the context of a problem-solving journey. This context is essential for the Planner to make informed decisions about subsequent steps.

    Memory tracks three primary types of information:

    1. The Original Request: The initial query provided to the Solver.
    2. Files: Any files (images, documents, etc.) provided with the query, including their descriptions.
    3. Action History: A detailed log of every step taken by the Solver, including which Tool was used, the specific sub_goal, the exact command executed, and the result obtained.
  2. What is the Planner in OctoTools?

    main

    The Planner is the strategic component of the octotools framework. It acts as a navigator or strategist that guides the problem-solving process by analyzing the user's goal, the current progress recorded in Memory, and the available Tools.

    To determine the next course of action, the Planner evaluates three key inputs:

    1. The Destination (Query): The final goal provided by the user.
    2. Current Location & Trip Log (Memory): The history of actions taken and information gathered so far.
    3. Map & Vehicle Options (Tools): The list of available tools and their descriptions.

    Based on these inputs, the Planner decides on the next sub-goal and the specific tool selection required to achieve it.

  3. What is the Solver and how does it work?

    main

    The Solver is the central coordinator (the "brain") of an octotools agent. It manages the problem-solving process by orchestrating three specialist components:

    1. Planner: The strategist that breaks down the main goal into smaller, actionable steps and decides which tools to use.
    2. Executor: The hands-on specialist that generates specific commands for tools and executes them.
    3. Memory: The project logbook that records all steps taken, commands used, and results obtained to provide context for the Planner.

    The Solver operates in a loop: it analyzes the query, asks the Planner for the next step, tells the Executor to run a command, records the result in Memory, and asks the Planner if the goal has been met. This continues until the goal is achieved or limits (like max_steps or max_time) are reached.

  4. What is the Executor and how does it work?

    main

    The Executor acts as the 'Technician' in the octotools framework. While the Planner decides what to do, the Executor is responsible for how to do it by translating strategic decisions into concrete actions.

    Its workflow consists of two main phases:

    1. Command Formulation: The Executor uses an LLM Engine to translate a high-level sub-goal and tool metadata into a precise string of Python code. It instructs the LLM to generate code that calls the tool's .execute() method and assigns the result to a variable named execution.
    2. Execution & Reporting: The Executor locates the requested Tool object, prepares a controlled execution environment where the tool is available under the variable name tool, runs the generated code (typically via exec()), captures the value of the execution variable, and returns the result to the Solver.

    This process allows the system to bridge the gap between abstract reasoning and actual tool interaction.

  5. What is the Initializer?

    main

    The Initializer acts as the setup crew for an octotools project. It prepares the environment before the Solver begins its work by performing three main tasks:

    1. Discovering Tools: Scanning the project to find available Tools (e.g., Web_Search_Tool). You can specify specific tools or request all of them.
    2. Loading Metadata: For each tool, it loads the 'instruction manual' containing:
      • tool_name: The name of the tool.
      • tool_description: What the tool does.
      • input_types: Required inputs.
      • output_type: Produced outputs.
      • require_llm_engine: Whether the tool requires an LLM Engine.
    3. Checking Availability (Optional): Running checks or 'demo commands' to ensure tools are functional in the current environment (e.g., verifying API keys).
  6. What is OctoTools?

    main

    OctoTools is an agentic framework designed for complex reasoning across diverse domains. It is training-free and easily extensible. The framework relies on three core components:

    1. Tool cards: Standardized metadata that encapsulates tool functionality, allowing for the integration of heterogeneous tools without additional training.
    2. Planner: Manages both high-level and low-level planning to address global objectives and refine actions step-by-step.
    3. Executor: Instantiates tool calls by generating executable commands and saving structured results into the context.

    The framework also includes a task-specific toolset optimization algorithm that identifies the most beneficial subset of tools for specific downstream tasks.

  7. What is the LLM Engine?

    main

    The LLM Engine is the component in octotools that manages communication with Large Language Models (LLMs) like OpenAI's GPT, Anthropic's Claude, or Google's Gemini. It acts as an adapter and communication manager for the rest of the framework (such as the Planner and Executor).

    Key responsibilities include:

    • Connection & Communication: Handling API connections and formatting requests for specific providers.
    • Translation: Converting LLM responses back into a format usable by octotools.
    • Reliability: Automatically retrying requests if connections fail or the LLM is busy.
    • Efficiency: Caching results so that identical subsequent requests are served from memory instead of re-calling the API.
    • Flexibility: Supporting various LLM providers through a unified interface.
  8. What is a Tool in octotools?

    main

    A Tool is a specialized capability that extends the basic knowledge of the LLM Engine. While the LLM provides reasoning, Tools allow the system to interact with the real world or perform specific technical tasks.

    Every tool consists of three core components:

    1. Defined Inputs: The specific information required to perform the task (e.g., a search query).
    2. Defined Outputs: The result produced by the tool (e.g., a list of search results).
    3. Metadata: Descriptive information (name, description, version, examples) that allows the Planner to select the correct tool for a given problem.

    Common examples include Web Search, Image Captioning, Object Detection, Code Execution, and ArXiv Paper Searching.

  9. How CachedEngine works

    main

    The CachedEngine is a wrapper/mechanism used by the LLM Engine to optimize performance and cost.

    Workflow:

    1. Store Results: When a request is made to an engine with caching enabled, the engine stores a copy of the prompt and the received response.
    2. Check First: For every new request, the engine checks its internal storage (the cache) for an exact match of the request.
    3. Return Stored Answer: If a match is found, the engine returns the stored response immediately without contacting the external AI service.
    4. Fetch if New: If no match is found, the engine performs the standard external API call, saves the result to the cache, and then returns it.

    Persistence: The cache is typically stored as a file on your local machine (often in a user cache directory), meaning cached responses persist across script restarts as long as the model_string and cache path remain the same.

  10. Understand the tools directory structure

    main

    The tools directory is organized into specialized subdirectories, each containing a specific detection implementation and its own documentation. All tools are built upon a common base class.

    Directory Layout:

    • __init__.py: Initializes the tools package.
    • base.py: Contains the base class for all tools, providing shared functionality.
    • text_detector/: Contains the text detection tool implementation (tool.py) and its documentation (readme.md).
    • object_detector/: Contains the object detection tool implementation (tool.py) and its documentation (readme.md).
    ├── __init__.py              # Initializes the tools package and possibly exposes submodules
    ├── base.py                  # Base class for tools, providing common functionality
    ├── text_detector/           # Directory for the text detection tool
    │   ├── readme.md            # Documentation for the text detection tool
    │   └── tool.py              # Implementation of the text detection tool
    ├── object_detector/         # Directory for the object detection tool
    │   ├── readme.md            # Documentation for the object detection tool
    │   └── tool.py              # Implementation of the object detection tool
  11. How the LLM Engine lifecycle works

    main

    The LLM Engine acts as a bridge between the framework and external LLM providers. It manages three main concerns:

    • Abstraction: The create_llm_engine factory allows you to switch between different 'brains' (GPT, Claude, Gemini) without changing your core logic.
    • Reliability: Engines implement retry logic (e.g., via @retry decorators) to manage transient API failures.
    • Efficiency: Through the CachedEngine implementation, the engine uses diskcache to store and retrieve responses based on a SHA-256 hash of the prompt, reducing latency and API costs for repeated queries.
  12. How the OctoTools agentic framework works

    main

    OctoTools is an agentic framework designed to solve complex problems by decomposing them into smaller, manageable steps. It functions as a smart agent that coordinates between a Planner, an Executor, and various Tools using a Large Language Model (LLM) as the reasoning core.

    Core Components and Workflow

    • Solver: The central coordinator that manages the entire process.
    • Planner: Decides what steps to take next based on the user query and current context.
    • Executor: Determines how to perform the planned steps using specific tools.
    • Tool: The functional units (e.g., Google Search) that the Executor calls to perform actions.
    • Memory: Maintains a history of actions and observations to provide context to the Planner.
    • LLM Engine: Provides the intelligence for reasoning and communication with AI models. It can be wrapped with Caching (CachedEngine) to improve speed and reduce costs.
    • Data Formatters: Ensure that communication between components is structured correctly.
    • Initializer: Handles the discovery and loading of tools and system setup.