Skip to content

Debug Info Manager

📘 DebugInfoManager Documentation

The DebugInfoManager is a service designed to collect, manage, and expose debug information for tools and orchestrators. It provides a centralized key-value store for debug data, ensuring that relevant information is accessible to users with the appropriate roles (e.g., the "Debug" role in the front end).


🔑 Key Features

  1. Tool Debug Information Extraction
  2. The DebugInfoManager can extract debug data from a list of ToolCallResponse objects.
  3. This data is stored under the "tools" key, with each tool's name and debug information included.

  4. Direct Debug Data Addition

  5. Debug information can be added directly to the manager using a key-value pair.
  6. This allows the orchestrator or other services to log additional debug data as needed.

  7. Debug Data Retrieval

  8. The manager provides a method to retrieve all stored debug information in its current state.

🛠️ Methods

  1. extract_tool_debug_info(tool_call_responses: list[ToolCallResponse], loop_iteration_index: int | None = None)
  2. Extracts debug information from a list of ToolCallResponse objects and appends it to the "tools" key in the debug store.

  3. add(key: str, value: Any)

  4. Adds a key-value pair to the debug store, merging it with the existing data.

  5. get() -> dict

  6. Retrieves the current state of the debug information.

🔄 Code Implementation

class DebugInfoManager:
    def __init__(self):
        self.debug_info = {"tools": []}

    def extract_tool_debug_info(self, tool_call_responses: list[ToolCallResponse], loop_iteration_index: int | None = None):
        for tool_call_response in tool_call_responses:
            tool_info =                {
                "name": tool_call_response.name,
                "info": {
                    **tool_call_response.debug_info
                },
            }
            if loop_iteration_index is not None:
                tool_info["info"]["loop_iteration"] = loop_iteration_index
            self.debug_info["tools"].append(tool_info)

    def add(self, key, value):
        self.debug_info = self.debug_info | {key: value}

    def get(self):
        return self.debug_info