Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log every tool call - even python tools #300

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion holmes/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def create_console_tool_executor(
enabled_toolsets.append(ts)
logging.info(f"Loaded toolset {ts.name} from {ts.get_path()}")
elif ts.get_status() == ToolsetStatusEnum.DISABLED:
logging.info(f"Disabled toolset: {ts.name} from {ts.get_path()})")
logging.info(f"Disabled toolset: {ts.name} from {ts.get_path()}")
elif ts.get_status() == ToolsetStatusEnum.FAILED:
logging.info(
f"Failed loading toolset {ts.name} from {ts.get_path()}: ({ts.get_error()})"
Expand Down
1 change: 1 addition & 0 deletions holmes/core/tool_calling_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ def _invoke_tool(

tool_response = None
try:
tool.log(tool_params)
tool_response = tool.invoke(tool_params)
except Exception as e:
logging.error(
Expand Down
7 changes: 6 additions & 1 deletion holmes/core/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ def get_openai_format(self):

return result

def log(self, params: Dict):
logging.info(f"Running tool: {self.__class__.__name__} with params {params}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should at least log the name of the tool which is often different from the class name.
I will care for updating this PR. The plan is to have something similar to:

class Tool(ABC):
    def invoke(self, params):
        logging.info(f"Running tool: {self.get_parameterized_one_liner(context)}")
        return self._invoke(params)

    @abstractmethod
    def _invoke(self, params):
        pass

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, thanks


@abstractmethod
def invoke(self, params: Dict) -> str:
return ""
Expand Down Expand Up @@ -157,9 +160,11 @@ def _build_context(self, params):
context = {**params}
return context

def invoke(self, params) -> str:
def log(self, params):
context = self._build_context(params)
logging.info(f"Running tool: {self.get_parameterized_one_liner(context)}")

def invoke(self, params) -> str:
if self.command is not None:
raw_output = self.__invoke_command(params)
else:
Expand Down
Loading