Merged
Conversation
Contributor
审阅者指南为自定义工具的 HTTP 请求实现了“基于 schema 的类型转换(type coercion)”,在发送请求之前,会根据 schema 将查询参数和 JSON 请求体字段转换为合适的原始类型(primitive types)。 更新后的自定义工具请求构建类图classDiagram
class CustomToolBase {
+_build_request_url(operation: Dict~str, Any~, params: Dict~str, Any~) str
+_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~) Dict~str, Any~
+_send_http_request(operation: Dict~str, Any~, params: Dict~str, Any~) Any
}
note for CustomToolBase "_coerce_param is now used by _build_request_url and _build_request_data to coerce query and body parameters to schema types"
文件级变更
提示与命令与 Sourcery 交互
自定义你的体验访问你的 dashboard 可以:
获取帮助Original review guide in EnglishReviewer's GuideImplements schema-aware type coercion for custom tool HTTP requests, ensuring query parameters and JSON body fields are converted to the appropriate primitive types before sending the request. Class diagram for updated custom tool request buildingclassDiagram
class CustomToolBase {
+_build_request_url(operation: Dict~str, Any~, params: Dict~str, Any~) str
+_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~) Dict~str, Any~
+_send_http_request(operation: Dict~str, Any~, params: Dict~str, Any~) Any
}
note for CustomToolBase "_coerce_param is now used by _build_request_url and _build_request_data to coerce query and body parameters to schema types"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - 我在这里给出了一些高层次的反馈:
- 当前的布尔值转换逻辑(
value.lower() not in ("false", "0", ""))可能过于宽松且有些出乎意料(例如,"no" 会变成True);建议改为显式维护一份真值/假值字符串的白名单。 _coerce_param辅助函数目前只处理原始的type值,并忽略了其他模式(schema)方面的信息,例如数组的items或嵌套对象的 schema;建议考虑如何处理或拒绝这些更复杂的类型,以避免出现静默的不匹配。
面向 AI Agent 的提示
Please address the comments from this code review:
## Overall Comments
- The boolean coercion logic (`value.lower() not in ("false", "0", "")`) may be too permissive and surprising (e.g., "no" becomes `True`); consider explicitly whitelisting truthy/falsey string values instead.
- The `_coerce_param` helper currently only handles primitive `type` values and ignores other schema aspects like `items` for arrays or nested object schemas; consider how you want to handle or reject those more complex types to avoid silent mismatches.帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English
Hey - I've left some high level feedback:
- The boolean coercion logic (
value.lower() not in ("false", "0", "")) may be too permissive and surprising (e.g., "no" becomesTrue); consider explicitly whitelisting truthy/falsey string values instead. - The
_coerce_paramhelper currently only handles primitivetypevalues and ignores other schema aspects likeitemsfor arrays or nested object schemas; consider how you want to handle or reject those more complex types to avoid silent mismatches.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The boolean coercion logic (`value.lower() not in ("false", "0", "")`) may be too permissive and surprising (e.g., "no" becomes `True`); consider explicitly whitelisting truthy/falsey string values instead.
- The `_coerce_param` helper currently only handles primitive `type` values and ignores other schema aspects like `items` for arrays or nested object schemas; consider how you want to handle or reject those more complex types to avoid silent mismatches.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
coerce query and request body parameters to schema types
Summary by Sourcery
在发送请求之前,将自定义工具的 HTTP 请求参数强制转换为其定义的模式类型。
Bug 修复:
Original summary in English
Summary by Sourcery
Coerce custom tool HTTP request parameters to match their defined schema types before sending requests.
Bug Fixes: