Skip to content

feat(quantizedsliding): 支持目标超上限时自动钳制#1574

Merged
single-ptilopsis merged 2 commits intov2from
feature/quantized-sliding
Mar 24, 2026
Merged

feat(quantizedsliding): 支持目标超上限时自动钳制#1574
single-ptilopsis merged 2 commits intov2from
feature/quantized-sliding

Conversation

@single-ptilopsis
Copy link
Copy Markdown
Contributor

@single-ptilopsis single-ptilopsis commented Mar 24, 2026

  • 新增 ClampTargetToMax 可选参数
  • 目标超过 maxQuantity 时可钳制后继续执行
  • 同步补充中英文开发文档与接入说明

由 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:

  • Introduce a ClampTargetToMax parameter to optionally clamp Target to the recognized maxQuantity instead of failing when the requested target exceeds the maximum.

Enhancements:

  • Propagate ClampTargetToMax through quantized sliding action parameters and state, including logging of clamping behavior and final target values.

Documentation:

  • Document the ClampTargetToMax option, its behavior, and related integration caveats in the English and Chinese quantized sliding developer guides.

- 新增 ClampTargetToMax 可选参数
- 目标超过 maxQuantity 时可钳制后继续执行
- 同步补充中英文开发文档与接入说明
@single-ptilopsis single-ptilopsis marked this pull request as ready for review March 24, 2026 08:47
Copilot AI review requested due to automatic review settings March 24, 2026 08:47
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 - 我在这里给出了一些高层次的反馈:

  • 一旦 ClampTargetToMax 开始生效,a.Target 就会被修改,原先请求的目标值就丢失了;如果下游的使用方或日志需要区分“请求的”数量和“实际的”数量,建议把 OriginalTarget 作为单独字段存储,并在 handleDone 中同时记录这两个值,而不是只记录被限制后的值。
给 AI 代理的提示
请根据这次代码评审中的评论进行修改:

## 总体评论
- 一旦 `ClampTargetToMax` 开始生效,`a.Target` 就会被修改,原先请求的目标值就丢失了;如果下游的使用方或日志需要区分“请求的”数量和“实际的”数量,建议把 `OriginalTarget` 作为单独字段存储,并在 `handleDone` 中同时记录这两个值,而不是只记录被限制后的值。

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

Hey - I've left some high level feedback:

  • 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.
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.

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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 签名以支持该开关。

@single-ptilopsis single-ptilopsis merged commit 816f74b into v2 Mar 24, 2026
16 checks passed
@single-ptilopsis single-ptilopsis deleted the feature/quantized-sliding branch March 24, 2026 09:19
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.

2 participants