implement 2 strategies

This commit is contained in:
Gaetan Hurel
2025-06-26 14:52:36 +02:00
parent 90ac5e9e82
commit 331e2e434d
23 changed files with 1080 additions and 747 deletions

View File

@@ -0,0 +1,6 @@
"""Custom tools for the multi-agent sysadmin system."""
from .log_tail_tool import LogTailTool
from .shell_tool_wrapper import get_shell_tool
__all__ = ["LogTailTool", "get_shell_tool"]

View File

@@ -0,0 +1,24 @@
"""Log tail tool for reading log files."""
import subprocess
from langchain_core.tools import BaseTool
class LogTailTool(BaseTool):
"""Tail the last N lines from a log file."""
name: str = "tail_log"
description: str = "Tail the last N lines of a log file given its path and optional number of lines."
def _run(self, path: str, lines: int = 500): # type: ignore[override]
"""Run the tool to tail log files."""
try:
return subprocess.check_output(["tail", "-n", str(lines), path], text=True)
except subprocess.CalledProcessError as e:
return f"Error reading log file {path}: {e}"
except FileNotFoundError:
return f"Log file not found: {path}"
async def _arun(self, *args, **kwargs): # noqa: D401
"""Async version not implemented."""
raise NotImplementedError("Use the synchronous version of this tool.")

View File

@@ -0,0 +1,8 @@
"""Shell tool wrapper for consistent access."""
from langchain_community.tools import ShellTool
def get_shell_tool() -> ShellTool:
"""Get a configured shell tool instance."""
return ShellTool()