Skip to content

Conversation

@Soulter
Copy link
Member

@Soulter Soulter commented Jan 5, 2026

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:

  • 修复了在向 provider response 实体构造函数传递非空值时,响应 ID 和令牌使用数据会丢失的问题。
Original summary in English

Summary by Sourcery

Bug Fixes:

  • Fix loss of response ID and token usage data when non-null values are passed to the provider response entity constructor.

@auto-assign auto-assign bot requested review from Fridemn and LIghtJUNction January 5, 2026 09:05
@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jan 5, 2026
@Soulter Soulter merged commit 3615b7d into master Jan 5, 2026
4 of 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 - 我在这里给出了一些高层次的反馈:

  • 仅在参数非 None 时才初始化 self.idself.usage,可能会导致在某些代码路径下这些属性根本没有被定义;建议始终对它们进行赋值(例如设置为 None 或一个合理的默认值),并在需要的地方显式处理 None 情况,这样可以避免潜在的 AttributeError,同时保持对象结构的一致性。
给 AI Agent 的提示
Please address the comments from this code review:

## Overall Comments
- Initializing `self.id` and `self.usage` only when the arguments are non-`None` may leave these attributes undefined in some code paths; consider always setting them (e.g., to `None` or a sensible default) and handling the `None` case where needed to avoid potential `AttributeError`s and keep the object shape consistent.

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

Hey - I've left some high level feedback:

  • Initializing self.id and self.usage only when the arguments are non-None may leave these attributes undefined in some code paths; consider always setting them (e.g., to None or a sensible default) and handling the None case where needed to avoid potential AttributeErrors and keep the object shape consistent.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Initializing `self.id` and `self.usage` only when the arguments are non-`None` may leave these attributes undefined in some code paths; consider always setting them (e.g., to `None` or a sensible default) and handling the `None` case where needed to avoid potential `AttributeError`s and keep the object shape consistent.

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.

@Soulter Soulter deleted the fix/anthropic-source-token-usage-o branch January 5, 2026 09:06
@dosubot dosubot bot added the area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. label Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants