fix: pass tool_call_timeout to shell.exec for configurable shell timeout#7310
Draft
sunnyyangyangyang wants to merge 1 commit intoAstrBotDevs:masterfrom
Draft
fix: pass tool_call_timeout to shell.exec for configurable shell timeout#7310sunnyyangyangyang wants to merge 1 commit intoAstrBotDevs:masterfrom
sunnyyangyangyang wants to merge 1 commit intoAstrBotDevs:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the shell tool to incorporate a configurable timeout for command execution by passing context.tool_call_timeout to the sb.shell.exec method. The review feedback suggests simplifying the implementation by removing the intermediate variable and the Chinese comment to improve code clarity and maintain style consistency.
Comment on lines
+61
to
+65
| # 从上下文获取工具调用超时时间配置,传递给 shell.exec | ||
| timeout = context.tool_call_timeout | ||
| result = await sb.shell.exec( | ||
| command, background=background, env=env, timeout=timeout | ||
| ) |
Contributor
There was a problem hiding this comment.
建议移除冗余的中间变量和中文注释,直接将 context.tool_call_timeout 传递给 sb.shell.exec。根据 Google Python 风格指南,代码注释应使用英文以保持一致性,且此处代码逻辑已足够清晰,无需额外注释。
result = await sb.shell.exec(
command, background=background, env=env, timeout=context.tool_call_timeout
)References
- Google Python Style Guide 建议所有注释都应使用英文,以保持代码库的一致性。 (link)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR 描述(Draft)
Modifications / 改动点
修复了
astrbot_execute_shell工具的超时时间配置功能,使得用户可以通过管理面板中的"工具调用超时时间(秒)"设置来控制 shell 执行的超时时间。问题描述:
ExecuteShellTool调用shell.exec()时,没有传递timeout参数,导致始终使用接口默认的 30 秒超时tool_call_timeout设置为 600 秒,shell 执行仍然是 30 秒就超时修复方案:
context.tool_call_timeout获取配置的超时时间tool_call_timeout传递给shell.exec()的timeout参数修改文件:
astrbot/core/computer/tools/shell.pyScreenshots or Test Results / 运行截图或测试结果
注意:这是一个 Draft PR,目前代码尚未经过实际测试。
测试步骤建议:
tool_call_timeout为较大值(如 600)astrbot_execute_shell工具执行一个耗时较长的命令Checklist / 检查清单
requirements.txtandpyproject.toml.状态:Draft PR - 待测试
Summary by Sourcery
Bug Fixes: