ambiguous-pointer commented on PR #1616:
URL: https://github.com/apache/dubbo-admin/pull/1616#issuecomment-6568949764

   ## 修一个 reasoning 策略的绕过(来自 #1618 的评审意见)
   
   #1618 的评审指出 `rewriteReasoningParts` 有一个策略绕过:它先在**原始文本**里搜 `reasoning` 
这个词,命中才继续解码。JSON 转义之后原文字节里并不含这个词 —— 比如 `"type":"reasoning"` —— 
早退命中后整份文档原样返回,`CaptureNone` 形同虚设,reasoning 内容会原样进入 trace。
   
   本 PR 才是这段代码的归属地(#1618 那边已经把 `ai/component/hooks/reasoning.go` 与 
`reasoning_test.go` 移除,因为它俩在这条分支上缺了 `TracingSpec.CaptureReasoning` / 
`Registration.CaptureReasoning` / `Manager.ReasoningPolicy` 的接线,ai 
模块编译不过)。所以修在这里(`3c6596d`)。
   
   **改法**:去掉原始文本的字符串早退,一律先解码再判定 type 判别符。解码后的比较本来就认得转义形式,所以 
`filterReasoningElements` 里的 `element["type"] != reasoningPartType` 不需要改;遍历在没有 
reasoning part 时返回 `changed=false`,文档依旧原样返回,行为不变。
   
   **回归用例** `TestApplyReasoningPolicyRemovesEscapedReasoningParts`:构造一个把 `type` 
写成 JSON 转义形式的文档,断言 `CaptureNone` 之后只剩 text part、reasoning 内容消失。
   
   已验证这个用例确实能抓到问题:把解码顺序改回旧写法,它会失败,报错里被转义的 reasoning part 原样保留。
   
   > 补充一句上下文:`ai` 模块与 `ui-vue3/src/components/ai-chat/` 下一批文件此前一直缺 license 
header(这条分支的流水线此前从不在 `ai` 上跑)。#1618 打开了 ci.yml 对 `ai` 分支的触发后,license 检查把 37 
个文件挑了出来,已在 #1618 里补齐。
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to