feat: implement code execution sandbox for programmatic tool calling
- Introduced a new `execute_code` tool that allows the agent to run Python scripts that call Hermes tools via RPC, reducing the number of round trips required for tool interactions. - Added configuration options for timeout and maximum tool calls in the sandbox environment. - Updated the toolset definitions to include the new code execution capabilities, ensuring integration across platforms. - Implemented comprehensive tests for the code execution sandbox, covering various scenarios including tool call limits and error handling. - Enhanced the CLI and documentation to reflect the new functionality, providing users with clear guidance on using the code execution tool.
This commit is contained in:
parent
748f0b2b5f
commit
783acd712d
10 changed files with 1598 additions and 18 deletions
|
|
@ -1594,6 +1594,12 @@ class AIAgent:
|
|||
detail = rl.get(tool_name, tool_name.replace("rl_", ""))
|
||||
return f"┊ 🧪 rl {detail} {dur}"
|
||||
|
||||
# ── Code Execution Sandbox ──
|
||||
if tool_name == "execute_code":
|
||||
code = args.get("code", "")
|
||||
first_line = code.strip().split("\n")[0] if code.strip() else ""
|
||||
return f"┊ 🐍 exec {_trunc(first_line, 35)} {dur}"
|
||||
|
||||
# ── Fallback ──
|
||||
preview = _build_tool_preview(tool_name, args) or ""
|
||||
return f"┊ ⚡ {tool_name[:9]:9} {_trunc(preview, 35)} {dur}"
|
||||
|
|
@ -2970,7 +2976,7 @@ class AIAgent:
|
|||
'skills_list': '📚', 'skill_view': '📚',
|
||||
'schedule_cronjob': '⏰', 'list_cronjobs': '⏰', 'remove_cronjob': '⏰',
|
||||
'send_message': '📨', 'todo': '📋', 'memory': '🧠', 'session_search': '🔍',
|
||||
'clarify': '❓',
|
||||
'clarify': '❓', 'execute_code': '🐍',
|
||||
}
|
||||
emoji = tool_emoji_map.get(function_name, '⚡')
|
||||
preview = _build_tool_preview(function_name, function_args) or function_name
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue