feat(quantizedsliding): 支持目标超上限时自动钳制#1574
Merged
single-ptilopsis merged 2 commits intov2from Mar 24, 2026
Merged
Conversation
- 新增 ClampTargetToMax 可选参数 - 目标超过 maxQuantity 时可钳制后继续执行 - 同步补充中英文开发文档与接入说明
Contributor
There was a problem hiding this comment.
Hey - 我在这里给出了一些高层次的反馈:
- 一旦
ClampTargetToMax开始生效,a.Target就会被修改,原先请求的目标值就丢失了;如果下游的使用方或日志需要区分“请求的”数量和“实际的”数量,建议把OriginalTarget作为单独字段存储,并在handleDone中同时记录这两个值,而不是只记录被限制后的值。
给 AI 代理的提示
请根据这次代码评审中的评论进行修改:
## 总体评论
- 一旦 `ClampTargetToMax` 开始生效,`a.Target` 就会被修改,原先请求的目标值就丢失了;如果下游的使用方或日志需要区分“请求的”数量和“实际的”数量,建议把 `OriginalTarget` 作为单独字段存储,并在 `handleDone` 中同时记录这两个值,而不是只记录被限制后的值。帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进之后的评审。
Original comment in English
Hey - I've left some high level feedback:
- Once
ClampTargetToMaxkicks in,a.Targetis mutated and the original requested target is lost; if downstream consumers or logs need to distinguish between "requested" vs "actual" quantity, consider storingOriginalTargetas a separate field and logging both inhandleDoneinstead of only the clamped value.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Once `ClampTargetToMax` kicks in, `a.Target` is mutated and the original requested target is lost; if downstream consumers or logs need to distinguish between "requested" vs "actual" quantity, consider storing `OriginalTarget` as a separate field and logging both in `handleDone` instead of only the clamped value.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Contributor
There was a problem hiding this comment.
Pull request overview
该 PR 为 go-service 的 QuantizedSliding 自定义动作新增“目标超过识别上限时自动钳制”的可选行为,并同步更新中英文开发文档,便于业务接入时在“目标超上限”场景下不中断流程。
Changes:
- 新增
ClampTargetToMax参数,并在解析/日志中透出该开关。 - 在获取
maxQuantity后支持(可选)将Target钳制为maxQuantity继续执行。 - 同步补充中英文文档中的参数表、成功/失败条件与自检清单。
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/zh_cn/developers/quantized-sliding.md | 增加 ClampTargetToMax 参数说明与接入注意事项(成功/失败条件、自检清单同步更新)。 |
| docs/en_us/developers/quantized-sliding.md | 英文文档同步增加 ClampTargetToMax 说明与注意事项。 |
| agent/go-service/quantizedsliding/types.go | 为动作参数/结构体新增 ClampTargetToMax 字段,并更新参数注释。 |
| agent/go-service/quantizedsliding/params.go | 参数归一化、应用与解析日志中加入 ClampTargetToMax。 |
| agent/go-service/quantizedsliding/handlers.go | 在解析 maxQuantity 后引入钳制逻辑,并调整 resolveMaxQuantityNext 签名以支持该开关。 |
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.
由 Sourcery 生成的摘要
为量化滑动目标添加可选的钳制行为,当目标超过检测到的最大值时进行钳制,并在英文和中文指南中记录该新行为和参数。
新功能:
ClampTargetToMax参数,用于在Target超过检测到的maxQuantity时,可选地将其钳制到maxQuantity,而不是在目标超过最大值时直接失败。增强改进:
文档:
ClampTargetToMax参数、其行为以及集成注意事项。Original summary in English
Summary by Sourcery
为量化滑动目标添加可选的截断(clamp)行为,用于处理超过已识别最大值的目标,并在英文和中文开发者指南中记录这一新行为。
新功能:
ClampTargetToMax参数,可选地将Target截断到已识别的maxQuantity,而不是在请求的目标超过最大值时直接失败。功能增强:
ClampTargetToMax,包括记录截断行为以及最终目标值的日志。文档更新:
ClampTargetToMax选项、其行为以及相关集成注意事项。Original summary in English
Summary by Sourcery
Add optional clamping behavior for quantized sliding targets that exceed the recognized maximum and document the new behavior in both English and Chinese developer guides.
New Features:
Enhancements:
Documentation: