Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion astrbot/core/computer/tools/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ async def call(
context.context.event.unified_msg_origin,
)
try:
result = await sb.shell.exec(command, background=background, env=env)
# 从上下文获取工具调用超时时间配置,传递给 shell.exec
timeout = context.tool_call_timeout
result = await sb.shell.exec(
command, background=background, env=env, timeout=timeout
)
Comment on lines +61 to +65
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

建议移除冗余的中间变量和中文注释,直接将 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
  1. Google Python Style Guide 建议所有注释都应使用英文,以保持代码库的一致性。 (link)

return json.dumps(result)
except Exception as e:
return f"Error executing command: {str(e)}"