diff --git a/astrbot/core/computer/tools/shell.py b/astrbot/core/computer/tools/shell.py index b5009d30f..64ce60daa 100644 --- a/astrbot/core/computer/tools/shell.py +++ b/astrbot/core/computer/tools/shell.py @@ -58,7 +58,10 @@ class ExecuteShellTool(FunctionTool): context.context.event.unified_msg_origin, ) try: - result = await sb.shell.exec(command, background=background, env=env) + config = context.context.context.get_config() + timeout = config.get("provider_settings", {}).get("shell_call_timeout", 30) + + result = await sb.shell.exec(command, background=background, env=env, timeout=timeout) return json.dumps(result) except Exception as e: return f"Error executing command: {str(e)}" diff --git a/astrbot/core/config/default.py b/astrbot/core/config/default.py index ba656ff53..41cc4510c 100644 --- a/astrbot/core/config/default.py +++ b/astrbot/core/config/default.py @@ -118,6 +118,7 @@ DEFAULT_CONFIG = { "reachability_check": False, "max_agent_step": 30, "tool_call_timeout": 60, + "shell_call_timeout": 30, "tool_schema_mode": "full", "llm_safety_mode": True, "safety_mode_strategy": "system_prompt", # TODO: llm judge @@ -2542,6 +2543,9 @@ CONFIG_METADATA_2 = { "tool_call_timeout": { "type": "int", }, + "shell_call_timeout": { + "type": "int", + }, "tool_schema_mode": { "type": "string", }, @@ -3284,6 +3288,13 @@ CONFIG_METADATA_3 = { "provider_settings.agent_runner_type": "local", }, }, + "provider_settings.shell_call_timeout": { + "description": "Shell 工具调用超时时间(秒)", + "type": "int", + "condition": { + "provider_settings.agent_runner_type": "local", + }, + }, "provider_settings.tool_call_timeout": { "description": "工具调用超时时间(秒)", "type": "int", diff --git a/dashboard/src/i18n/locales/en-US/features/config-metadata.json b/dashboard/src/i18n/locales/en-US/features/config-metadata.json index 3a8251cb9..13a4c9d55 100644 --- a/dashboard/src/i18n/locales/en-US/features/config-metadata.json +++ b/dashboard/src/i18n/locales/en-US/features/config-metadata.json @@ -304,6 +304,9 @@ "max_agent_step": { "description": "Maximum Tool Call Rounds" }, + "shell_call_timeout": { + "description": "Shell Call Timeout (s)" + }, "tool_call_timeout": { "description": "Tool Call Timeout (seconds)" }, diff --git a/dashboard/src/i18n/locales/zh-CN/features/config-metadata.json b/dashboard/src/i18n/locales/zh-CN/features/config-metadata.json index be5299518..7bc80e738 100644 --- a/dashboard/src/i18n/locales/zh-CN/features/config-metadata.json +++ b/dashboard/src/i18n/locales/zh-CN/features/config-metadata.json @@ -307,6 +307,9 @@ "max_agent_step": { "description": "工具调用轮数上限" }, + "shell_call_timeout": { + "description": "Shell 调用超时时间(秒)" + }, "tool_call_timeout": { "description": "工具调用超时时间(秒)" },