Skip to content

Fix 修正shell工具未正确应用工具调用超时的问题#6434

Merged
LIghtJUNction merged 7 commits intoAstrBotDevs:devfrom
a61995987:fix-修正shell工具未正确应用工具调用超时的问题
Mar 16, 2026

Hidden character warning

The head ref may contain hidden characters: "fix-\u4fee\u6b63shell\u5de5\u5177\u672a\u6b63\u786e\u5e94\u7528\u5de5\u5177\u8c03\u7528\u8d85\u65f6\u7684\u95ee\u9898"
Merged

Fix 修正shell工具未正确应用工具调用超时的问题#6434
LIghtJUNction merged 7 commits intoAstrBotDevs:devfrom
a61995987:fix-修正shell工具未正确应用工具调用超时的问题

Conversation

@a61995987
Copy link
Contributor

@a61995987 a61995987 commented Mar 16, 2026

某些特殊技能脚本可能需要更长的执行时间 且需要将执行结果实时返回给LLM(如使用yt-dlp库在youtube上抓取字幕 该库在游客身份下获取字幕列表后 必须等待60秒才能够进行字幕下载 否则会报429错误)
该PR对shell工具引入了工具调用超时参数 使其能够正确接收工具调用超时设置而非硬编码的30秒
修改自PR(#6076)

Modifications / 改动点

修改文件:astrbot/core/computer/tools/shell.py

  1. 修改call方法中的sb.shell.exec调用 传入系统配置(tool_call_timeout)

Screenshots or Test Results / 运行截图或测试结果


Checklist / 检查清单

  • 😊 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。
    / If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.

  • 👀 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”
    / My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.

  • 🤓 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txtpyproject.toml 文件相应位置。
    / I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.

  • 😮 我的更改没有引入恶意代码。
    / My changes do not introduce malicious code.

  • ⚠️ 我已认真阅读并理解以上所有内容,确保本次提交符合规范。
    / I have read and understood all the above and confirm this PR follows the rules.

  • 🚀 我确保本次开发基于 dev 分支,并将代码合并至开发分支(除非极其紧急,才允许合并到主分支)。
    / I confirm that this development is based on the dev branch and will be merged into the development branch, unless it is extremely urgent to merge into the main branch.

  • ⚠️没有认真阅读以上内容,直接提交。
    / I did not read the above carefully before submitting.

Summary by Sourcery

Bug Fixes:

  • Use the provider_settings.tool_call_timeout configuration value for shell tool executions, falling back to 30 seconds if not set.

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Mar 16, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求旨在增强shell工具的灵活性和鲁棒性,通过允许其根据系统配置动态调整命令执行超时时间。这确保了需要较长执行时间的脚本(例如数据抓取或复杂处理任务)不会因默认的硬编码超时而过早终止,从而提高了工具的可靠性和适用性。

Highlights

  • 工具调用超时配置: 为shell工具引入了可配置的工具调用超时参数,使其能够根据系统设置动态调整执行时间。
  • 解决长时间运行脚本问题: 解决了某些特殊技能脚本(如使用yt-dlp抓取字幕)可能因默认30秒硬编码超时而中断的问题。
Changelog
  • astrbot/core/computer/tools/shell.py
    • 修改了call方法,使其从配置中获取tool_call_timeout参数,并将其传递给sb.shell.exec调用,取代了之前硬编码的30秒超时。
Activity
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • When converting tool_call_timeout to an int, consider handling non-numeric or malformed values (e.g., try/except ValueError with a sane fallback) to avoid failing the entire tool call if the config is misconfigured.
  • It may be useful to validate that the resolved timeout is positive and within a reasonable upper bound before passing it to sb.shell.exec, so that misconfigured timeouts (e.g., 0 or extremely large values) don't cause unintended behavior.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- When converting `tool_call_timeout` to an `int`, consider handling non-numeric or malformed values (e.g., try/except ValueError with a sane fallback) to avoid failing the entire tool call if the config is misconfigured.
- It may be useful to validate that the resolved timeout is positive and within a reasonable upper bound before passing it to `sb.shell.exec`, so that misconfigured timeouts (e.g., 0 or extremely large values) don't cause unintended behavior.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@dosubot dosubot bot added the area:core The bug / feature is about astrbot's core, backend label Mar 16, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

这个 Pull Request 很好地解决了 shell 工具未使用可配置超时的问题,改为从配置中读取 tool_call_timeout。我的审查意见主要是为了提高配置值解析的健壮性。我建议进行一处修改,以妥善处理将超时值转换为整数时可能发生的错误,这样可以避免工具因配置无效而中断,从而提高其稳定性。

@rin259
Copy link
Contributor

rin259 commented Mar 16, 2026

某些特殊技能脚本可能需要更长的执行时间 且需要将执行结果实时返回给LLM(如使用yt-dlp库在youtube上抓取字幕 该库在游客身份下获取字幕列表后 必须等待60秒才能够进行字幕下载 否则会报429错误) 该PR对shell工具引入了工具调用超时参数 使其能够正确接收工具调用超时设置而非硬编码的30秒 修改自PR(#6076)

Modifications / 改动点

修改文件:astrbot/core/computer/tools/shell.py

  1. 修改call方法中的sb.shell.exec调用 传入系统配置(tool_call_timeout)

Screenshots or Test Results / 运行截图或测试结果

Checklist / 检查清单

  • 😊 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。
    / If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
  • 👀 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”
    / My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
  • 🤓 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txtpyproject.toml 文件相应位置。
    / I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
  • 😮 我的更改没有引入恶意代码。
    / My changes do not introduce malicious code.
  • ⚠️ 我已认真阅读并理解以上所有内容,确保本次提交符合规范。
    / I have read and understood all the above and confirm this PR follows the rules.
  • 🚀 我确保本次开发基于 dev 分支,并将代码合并至开发分支(除非极其紧急,才允许合并到主分支)。
    / I confirm that this development is based on the dev branch and will be merged into the development branch, unless it is extremely urgent to merge into the main branch.
  • ⚠️没有认真阅读以上内容,直接提交。
    / I did not read the above carefully before submitting.

Summary by Sourcery

Bug Fixes:

  • Use the provider_settings.tool_call_timeout configuration value for shell tool executions, falling back to 30 seconds if not set.

关于工具调用之前有个恶性bug,delta.data和data没有同时判定的

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@LIghtJUNction
Copy link
Member

lgtm

@LIghtJUNction
Copy link
Member

@a61995987 合并后,在这里:#6325 跟踪进度

@a61995987
Copy link
Contributor Author

a61995987 commented Mar 16, 2026

某些特殊技能脚本可能需要更长的执行时间 且需要将执行结果实时返回给LLM(如使用yt-dlp库在youtube上抓取字幕 该库在游客身份下获取字幕列表后 必须等待60秒才能够进行字幕下载 否则会报429错误) 该PR对shell工具引入了工具调用超时参数 使其能够正确接收工具调用超时设置而非硬编码的30秒 修改自PR(#6076)

Modifications / 改动点

修改文件:astrbot/core/computer/tools/shell.py

  1. 修改call方法中的sb.shell.exec调用 传入系统配置(tool_call_timeout)

Screenshots or Test Results / 运行截图或测试结果

Checklist / 检查清单

  • 😊 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。
    / If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
  • 👀 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”
    / My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
  • 🤓 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txtpyproject.toml 文件相应位置。
    / I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
  • 😮 我的更改没有引入恶意代码。
    / My changes do not introduce malicious code.
  • ⚠️ 我已认真阅读并理解以上所有内容,确保本次提交符合规范。
    / I have read and understood all the above and confirm this PR follows the rules.
  • 🚀 我确保本次开发基于 dev 分支,并将代码合并至开发分支(除非极其紧急,才允许合并到主分支)。
    / I confirm that this development is based on the dev branch and will be merged into the development branch, unless it is extremely urgent to merge into the main branch.
  • ⚠️没有认真阅读以上内容,直接提交。
    / I did not read the above carefully before submitting.

Summary by Sourcery

Bug Fixes:

  • Use the provider_settings.tool_call_timeout configuration value for shell tool executions, falling back to 30 seconds if not set.

关于工具调用之前有个恶性bug,delta.data和data没有同时判定的

请问指的是agent执行器中deerflow的模型提供商流式请求的过程中出现的么?还是其他地方?
关于deerflow提供商 我目前没有条件进行测试

@LIghtJUNction LIghtJUNction merged commit a05bfed into AstrBotDevs:dev Mar 16, 2026
2 checks passed
@rin259
Copy link
Contributor

rin259 commented Mar 16, 2026

某些特殊技能脚本可能需要更长的执行时间 且需要将执行结果实时返回给LLM(如使用yt-dlp库在youtube上抓取字幕 该库在游客身份下获取字幕列表后 必须等待60秒才能够进行字幕下载 否则会报429错误) 该PR对shell工具引入了工具调用超时参数 使其能够正确接收工具调用超时设置而非硬编码的30秒 修改自PR(#6076)

Modifications / 改动点

修改文件:astrbot/core/computer/tools/shell.py

  1. 修改call方法中的sb.shell.exec调用 传入系统配置(tool_call_timeout)

Screenshots or Test Results / 运行截图或测试结果

Checklist / 检查清单

  • 😊 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。
    / If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
  • 👀 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”
    / My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
  • 🤓 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txtpyproject.toml 文件相应位置。
    / I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
  • 😮 我的更改没有引入恶意代码。
    / My changes do not introduce malicious code.
  • ⚠️ 我已认真阅读并理解以上所有内容,确保本次提交符合规范。
    / I have read and understood all the above and confirm this PR follows the rules.
  • 🚀 我确保本次开发基于 dev 分支,并将代码合并至开发分支(除非极其紧急,才允许合并到主分支)。
    / I confirm that this development is based on the dev branch and will be merged into the development branch, unless it is extremely urgent to merge into the main branch.
  • ⚠️没有认真阅读以上内容,直接提交。
    / I did not read the above carefully before submitting.

Summary by Sourcery

Bug Fixes:

  • Use the provider_settings.tool_call_timeout configuration value for shell tool executions, falling back to 30 seconds if not set.

关于工具调用之前有个恶性bug,delta.data和data没有同时判定的

请问指的是agent执行器中deerflow的模型提供商流式请求的过程中出现的么?还是其他地方?

是开启streaming返回的时候,出现了任何tool无法调用的情况,我提交的pr先前已经合并到master了

@a61995987
Copy link
Contributor Author

@a61995987 合并后,在这里:#6325 跟踪进度

收到 感谢

@a61995987
Copy link
Contributor Author

某些特殊技能脚本可能需要更长的执行时间 且需要将执行结果实时返回给LLM(如使用yt-dlp库在youtube上抓取字幕 该库在游客身份下获取字幕列表后 必须等待60秒才能够进行字幕下载 否则会报429错误) 该PR对shell工具引入了工具调用超时参数 使其能够正确接收工具调用超时设置而非硬编码的30秒 修改自PR(#6076)

Modifications / 改动点

修改文件:astrbot/core/computer/tools/shell.py

  1. 修改call方法中的sb.shell.exec调用 传入系统配置(tool_call_timeout)

Screenshots or Test Results / 运行截图或测试结果

Checklist / 检查清单

  • 😊 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。
    / If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
  • 👀 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”
    / My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
  • 🤓 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txtpyproject.toml 文件相应位置。
    / I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
  • 😮 我的更改没有引入恶意代码。
    / My changes do not introduce malicious code.
  • ⚠️ 我已认真阅读并理解以上所有内容,确保本次提交符合规范。
    / I have read and understood all the above and confirm this PR follows the rules.
  • 🚀 我确保本次开发基于 dev 分支,并将代码合并至开发分支(除非极其紧急,才允许合并到主分支)。
    / I confirm that this development is based on the dev branch and will be merged into the development branch, unless it is extremely urgent to merge into the main branch.
  • ⚠️没有认真阅读以上内容,直接提交。
    / I did not read the above carefully before submitting.

Summary by Sourcery

Bug Fixes:

  • Use the provider_settings.tool_call_timeout configuration value for shell tool executions, falling back to 30 seconds if not set.

关于工具调用之前有个恶性bug,delta.data和data没有同时判定的

请问指的是agent执行器中deerflow的模型提供商流式请求的过程中出现的么?还是其他地方?

是开启streaming返回的时候,出现了任何tool无法调用的情况,我提交的pr先前已经合并到master了

OK 我看到了 但好像咱们两个的PR并没有冲突 没问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core The bug / feature is about astrbot's core, backend size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants