diff --git a/astrbot/core/computer/tools/shell.py b/astrbot/core/computer/tools/shell.py index b5009d30fd..f80b0e7da0 100644 --- a/astrbot/core/computer/tools/shell.py +++ b/astrbot/core/computer/tools/shell.py @@ -58,7 +58,16 @@ async def call( context.context.event.unified_msg_origin, ) try: - result = await sb.shell.exec(command, background=background, env=env) + config = context.context.context.get_config( + umo=context.context.event.unified_msg_origin + ) + timeout = config.get("provider_settings", {}).get("shell_call_timeout", 30) + # 将timeout转为int + timeout = int(timeout) + + 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 ba656ff538..41cc4510cb 100644 --- a/astrbot/core/config/default.py +++ b/astrbot/core/config/default.py @@ -118,6 +118,7 @@ "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 @@ class ChatProviderTemplate(TypedDict): "tool_call_timeout": { "type": "int", }, + "shell_call_timeout": { + "type": "int", + }, "tool_schema_mode": { "type": "string", }, @@ -3284,6 +3288,13 @@ class ChatProviderTemplate(TypedDict): "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 3a8251cb97..13a4c9d550 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 be52995189..7bc80e7381 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": "工具调用超时时间(秒)" },