Skip to content

perf: 优化分段回复间隔时间的初始化逻辑#5068

Merged
Soulter merged 1 commit intomasterfrom
fix5059
Feb 12, 2026
Merged

perf: 优化分段回复间隔时间的初始化逻辑#5068
Soulter merged 1 commit intomasterfrom
fix5059

Conversation

@Soulter
Copy link
Member

@Soulter Soulter commented Feb 12, 2026

fixes: #5059

Modifications / 改动点

  • This is NOT a breaking change. / 这不是一个破坏性变更。

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.

Summary by Sourcery

在解析分段回复时间间隔时增加特性开关保护,并在初始化期间设置更安全的默认间隔。

Bug Fixes(错误修复):

  • 当分段回复被禁用时,跳过时间间隔解析,避免在功能未启用时产生错误。

Enhancements(增强功能):

  • 在应用配置覆盖之前,为分段回复时间间隔初始化一个合理的默认值。
Original summary in English

Summary by Sourcery

Guard segmented reply interval parsing with the feature flag and set a safer default interval during initialization.

Bug Fixes:

  • Prevent errors when segmented replies are disabled by skipping interval parsing unless the feature is enabled.

Enhancements:

  • Initialize segmented reply intervals with a sensible default before applying configuration overrides.

@auto-assign auto-assign bot requested review from Raven95676 and anka-afk February 12, 2026 11:18
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Feb 12, 2026
@dosubot
Copy link

dosubot bot commented Feb 12, 2026

Related Documentation

Checked 1 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

@Soulter Soulter merged commit d87bfb0 into master Feb 12, 2026
5 checks passed
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 - 我在这里给出了一些高层次的反馈:

  • 在这里捕获 BaseException 范围太广了;建议改为捕获 Exception(或更具体的错误,比如 ValueError),这样就不会把像 KeyboardInterruptSystemExit 这样的关键异常也吞掉。
  • 默认区间 [1.5, 3.5] 现在是硬编码在方法里的;建议把它提取为一个模块级常量或配置项,这样在复用和统一调整时会更容易。
  • 在新的逻辑下,只有当 enable_seg 为 true 时才会记录区间;如果在分段关闭时依然需要通过日志了解区间以便调试,你可能也需要在条件之外保留一条日志。
供 AI Agent 使用的提示词
Please address the comments from this code review:

## Overall Comments
- Catching `BaseException` is overly broad here; consider catching `Exception` (or more specific errors like `ValueError`) so that critical exceptions like `KeyboardInterrupt` or `SystemExit` are not swallowed.
- The default interval `[1.5, 3.5]` is now hard-coded in the method; consider extracting this into a module-level constant or config value so it is easier to reuse and adjust consistently.
- With the new logic, the interval is only logged when `enable_seg` is true; if it’s useful for debugging to know the interval even when segmentation is disabled, you might want to keep a log line outside the condition as well.

Sourcery 对开源项目是免费的——如果你喜欢我们的评审,请考虑分享一下 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English

Hey - I've left some high level feedback:

  • Catching BaseException is overly broad here; consider catching Exception (or more specific errors like ValueError) so that critical exceptions like KeyboardInterrupt or SystemExit are not swallowed.
  • The default interval [1.5, 3.5] is now hard-coded in the method; consider extracting this into a module-level constant or config value so it is easier to reuse and adjust consistently.
  • With the new logic, the interval is only logged when enable_seg is true; if it’s useful for debugging to know the interval even when segmentation is disabled, you might want to keep a log line outside the condition as well.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Catching `BaseException` is overly broad here; consider catching `Exception` (or more specific errors like `ValueError`) so that critical exceptions like `KeyboardInterrupt` or `SystemExit` are not swallowed.
- The default interval `[1.5, 3.5]` is now hard-coded in the method; consider extracting this into a module-level constant or config value so it is easier to reuse and adjust consistently.
- With the new logic, the interval is only logged when `enable_seg` is true; if it’s useful for debugging to know the interval even when segmentation is disabled, you might want to keep a log line outside the condition as well.

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 Feb 12, 2026
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.

[Bug]

1 participant