From f5e7ca12f751d3bce8cc874b8f98d045e721a2c0 Mon Sep 17 00:00:00 2001 From: Chen <61995987@qq.com> Date: Thu, 12 Mar 2026 02:50:10 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20shell=20?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E8=87=AA=E5=AE=9A=E4=B9=89=E8=B6=85=E6=97=B6?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/computer/tools/shell.py | 5 ++++- astrbot/core/config/default.py | 11 +++++++++++ .../i18n/locales/en-US/features/config-metadata.json | 3 +++ .../i18n/locales/zh-CN/features/config-metadata.json | 3 +++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/astrbot/core/computer/tools/shell.py b/astrbot/core/computer/tools/shell.py index b5009d30fd..64ce60daa6 100644 --- a/astrbot/core/computer/tools/shell.py +++ b/astrbot/core/computer/tools/shell.py @@ -58,7 +58,10 @@ 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() + 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 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": "工具调用超时时间(秒)" }, From 3dc4bb8e345d7470c6647feed18fdc00c8b7ea44 Mon Sep 17 00:00:00 2001 From: Chen <61995987@qq.com> Date: Thu, 12 Mar 2026 03:42:09 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=B0=86shell=E8=B0=83=E7=94=A8=E6=97=B6?= =?UTF-8?q?=E7=9A=84timeout=E8=BD=AC=E4=B8=BAint=20=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E9=85=8D=E7=BD=AE=E6=97=B6=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E4=BC=A0=E9=80=92umo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/computer/tools/shell.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/astrbot/core/computer/tools/shell.py b/astrbot/core/computer/tools/shell.py index 64ce60daa6..d482603177 100644 --- a/astrbot/core/computer/tools/shell.py +++ b/astrbot/core/computer/tools/shell.py @@ -58,8 +58,10 @@ async def call( context.context.event.unified_msg_origin, ) try: - config = context.context.context.get_config() + 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) From b1a119edb4d6ee33c1ad558e24ca54a8a5757cae Mon Sep 17 00:00:00 2001 From: Chen <61995987@qq.com> Date: Thu, 12 Mar 2026 03:44:36 +0800 Subject: [PATCH 3/5] ruff --- astrbot/core/computer/tools/shell.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/astrbot/core/computer/tools/shell.py b/astrbot/core/computer/tools/shell.py index d482603177..f80b0e7da0 100644 --- a/astrbot/core/computer/tools/shell.py +++ b/astrbot/core/computer/tools/shell.py @@ -58,12 +58,16 @@ async def call( context.context.event.unified_msg_origin, ) try: - config = context.context.context.get_config(umo=context.context.event.unified_msg_origin) + 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) + + 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)}" From a1a3db22182730591610d79387454d209b0f8e39 Mon Sep 17 00:00:00 2001 From: Chen <61995987@qq.com> Date: Mon, 16 Mar 2026 18:10:23 +0800 Subject: [PATCH 4/5] =?UTF-8?q?fix-=E4=BF=AE=E6=AD=A3shell=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E6=9C=AA=E6=AD=A3=E7=A1=AE=E5=BA=94=E7=94=A8=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E8=B0=83=E7=94=A8=E8=B6=85=E6=97=B6=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/computer/tools/shell.py | 2 +- astrbot/core/config/default.py | 11 ----------- .../i18n/locales/en-US/features/config-metadata.json | 3 --- .../i18n/locales/zh-CN/features/config-metadata.json | 3 --- 4 files changed, 1 insertion(+), 18 deletions(-) diff --git a/astrbot/core/computer/tools/shell.py b/astrbot/core/computer/tools/shell.py index f80b0e7da0..dc554c312b 100644 --- a/astrbot/core/computer/tools/shell.py +++ b/astrbot/core/computer/tools/shell.py @@ -61,7 +61,7 @@ async def call( config = context.context.context.get_config( umo=context.context.event.unified_msg_origin ) - timeout = config.get("provider_settings", {}).get("shell_call_timeout", 30) + timeout = config.get("provider_settings", {}).get("tool_call_timeout", 30) # 将timeout转为int timeout = int(timeout) diff --git a/astrbot/core/config/default.py b/astrbot/core/config/default.py index 41cc4510cb..ba656ff538 100644 --- a/astrbot/core/config/default.py +++ b/astrbot/core/config/default.py @@ -118,7 +118,6 @@ "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 @@ -2543,9 +2542,6 @@ class ChatProviderTemplate(TypedDict): "tool_call_timeout": { "type": "int", }, - "shell_call_timeout": { - "type": "int", - }, "tool_schema_mode": { "type": "string", }, @@ -3288,13 +3284,6 @@ 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 13a4c9d550..3a8251cb97 100644 --- a/dashboard/src/i18n/locales/en-US/features/config-metadata.json +++ b/dashboard/src/i18n/locales/en-US/features/config-metadata.json @@ -304,9 +304,6 @@ "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 7bc80e7381..be52995189 100644 --- a/dashboard/src/i18n/locales/zh-CN/features/config-metadata.json +++ b/dashboard/src/i18n/locales/zh-CN/features/config-metadata.json @@ -307,9 +307,6 @@ "max_agent_step": { "description": "工具调用轮数上限" }, - "shell_call_timeout": { - "description": "Shell 调用超时时间(秒)" - }, "tool_call_timeout": { "description": "工具调用超时时间(秒)" }, From a027fb310c735df088060178bc7b615a3a433245 Mon Sep 17 00:00:00 2001 From: LIghtJUNction Date: Mon, 16 Mar 2026 20:34:17 +0800 Subject: [PATCH 5/5] Update astrbot/core/computer/tools/shell.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- astrbot/core/computer/tools/shell.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/astrbot/core/computer/tools/shell.py b/astrbot/core/computer/tools/shell.py index dc554c312b..251a67f361 100644 --- a/astrbot/core/computer/tools/shell.py +++ b/astrbot/core/computer/tools/shell.py @@ -61,10 +61,10 @@ async def call( config = context.context.context.get_config( umo=context.context.event.unified_msg_origin ) - timeout = config.get("provider_settings", {}).get("tool_call_timeout", 30) - # 将timeout转为int - timeout = int(timeout) - + try: + timeout = int(config.get("provider_settings", {}).get("tool_call_timeout", 30)) + except (ValueError, TypeError): + timeout = 30 result = await sb.shell.exec( command, background=background, env=env, timeout=timeout )