From bab9c75b5b40bfa8788aaec8a3c6f606bb60d240 Mon Sep 17 00:00:00 2001 From: hjc-puro Date: Sat, 26 Jul 2025 04:43:07 +0000 Subject: [PATCH] more detailed desc --- model_tools.py | 4 ++-- terminal_tool.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/model_tools.py b/model_tools.py index d8d300725..6a6c59f67 100644 --- a/model_tools.py +++ b/model_tools.py @@ -24,7 +24,7 @@ from typing import Dict, Any, List # Import toolsets from web_tools import web_search_tool, web_extract_tool, web_crawl_tool, check_tavily_api_key -from terminal_tool import terminal_tool, check_hecate_requirements +from terminal_tool import terminal_tool, check_hecate_requirements, TERMINAL_TOOL_DESCRIPTION def get_web_tool_definitions() -> List[Dict[str, Any]]: """ @@ -123,7 +123,7 @@ def get_terminal_tool_definitions() -> List[Dict[str, Any]]: "type": "function", "function": { "name": "terminal", - "description": "Execute commands on a Linux VM with optional interactive session support. Automatically manages VM lifecycle - creates VMs on demand, reuses existing VMs, and cleans up after inactivity. Can handle both simple commands and interactive sessions.", + "description": TERMINAL_TOOL_DESCRIPTION, "parameters": { "type": "object", "properties": { diff --git a/terminal_tool.py b/terminal_tool.py index 012c05906..7f77c06d5 100644 --- a/terminal_tool.py +++ b/terminal_tool.py @@ -25,6 +25,53 @@ from typing import Optional, Dict, Any from hecate import run_tool_with_lifecycle_management from morphcloud._llm import ToolCall +# Detailed description for the terminal tool based on Hermes Terminal system prompt +TERMINAL_TOOL_DESCRIPTION = """Execute commands on a secure, persistent Linux VM environment with full interactive application support. + +**Environment:** +- Minimal Debian-based OS with internet access +- Automatic VM lifecycle management (creates on-demand, reuses, cleans up) +- **Full state persistence across tool calls**: current directory (pwd), environment variables, activated virtual environments (conda/venv), running processes, and command history all persist between consecutive tool calls +- Session state managed automatically via tmux + +**Command Execution:** +- Simple commands: Just provide the 'command' parameter +- Background processes: Set 'background': True for servers/long-running tasks +- Interactive applications automatically detected and handled + +**Interactive Applications (TUIs/Pagers/Prompts):** +When commands enter interactive mode (vim, nano, less, git prompts, package managers, etc.), you'll receive screen content with "frozen" status. This is NORMAL - the session is still active and waiting for input. + +**To interact with frozen sessions:** +1. Use 'input_keys' parameter with keystrokes to send +2. System auto-detects and uses the active session +3. Session stays active until application exits + +**Special Key Syntax for input_keys:** +- ``: Escape key +- ``: Enter/Return +- ``, ``, ``: Control combinations +- ``, ``, ``, ``: Arrow keys +- ``, ``: Tab and Backspace +- `` through ``: Function keys +- ``: Shift+Tab +- Uppercase letters for Shift+letter (e.g., 'V' for Shift+V) +- Symbols for Shift+number (e.g., '!' for Shift+1, ':' for Shift+;) + +**Examples:** +- Start vim: `{"command": "vim file.txt"}` +- Type in vim: `{"input_keys": "iHello World"}` +- Save and quit: `{"input_keys": ":wq"}` +- Navigate in less: `{"input_keys": "j"}` +- Quit less: `{"input_keys": "q"}` + +**Best Practices:** +- Run servers/long processes in background with separate tool calls +- Chain multiple foreground commands in single call if needed +- Monitor disk usage for large tasks, clean up to free space +- Test components incrementally with mock inputs +- Install whatever tools needed - full system access provided""" + def terminal_tool( command: Optional[str] = None, input_keys: Optional[str] = None,