Skip to content

fix(custom-tools)#904

Merged
TimeBomb2018 merged 1 commit intorelease/v0.3.0from
fix/Timebomb_030
Apr 15, 2026
Merged

fix(custom-tools)#904
TimeBomb2018 merged 1 commit intorelease/v0.3.0from
fix/Timebomb_030

Conversation

@TimeBomb2018
Copy link
Copy Markdown
Collaborator

@TimeBomb2018 TimeBomb2018 commented Apr 15, 2026

remove parameter coercion in custom tool base class

Summary by Sourcery

错误修复:

  • 停止在自定义工具中强制转换查询参数和请求体参数的类型,以避免在发出的 HTTP 请求中出现意外的值转换。
Original summary in English

Summary by Sourcery

Bug Fixes:

  • Stop coercing query and body parameter types in custom tools to avoid unexpected value transformations in outgoing HTTP requests.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Apr 15, 2026

审阅者指南(在小型 PR 上折叠显示)

审阅者指南

停止将自定义工具参数强制转换为带类型的值,而是按原样转发到查询字符串和请求体中,从而简化自定义工具基类的行为。

更新后的自定义工具基类参数处理类图

classDiagram
    class CustomToolBase_before {
        _build_request_url(operation: Dict~str, Any~, params: Dict~str, Any~) Dict~str, Any~
        _build_request_headers(operation: Dict~str, Any~) Dict~str, str~
        _coerce_param(value: Any, schema_type: str) Any
        _build_request_data(operation: Dict~str, Any~, params: Dict~str, Any~) Optional~Dict~str, Any~~
        _send_http_request(operation: Dict~str, Any~, params: Dict~str, Any~) Any
    }

    class CustomToolBase_after {
        _build_request_url(operation: Dict~str, Any~, params: Dict~str, Any~) Dict~str, Any~
        _build_request_headers(operation: Dict~str, Any~) Dict~str, str~
        _build_request_data(operation: Dict~str, Any~, params: Dict~str, Any~) Optional~Dict~str, Any~~
        _send_http_request(operation: Dict~str, Any~, params: Dict~str, Any~) Any
    }

    CustomToolBase_before <|-- CustomToolBase_after

    note for CustomToolBase_before "Parameters for query and body are coerced using _coerce_param before being sent"
    note for CustomToolBase_after "Parameter coercion removed; values are forwarded as-is into query strings and request bodies"
Loading

文件级变更

变更 详情 文件
停止对查询参数和请求体字段进行强制转换;直接传递提供的原始值。
  • 在构建查询参数时移除对内部强制转换辅助函数的使用,改为直接赋值原始参数。
  • 在构建请求体数据时移除对内部强制转换辅助函数的使用,改为直接赋值原始参数。
  • 删除不再使用的 _coerce_param 助手实现,并相应更新请求体构建函数的签名。
api/app/core/tools/custom/base.py

提示与命令

与 Sourcery 交互

  • 触发一次新审阅: 在 pull request 上评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审阅评论。
  • 从审阅评论生成 GitHub issue: 通过回复某条审阅评论,请求 Sourcery 从该评论创建一个 issue。你也可以直接回复该评论 @sourcery-ai issue 来从中创建 issue。
  • 生成 pull request 标题: 在 pull request 标题的任意位置写上 @sourcery-ai,可随时生成标题。你也可以在 pull request 上评论 @sourcery-ai title 来(重新)生成标题。
  • 生成 pull request 摘要: 在 pull request 正文的任意位置写上 @sourcery-ai summary,即可在你想要的位置生成 PR 摘要。你也可以在 pull request 上评论 @sourcery-ai summary 来(重新)生成摘要。
  • 生成审阅者指南: 在 pull request 上评论 @sourcery-ai guide,可随时(重新)生成审阅者指南。
  • 解决所有 Sourcery 评论: 在 pull request 上评论 @sourcery-ai resolve,以解决所有 Sourcery 评论。如果你已经处理完所有评论且不想再看到它们,这会很有用。
  • 撤销所有 Sourcery 审阅: 在 pull request 上评论 @sourcery-ai dismiss,以撤销所有现有的 Sourcery 审阅。特别适用于你想从头开始一次新审阅的场景——别忘了再评论 @sourcery-ai review 来触发新审阅!

自定义你的使用体验

访问你的 dashboard 以:

  • 启用或禁用审阅功能,例如 Sourcery 生成的 pull request 摘要、审阅者指南等。
  • 更改审阅语言。
  • 添加、删除或编辑自定义审阅说明。
  • 调整其他审阅设置。

获取帮助

Original review guide in English
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Stops coercing custom-tool parameters into typed values and instead forwards them as-is into query strings and request bodies, simplifying the custom tool base class behavior.

Class diagram for updated custom tool base parameter handling

classDiagram
    class CustomToolBase_before {
        _build_request_url(operation: Dict~str, Any~, params: Dict~str, Any~) Dict~str, Any~
        _build_request_headers(operation: Dict~str, Any~) Dict~str, str~
        _coerce_param(value: Any, schema_type: str) Any
        _build_request_data(operation: Dict~str, Any~, params: Dict~str, Any~) Optional~Dict~str, Any~~
        _send_http_request(operation: Dict~str, Any~, params: Dict~str, Any~) Any
    }

    class CustomToolBase_after {
        _build_request_url(operation: Dict~str, Any~, params: Dict~str, Any~) Dict~str, Any~
        _build_request_headers(operation: Dict~str, Any~) Dict~str, str~
        _build_request_data(operation: Dict~str, Any~, params: Dict~str, Any~) Optional~Dict~str, Any~~
        _send_http_request(operation: Dict~str, Any~, params: Dict~str, Any~) Any
    }

    CustomToolBase_before <|-- CustomToolBase_after

    note for CustomToolBase_before "Parameters for query and body are coerced using _coerce_param before being sent"
    note for CustomToolBase_after "Parameter coercion removed; values are forwarded as-is into query strings and request bodies"
Loading

File-Level Changes

Change Details Files
Stop coercing query parameters and body fields; pass through provided values unchanged.
  • Remove use of the internal coercion helper when building query parameters, assigning raw parameter values instead.
  • Remove use of the internal coercion helper when building request body data, assigning raw parameter values instead.
  • Delete the now-unused _coerce_param helper implementation and update the request-body builder signature accordingly.
api/app/core/tools/custom/base.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
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 - 我在这里给出了一些高层次的反馈:

  • _build_request_data 方法仍然定义为类方法(缩进在类内部),但现在既没有接收 self,也没有加上 @staticmethod,这会导致像 self._build_request_data(...) 这样的现有调用位置出错;要么重新引入 self,要么明确将其设为静态方法并相应更新所有调用位置。
  • 由于 _coerce_param 已被移除,请仔细检查在该类或代码库的其他地方是否还存在对它的引用,以避免运行时属性错误。
给 AI 代理的提示
Please address the comments from this code review:

## Overall Comments
- `_build_request_data` 方法仍然定义为类方法(缩进在类内部),但现在既没有接收 `self`,也没有加上 `@staticmethod`,这会导致像 `self._build_request_data(...)` 这样的现有调用位置出错;要么重新引入 `self`,要么明确将其设为静态方法并相应更新所有调用位置。
- 由于 `_coerce_param` 已被移除,请仔细检查在该类或代码库的其他地方是否还存在对它的引用,以避免运行时属性错误。

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

Hey - I've left some high level feedback:

  • The _build_request_data method is still defined as a class method (indented inside the class) but no longer takes self or has @staticmethod, which will break existing call sites like self._build_request_data(...); either reintroduce self or make it explicitly static and update call sites accordingly.
  • Since _coerce_param was removed, double-check there are no remaining references to it elsewhere in the class or codebase to avoid runtime attribute errors.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `_build_request_data` method is still defined as a class method (indented inside the class) but no longer takes `self` or has `@staticmethod`, which will break existing call sites like `self._build_request_data(...)`; either reintroduce `self` or make it explicitly static and update call sites accordingly.
- Since `_coerce_param` was removed, double-check there are no remaining references to it elsewhere in the class or codebase to avoid runtime attribute errors.

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.

@TimeBomb2018 TimeBomb2018 merged commit 61f2e44 into release/v0.3.0 Apr 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant