fix: extend run_command foreground timeout limit to 120s

This commit is contained in:
JOJO 2026-04-25 16:34:56 +08:00
parent 070d77c070
commit d541d9bd30
4 changed files with 6 additions and 6 deletions

View File

@ -10,7 +10,7 @@ MAX_UPLOAD_SIZE = 50 * 1024 * 1024
# 执行超时
CODE_EXECUTION_TIMEOUT = 60
TERMINAL_COMMAND_TIMEOUT = 30
TERMINAL_COMMAND_TIMEOUT = 120
SEARCH_MAX_RESULTS = 10
# 自动修复与工具调用限制None 表示不限制)

View File

@ -614,14 +614,14 @@ class MainTerminalToolsDefinitionMixin:
"type": "function",
"function": {
"name": "run_command",
"description": "执行一次性终端命令适合查看文件信息file/ls/stat/iconv 等)、转换编码或调用 CLI 工具。禁止启动交互式程序。必须提供 timeout。前台模式run_in_background=false默认上限60秒超时会打断后台模式run_in_background=true上限3600秒会先等待5秒返回已有输出并继续在后台运行完成后由系统通知。",
"description": "执行一次性终端命令适合查看文件信息file/ls/stat/iconv 等)、转换编码或调用 CLI 工具。禁止启动交互式程序。必须提供 timeout。前台模式run_in_background=false默认上限120秒超时会打断后台模式run_in_background=true上限3600秒会先等待5秒返回已有输出并继续在后台运行完成后由系统通知。",
"parameters": {
"type": "object",
"properties": self._inject_intent({
"command": {"type": "string", "description": "终端命令"},
"timeout": {
"type": "number",
"description": "超时时长(秒),必填。前台最大60后台最大3600。"
"description": "超时时长(秒),必填。前台最大120后台最大3600。"
},
"run_in_background": {
"type": "boolean",

View File

@ -1182,10 +1182,10 @@ class MainTerminalToolsExecutionMixin:
"success": False,
"error": "timeout 参数必填且需大于0"
}
elif float(timeout_value) > 60:
elif float(timeout_value) > 120:
result = {
"success": False,
"error": "前台模式下 timeout 最大为 60 秒"
"error": "前台模式下 timeout 最大为 120 秒"
}
else:
result = await self.terminal_ops.run_command(

View File

@ -314,7 +314,7 @@ class TerminalOperator:
"return_code": -1
}
# 默认10s上限30s
# 默认10s上限由 TERMINAL_COMMAND_TIMEOUT 控制
timeout = self._clamp_timeout(timeout, default=10, max_limit=TERMINAL_COMMAND_TIMEOUT)
print(f"{OUTPUT_FORMATS['terminal']} 执行命令: {command}")