Skip to content

fix(maker-core): 泄漏工具调用标记的回合不再按成功收口,纳入有界自动恢复 - #2541

Open
fico-hub wants to merge 45 commits into
makecindy:mainfrom
fico-hub:fix/issue-2518-leaked-tool-markup
Open

fix(maker-core): 泄漏工具调用标记的回合不再按成功收口,纳入有界自动恢复#2541
fico-hub wants to merge 45 commits into
makecindy:mainfrom
fico-hub:fix/issue-2518-leaked-tool-markup

Conversation

@fico-hub

@fico-hub fico-hub commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

这次改了什么

摘要

fix 部分 #2518(类 B 状态误判与自动恢复;LaTeX 渲染部分为独立 renderer 决策,不在本 PR)。模型偶发把工具调用块写坏(开标签的 < 与外层调用标签一起丢失),SDK 解析器从未进入工具调用状态,损坏标记连同参数正文被当普通 assistant 文本输出——回合静默按成功收口,工具实际没执行,用户无从分辨「做完了」和「压根没跑」(issue 实测 423 次调用中 3 次未被任何机制捕获)。

  • 新增共享纯函数检测器 agents/shared/leaked-tool-markup.ts(标记语法集中定义):须同时命中 invoke 开标记(允许缺失前导 <)与其的 parameter 开标记;代码围栏/行内代码先剥离;name 有界不含换行。单独出现 invoke/parameter 词汇、普通英文讨论、大写变体均不命中。
  • claude-code translator 收口分类:非 is_error、非 interrupt、非 compact、全轮零结构化 tool_use 且正文命中检测器 → 推带稳定 reason malformed-tool-markup 的 terminal error,然后继续 status Done + done——本轮有真实用量,砍 done 会丢整轮账(与 is_error 失败序列同构;empty-response 只发 error 是因为零用量无账可丢)。日志只记类别与长度,不记正文。
  • desktop 自动续跑 reason 门放行该 key:泄漏正文已落库,恢复走「已有进展 → 续跑提示 + checkpoint」分支(不重发原消息),模型基于上下文重发调用即可救回(issue 实测该方式 3/3);止损与既有放行 reason 共用连续失败上限 / 人工介入周期硬上限 / 退避。

变更类型

  • fix 缺陷修复
  • feat 新功能
  • refactor / perf 重构或性能优化
  • docs / test / chore 文档、测试或工程维护
  • 其他:

范围

  • 关联 Issue / 需求:模型输出格式错误的工具调用块时,Cindy 静默结束回合,且把泄漏的正文按 LaTeX 渲染成乱码 #2518(期望行为 1、2;期望行为 3 的 LaTeX 定界符策略按维护者分析属独立 renderer 决策)
  • 本 PR 包含:packages/maker-core 检测器 + claude-code translator 收口分类;apps/desktop 自动续跑 reason 白名单;对应测试
  • 明确不包含:renderer 的 malformed 展示状态与 LaTeX 定界符收紧(独立决策);codex translator(其协议无此泄漏形态实证)
  • 用户可见变化:此前静默伪装成功的泄漏轮改为报「格式错误的工具调用」并自动续跑重试;失败超预算后横幅交还用户
  • 是否存在 breaking change:无

UI 变化

不涉及(main/maker-core 收口分类;错误横幅复用既有 error 呈现,message 为兜底文案)。

  • 引用的设计规范:不涉及

怎么验证的

自动验证

pnpm --filter @cindy/maker-core test
结果:2367/2367 通过(含新增 19 条:检测器 9 态单测 + translator 5 条收口回归:终态 error 且保 Done+done 记账 / 流式增量聚合 / 正常文本轮不判 / 执行过结构化工具不判 / interrupt 不判)

pnpm --filter @cindy/maker-core run --if-present typecheck && pnpm --filter desktop run --if-present typecheck
结果:均 0 错误

desktop 全量单测(--pool=forks 规避 threads 池已知 SIGSEGV flake)
结果:24527 通过 / 3 skip

根 pnpm test:unit
结果:除 desktop threads 池已知 SIGSEGV flake(forks 池全过)外 50 workspace 全过

指标影响评估(maker-core 规范 3.4)

  • 可能影响的指标:① turn 收口正确性(误报会把正常回合打成终态错误并触发自动续跑;漏检退化为本 PR 之前的现状)——由 44 条检测器/收口测试覆盖两个方向;② result 处理热路径耗时(检测器为每 result 一次、每 tool_use 分段一次的纯函数文本扫描,无 IO);③ 事件流形状(不新增/不重排既有事件,仅在命中时于 Done 前插入一条 terminal error)。用量计量、缓存率、prompt 内容不受影响(未触碰 usage-tracker / prompt 组装)。
  • 实测方法与结论(耗时):微基准 1000 次/形态(Node 24,M 系 mac):典型 10KB 中文正文 p50 12.6µs / p95 32.8µs;12KB 含围栏 p50 22.0µs / p95 45.9µs;含泄漏尾段 10KB p50 12.4µs;1KB 短文 p50 4.0µs。每 turn 总开销 <0.1ms,相对模型响应耗时可忽略。
  • 典型 turn 事件流抽查:translator 测试逐事件断言三类序列 —— 正常文本轮(text → status Done → done,零变化)、命中轮(error{malformed-tool-markup,isTerminal} → status Done → done,与 is_error 失败序列同构、记账保留)、工具轮(tool_use / tool_result 映射不受影响)。

手工验证

不涉及(泄漏形态为模型偶发输出,无法稳定手工复现;以 issue 提供的真实类 B 文本形态构造测试)。

未执行的验证

未在真实模型泄漏现场端到端验证自动续跑闭环(触发率约 0.9% 且依赖模型侧偶发);恢复路径复用 #2320 已验证的既有状态机,本 PR 只新增入口分类。

风险

风险分类

  • 无已知风险
  • 其他:

影响与回滚

  • 影响范围:仅「零结构化 tool_use 且正文命中窄范围标记对」的回合从成功收口改为失败收口 + 有界自动恢复;正常回合(含讨论 invoke/parameter 词汇、代码块内示例)判定路径命中不了检测器,行为字节不变。误报的代价是一次多余的续跑重试(有界),漏报的代价与现状相同。
  • 回滚 / 降级方式:revert 本 commit 回到静默成功收口的原状;运行期也可用自动续跑既有 kill switch 停用接管。

提交前检查

  • 已 review 完整 diff
  • 每个 commit 都带 DCO 签名(git commit -s,见 DCO)
  • UI 改动已在「UI 变化」注明引用的设计规范章节(不涉及 UI 则跳过)
  • 未提交凭证、令牌或授权文件
  • 已补充必要文档
  • 已确认测试结果或说明未执行原因

fix 部分 makecindy#2518(类 B 状态误判;LaTeX 渲染部分为独立 renderer 决策,不在
本 PR):模型偶发把工具调用块写坏(开标签的 < 与外层调用标签一起丢失),
SDK 解析器从未进入工具调用状态,损坏标记连同参数正文被当普通 assistant
文本输出 —— 回合静默按成功收口,工具实际没执行,用户无从分辨「做完了」
和「压根没跑」(issue 实测 423 次调用中 3 次未被任何机制捕获)。

- 新增共享纯函数检测器 leaked-tool-markup.ts(标记语法集中定义,不在各
  translator 复制正则):须同时命中 invoke 开标记(允许缺失前导 <)与其后
  的 parameter 开标记;代码围栏/行内代码先剥离;name 有界不含换行。单独
  出现 invoke/parameter 词汇、普通讨论、大写变体均不命中。
- claude-code translator 收口分类:非 is_error、非 interrupt、非 compact、
  全轮零结构化 tool_use 且正文命中检测器 → 推带稳定 reason
  'malformed-tool-markup' 的 terminal error,然后**继续** status Done +
  done —— 本轮有真实用量,砍 done 会丢整轮账(与 is_error 失败序列同构;
  empty-response 只发 error 是因为零用量无账可丢)。日志只记类别与长度,
  不记正文。
- desktop 自动续跑 reason 门放行该 key:泄漏正文已落库,恢复走「已有进展
  → 续跑提示 + checkpoint」分支(不重发原消息),模型基于上下文重发调用
  即可救回(issue 实测 3/3);止损与既有放行 reason 共用连续失败上限 /
  人工介入周期硬上限 / 退避。

测试:检测器 9 态单测(类 B / 带 < 泄漏 / 普通讨论 / 单标记 / 围栏与行内
代码 / 大写 / 未闭合围栏)+ translator 5 条收口回归(终态 error 且保
Done+done 记账 / 流式增量聚合 / 正常文本轮 / 执行过结构化工具不判 /
interrupt 不判)+ desktop reason 门 2 态。

Signed-off-by: ficowang <fico@xd.com>
@fico-hub
fico-hub requested a review from a team as a code owner August 12, 2026 12:34

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1fc2e5c3f6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/maker-core/src/agents/claude-code/translator.ts Outdated
Comment thread packages/maker-core/src/agents/claude-code/translator.ts Outdated
Comment on lines +1796 to +1799
message:
'模型输出了格式错误的工具调用块,未能解析为结构化调用,本轮工具未执行。将自动请求模型重试。',
isTerminal: true,
reason: 'malformed-tool-markup',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Localize the new terminal error

When auto-resume is disabled, exhausted, or cannot take over, this terminal error is shown and persisted, but malformed-tool-markup was not added to renderer/components/chat/errorReasonI18n.ts or the live mappings in makerChatStore.ts:4941-4950. Those paths consequently fall back to this raw Chinese message for every locale, so non-Chinese desktop and remote/mobile users receive untranslated error text; add the reason to the normal locale-backed mapping and all supported catalogs.

AGENTS.md reference: AGENTS.md:L100-L102

Useful? React with 👍 / 👎.

@greptile-apps

greptile-apps Bot commented Aug 12, 2026

Copy link
Copy Markdown

Greptile Summary

本 PR 为 Claude Code 回合新增损坏工具调用标记检测,并将命中的终态错误接入桌面端有界自动恢复。

  • 检测器在排除 CommonMark 代码与隐藏 HTML 结构后识别泄漏的 invoke/parameter 标记对。
  • translator 对流式正文、未流式尾段及零工具错位结果进行检测,同时保留 Done/done 用量记账事件。
  • 新回合会重置检测偏移与历史命中状态,桌面端允许 malformed-tool-markup 进入既有自动续跑预算和退避机制。
  • 当前 HEAD 已覆盖并修复先前线程指出的正文聚合、围栏解析、列表容器和跨回合状态问题。

Confidence Score: 5/5

当前 HEAD 已修复或明确处置所有先前报告的问题,未发现仍阻止合并的故障。

未发现仍然存在的阻塞性失败。

Important Files Changed

Filename Overview
packages/maker-core/src/agents/shared/leaked-tool-markup.ts 新增共享泄漏标记检测器,并处理围栏、行内代码、缩进代码、引用、列表和隐藏 HTML 块;先前报告的 CommonMark 边界问题在当前 HEAD 均已有针对性修复和回归测试。
packages/maker-core/src/agents/claude-code/translator.ts 在结果收口前检测损坏工具调用正文,覆盖流式聚合、未流式尾段和零工具错位结果,同时保持既有终态记账事件序列。
packages/maker-core/src/agents/claude-code/index.ts 新回合初始化路径现已同步清理检测偏移与历史命中,未发现 send、自动续跑或恢复入口遗漏。
apps/desktop/src/main/maker-ipc/interruptedTurnAutoResume.ts malformed-tool-markup 纳入既有有界自动续跑 reason 白名单,沿用连续失败上限、人工介入周期和退避机制。
packages/maker-core/src/agents/claude-code/tests/translator-leaked-tool-markup.test.ts 新增覆盖检测语法、CommonMark 排除规则、结果正文聚合、多工具分段和回合状态生命周期的集中回归测试。

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A["Claude Code SDK 输出"] --> B["聚合流式正文与结果尾段"]
  B --> C["剥离代码块、代码 span 与隐藏 HTML"]
  C --> D{"命中 invoke + parameter 标记对?"}
  D -- 否 --> E["正常收口:Done + done"]
  D -- 是 --> F["发送 terminal error\nreason: malformed-tool-markup"]
  F --> G["继续发送 Done + done\n保留用量记账"]
  G --> H["Desktop 有界自动续跑"]
  H --> I["续跑提示 + checkpoint"]
  H --> J["预算耗尽后交还用户"]
Loading

Reviews (44): Last reviewed commit: "fix(maker-core): type-6 标签表补 param" | Re-trigger Greptile

Comment thread packages/maker-core/src/agents/claude-code/translator.ts Outdated
Comment thread packages/maker-core/src/agents/shared/leaked-tool-markup.ts Outdated
@MagicLizi

Copy link
Copy Markdown
Contributor

@fico-hub 👋 这个 PR 还有 5 条 review conversation 没 resolve(packages/maker-core/src/agents/claude-code/translator.ts / packages/maker-core/src/agents/shared/leaked-tool-markup.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

@MagicLizi MagicLizi added awaiting-discussion 等待维护者讨论(review-pr) touches:core 改动碰到架构核心路径(review-pr 自动维护,仅展示) labels Aug 12, 2026
@MagicLizi

Copy link
Copy Markdown
Contributor

👋 此 PR 触发了维护者确认门:arch(核心路径改动 367 行,maker-core 工具调用标记与自动恢复逻辑)。

已创建讨论 issue #ISSUE_URL# 供维护者跟踪。在维护者 Approve 之前,此 PR 不会被自动合并。

维护者确认方式:直接在 PR 上 Approve(如需修改请 Request Changes,作者改完后再 Approve 即放行)。

讨论 issue:#2546

Review 反馈修复(Greptile P1 ×2 + Codex P2 ×1):

- 扫描正文改为「用户实际看到的全文」= emitted + fallbackTail —— 泄漏标记
  只存在于 result.result 兜出的未流式尾段(截断兜底刚补推给 UI)时,原先只
  扫 emitted 会漏检;前缀 mismatch 分支 fallbackTail 为空,退化为只扫
  emitted,与实际展示一致。
- toolUses 累计非零不再整轮免判:TurnState 新增 uiTextLenAtLastToolUse
  (最后一次结构化 tool_use 时的已推正文长度),检测只扫该偏移之后的正文
  —— 之前的文本属于已正常执行过工具的讨论语境,之后再泄漏(先成功调 N 个
  工具、第 N+1 个写坏成纯文本)仍要判;零 tool 轮偏移为 0 语义不变。
- 围栏剥离正则改为 (`{3,}|~{3,}) + 反向引用闭栏:波浪线围栏与 4+ 反引号
  开栏(CommonMark 嵌套围栏惯用法)内的示例不再被误判,内层短围栏不会提前
  闭合外层。

测试:检测器新增 3 态(~~~ 围栏 / 4 反引号围栏 / 长围栏嵌套短围栏),
translator 回归改写工具语境 2 态(工具前讨论不判 / 最后一次工具后泄漏判)
并新增 result 尾段泄漏 1 态;8 个既有 translator 测试的 TurnState 字面量
补齐新字段。

Signed-off-by: ficowang <fico@xd.com>
Comment thread packages/maker-core/src/agents/claude-code/translator.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3cd13b12af

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/maker-core/src/agents/shared/leaked-tool-markup.ts Outdated
第二轮 review 反馈修复(Greptile P1 + Codex P1):

- mismatch 分支补扫:result.result 与已流式正文前缀对不上时 fallbackTail
  为空、full 不展示,泄漏若只在 full 里,「工具没执行却按成功收口」的实质
  伤害不变 —— 检测依据是本轮模型输出,不限于已展示部分。仅零 tool 轮补扫:
  有 tool 轮的 uiTextLenAtLastToolUse 偏移建立在 emitted 之上,无法映射进
  错位的 full,保守跳过。
- inline code span 剥离从单行正则改为 CommonMark 等长闭合扫描(对齐
  maker-shared mathMarkdown.ts 的语义):开 backtick 运行与等长闭合运行
  配对、内容允许换行 —— 多行合法 code span 里演示的标记不再被留给检测器
  造成误报;无闭合运行按字面量保留;按空行分段,两段各自的孤立 backtick
  不会配对成 span 吞掉中间的真实泄漏。

测试:检测器 +2 态(多行 span 不判 / 空行屏障下真实泄漏仍判),translator
+1 态(mismatch 正文泄漏在零 tool 轮命中且不补推正文)。

Signed-off-by: ficowang <fico@xd.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ba01022215

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/maker-core/src/agents/shared/leaked-tool-markup.ts Outdated
第三轮 review 反馈修复(Codex P1):合法文档回复用 4 空格缩进代码块演示
标记语法时,预处理只剥围栏与 inline span,缩进块里的标记会触发误报终态
错误 + 自动续跑。按 CommonMark 语义剥离缩进块,保留两条规则:缩进块不能
打断段落 —— 紧跟非空行的缩进行是段落惰性延续不算代码,顺带保住「真实
泄漏恰好缩进在段落中间」的检出;块内空行不终结块。

测试:检测器 +2 态(缩进块演示不判 / 段落惰性延续的缩进泄漏仍判)。

Signed-off-by: ficowang <fico@xd.com>
Comment thread packages/maker-core/src/agents/claude-code/translator.ts
Comment thread packages/maker-core/src/agents/shared/leaked-tool-markup.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0ef99b5a91

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/maker-core/src/agents/claude-code/translator.ts
第四轮 review 反馈修复(Greptile P1 + Codex P1):

- 围栏剥离锚定行首(允许 0-3 空格缩进,CommonMark 语义),闭栏同样要求
  行首 —— 段落中间的行内 ``` / ~~~ 不是围栏,原正则会把它误作未闭合
  围栏吞掉其后的真实泄漏。
- tool_use 推进扫描偏移前,对被跳过的前段正文单独过一遍检测器,命中记入
  TurnState.leakedMarkupBeforeToolUse,收口时与尾段检测一起判 —— 平行
  调用里前一个写坏成纯文本、后一个正常解析时,坏调用文本落在 tool_use
  之前的段里,不能一律当讨论语境跳过;围栏/行内代码内的演示仍被检测器
  剥离,语法讲解不误伤。

测试:translator 前段语义改写为「围栏内讨论不判 / 裸标记的平行调用泄漏
判」两态;既有围栏用例全部保持通过。

同轮 Greptile 的「多工具 + 错位 full 补扫」未采纳:错位 full 上无法映射
tool_use 偏移、无法排除讨论段,扫全量会重新引入前几轮反例约束的误报,
该复合形态退化为本 PR 之前的行为,已在 thread 说明。

Signed-off-by: ficowang <fico@xd.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4008ee14d6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/maker-core/src/agents/shared/leaked-tool-markup.ts Outdated
第五轮 review 反馈修复(Codex P2):闭栏后缀原用 [`~]* 吸收超长闭栏,
会把 ```~~~ 这样的混合字符行误判为闭栏,导致合法围栏示例的剩余内容
暴露给检测器造成误报。按 CommonMark 语义拆成反引号/波浪线两个独立分支,
超长闭栏只由同字符吸收。

测试:检测器 +1 态(混合字符行不是闭栏)。

Signed-off-by: ficowang <fico@xd.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e7ef76c244

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/maker-core/src/agents/shared/leaked-tool-markup.ts Outdated
Comment thread packages/maker-core/src/agents/claude-code/index.ts
第六轮 review 反馈修复(Greptile P1 + Codex P1):

- beginNewTurn 手工重置清单漏掉本 PR 新增的 uiTextLenAtLastToolUse 与
  leakedMarkupBeforeToolUse:上一轮 abort/cancellation 未走到 result 的
  resetTurnState 时,下一轮会从旧偏移扫描漏检,或沿用旧命中把正常回合
  误报成 malformed-tool-markup。补齐两项重置。
- 检测预处理先剥行首 blockquote 前缀(> ,可叠加嵌套):引用里的围栏/
  缩进块(> ```xml、>     code)剥掉前缀后交给既有围栏/缩进块剥离按
  CommonMark 处理,不再把引用中的合法示例误报;引用里的裸泄漏剥掉前缀
  后仍是裸文本,不丢检出。

测试:检测器 +2 态(引用内围栏不判 / 引用内裸泄漏仍判)。

Signed-off-by: ficowang <fico@xd.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c59e30ca61

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/maker-core/src/agents/shared/leaked-tool-markup.ts Outdated
Comment thread packages/maker-core/src/agents/shared/leaked-tool-markup.ts Outdated
@MagicLizi

Copy link
Copy Markdown
Contributor

@fico-hub 👋 这个 PR 还有 3 条 review conversation 没 resolve(packages/maker-core/src/agents/claude-code/translator.ts / packages/maker-core/src/agents/shared/leaked-tool-markup.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

@MagicLizi MagicLizi removed the awaiting-discussion 等待维护者讨论(review-pr) label Aug 12, 2026
第七轮 review 反馈修复(Codex P2 ×2),并偿还正则技术债:五轮迭代后的
FENCED_CODE_RE 已不可维护,整体替换为行级状态机 stripFencedBlocks +
容器分段递归 stripBlockStructures:

- 开栏合法性按 CommonMark 判定:仅 0-3 个**空格**缩进(tab 缩进的是缩进
  代码不是围栏);反引号开栏的 info string 不得含反引号,含则整行不是
  开栏 —— 原正则会把这两种行误作开栏,把其后的真实泄漏吞到结尾。
- 容器边界不再先抹平:先剥当前层围栏,再把连续 blockquote 行摘出、去一层
  前缀递归处理(深度限 8)—— 引用里未闭合的围栏只吞到该引用段末尾,不再
  把引用外的真实泄漏一并吞掉。
- 状态机天然保持既有语义:同字符闭栏、不短于开栏、混合字符行不是闭栏、
  内层短围栏不闭合外层、未闭合吞到段末。
- 文件头补充设计取向说明:误报(终态错误+自动续跑)与漏检(退化为现状)
  代价不对称,剥离逻辑 fail-open 取向少剥少判。

测试:检测器 +3 态(tab 缩进行不是开栏 / info string 含反引号不是开栏 /
引用内未闭合围栏不吞引用外泄漏),全部 31 态通过。

Signed-off-by: ficowang <fico@xd.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a3c1860c67

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/maker-core/src/agents/shared/leaked-tool-markup.ts Outdated
第八轮 review 反馈修复(Codex P2,误报方向):模型把语法示例写成列表项内
的合法围栏(- ```xml,内容与闭栏随列表边距缩进)时,开栏带列表标记不被
识别、内容不足四空格也不算缩进代码,普通文档回复会被判成
malformed-tool-markup 触发终态错误 + 自动续跑。

围栏状态机扩展:开栏允许可选列表项标记前缀(- / * / + / 1. / 1) 等);
闭栏缩进上限改为「开栏容器边距 + 3」(CommonMark:闭栏缩进相对容器至多
3 空格,列表项内的闭栏随列表边距整体右移)。

测试:检测器 +3 态(无序/有序列表围栏不判 / 列表围栏闭合后的裸泄漏仍判)。

Signed-off-by: ficowang <fico@xd.com>
prevBlank 近似在「标题后无空行」的形态上失真:标题后的空列表项不被
识别,项内 4 空格缩进的引用围栏不进引用分组而误报。抽出共享
createBlockContext(段落/引用/列表状态,规则与围栏、HTML 状态机一致)
替换两处近似,并补「空列表项之后紧跟空行即关闭」规则(CommonMark:
list item can begin with at most one blank line)—— 空行关闭空项后的
4 空格行是顶层缩进代码(渲染为可见代码块的示例),正确不判。缩进代码
的起始门槛同步从「空行后」改为「段落外」(标题后的缩进行是代码,
micromark 实测同)。

Signed-off-by: ficowang <fico@xd.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d98cdcf184

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/maker-core/src/agents/shared/leaked-tool-markup.ts Outdated
- - inner 这类叠加标记行的每个标记都开启一层列表容器,此前只入栈最内
层内容列,外层项的 2 空格续行会把栈弹空 —— 续行上的未闭合围栏被当顶层
围栏吞到输入末尾,漏掉列表外的真实泄漏。listMarkerContentCols 逐段解析
前缀返回每层内容列(外层在前,最后一层保留 ≥5 空白 padding 规则),
enterItem 接数组逐层压栈;围栏/HTML 开栏的标记前缀走同一解析。

Signed-off-by: ficowang <fico@xd.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9851daf5c1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/maker-core/src/agents/shared/leaked-tool-markup.ts
空列表项之后紧跟空行即关闭该项(CommonMark:list item can begin with
at most one blank line)—— 该规则此前只在共享 createBlockContext 里,
围栏与 HTML 两个内联状态机没有:过期的空项上下文会把其后顶层缩进代码
里的反引号行当成项内围栏,吞掉后续可见泄漏。两个状态机补
pendingEmptyItem(仅由空标记行置位、任意行清零、空行时弹层)。

Signed-off-by: ficowang <fico@xd.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: be34017460

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/maker-core/src/agents/shared/leaked-tool-markup.ts
整块无占位地删除会让相邻块重新拼成不同的 Markdown 结构:intro + 围栏 +
空列表项剥掉围栏后变成 intro + `-`,下游状态机把 `-` 误读成 setext
下划线,空列表项与其中 HTML 块的容器边界全部丢失,dedent 后的真实泄漏
被吞到 EOF。围栏 / HTML 块 / 缩进代码剥离时留下「原行首缩进 + \u0000」
的哨兵行:各状态机把它当块边界(收段落、不建段落、按缩进参与容器弹层),
检测前统一转为空行 —— 被剥块同时成为段落屏障,行内 code span / 注释
配对不再跨越被剥块。

Signed-off-by: ficowang <fico@xd.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 659c34a58f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/maker-core/src/agents/shared/leaked-tool-markup.ts
@MagicLizi MagicLizi added the touches:large-diff 改动量较大(review-pr 自动维护,仅展示) label Aug 13, 2026
\<!-- 是反斜杠转义的可见文本不是注释开启符(micromark 实测渲染为
&lt;!--),行内闭合注释正则补 (?<!\\) lookbehind —— 它到后文 --> 之间
的真实泄漏不再被当注释吞掉。转义排除与 invoke/parameter 标记正则同为
单层 lookbehind 近似。

Signed-off-by: ficowang <fico@xd.com>

@MagicLizi MagicLizi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

在「待确认 PR」面板完成维护者确认。

@MagicLizi MagicLizi removed the awaiting-discussion 等待维护者讨论(review-pr) label Aug 13, 2026

@MagicLizi MagicLizi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

在「待确认 PR」面板完成维护者确认。

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 00bb01f301

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/maker-core/src/agents/shared/leaked-tool-markup.ts Outdated
标记后空白正则按字符吞 1-4 个,-\t\t 两个字符展开后是 7 列 —— 超过
4 列时只有 1 列算 padding,内容列应为标记末列 + 1(此前记成 8,其下
2 空格未闭合围栏被当顶层吞到输入末尾,漏掉列表外真实泄漏)。
listMarkerContentCols 逐段计算标记末列与空白末列的展开列差,>4 列或
最后一段之后还跟空白(≥5 字符)都按溢出处理;单 tab(3 列)照常。

Signed-off-by: ficowang <fico@xd.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 17976076b0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/maker-core/src/agents/shared/leaked-tool-markup.ts Outdated
\` 是反斜杠转义的字面反引号(micromark 实测渲染为普通文本),span
扫描此前不看转义,会把两个转义反引号配对成 span、吞掉中间可见泄漏。
run 扫描改为转义感知:转义只吞运行的首个反引号,剩余仍可作更短的
分隔符;单层 lookbehind 近似与其余正则一致。

Signed-off-by: ficowang <fico@xd.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 51f6f6f007

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/maker-core/src/agents/shared/leaked-tool-markup.ts
- item\nlazy 里 col-0 的 lazy 是列表项段落的惰性延续,列表项仍敞开,
其后 2 空格围栏属于该项 —— 此前无条件按 dedent 弹层,把项内未闭合围栏
当顶层吞掉列表外真实泄漏。三处状态机(围栏 / HTML / 共享跟踪器)统一:
敞开段落的纯段落行(非标题/分隔线/setext/引用/标记/HTML 开启)按惰性
延续处理不弹层;带普通文本内容的标记行敞开项内段落使惰性行可识别;
块级行(标题等)照常弹层结束列表(micromark 实测三种走向一致)。

Signed-off-by: ficowang <fico@xd.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: de7bb5a69d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/maker-core/src/agents/shared/leaked-tool-markup.ts
@MagicLizi

Copy link
Copy Markdown
Contributor

@fico-hub 👋 这个 PR 还有 3 条 review conversation 没 resolve(packages/maker-core/src/agents/claude-code/translator.ts / packages/maker-core/src/agents/shared/leaked-tool-markup.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

@MagicLizi MagicLizi added the status:threads-open 还有未 resolve 的评审讨论(review-pr 自动维护,仅展示) label Aug 13, 2026
CommonMark 的 code span 内容里反斜杠不转义:span 以「内容尾随反斜杠 +
闭合反引号」结尾时(`code \`)闭合照常成立(micromark 实测)。上一轮
的转义感知误伤了闭合端搜索,把这类合法 span 留给检测造成误报 —— 拆成
nextOpenRun(开启端跳过转义反引号)与 nextRawRun(闭合端不看转义)。

Signed-off-by: ficowang <fico@xd.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b8b9955c0e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/maker-core/src/agents/shared/leaked-tool-markup.ts
Comment thread packages/maker-core/src/agents/shared/leaked-tool-markup.ts Outdated

@dashhuang dashhuang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

产品方向认可:工具实际上没有执行时,不能让这一轮按成功完成。

但当前实现为了识别一个上游异常,在客户端逐步维护了一套接近 Markdown/CommonMark 解析器的检测逻辑,范围和长期维护成本过重。请先在 #2546 补齐模型/SDK 根因调查:模型与 SDK 版本、原始事件类型、停止原因、请求 ID 和脱敏样本,并用较新 SDK 做对照验证;优先争取结构化的异常信号。

如果根因解决前仍需要临时兜底,请把客户端方案收窄到已观测协议特征:仅在没有结构化 tool-use 事件时触发,明确把本轮标为“工具未执行”并阻止成功收口;可以复用现有有界恢复,但不要执行泄漏文本或盲目重发原请求。泄漏正文的 Markdown/LaTeX 安全展示请独立处理。

同时请增加匿名命中统计和明确的移除条件,避免临时兼容层永久留在客户端。完成根因调查并把兜底显著收窄后再放行。

对照 micromark htmlBlockNames 逐项比对,param 是本表唯一缺项 ——
<param …> 块在渲染端整块隐藏,块内协议示例不算泄漏。

Signed-off-by: ficowang <fico@xd.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0a528acb9c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// 这里看不到结论 —— 只陈述事实与始终存在的人工重试入口(第三十轮
// Codex review)。
message:
'模型输出了格式错误的工具调用块,未能解析为结构化调用,本轮工具未执行,可重新发送重试。',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 按实际执行情况描述失败范围

当本轮先成功执行一个或多个结构化 tool_use、随后才泄漏下一个损坏调用时(下方新增测试明确覆盖此路径),这里仍向用户断言“本轮工具未执行”。若自动续跑未接管或额度耗尽,用户据此重新发送原请求可能重复此前已经产生的文件修改、命令或推送等副作用;请根据 ctx.turn.toolUses 区分“本轮没有工具执行”与“最后一个调用未执行”。 docs/dev-rules/maker-core-and-agent-behavior.mdL78-L81

Useful? React with 👍 / 👎.

@MagicLizi

Copy link
Copy Markdown
Contributor

@fico-hub 👋 这个 PR 还有 3 条 review conversation 没 resolve(packages/maker-core/src/agents/claude-code/translator.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

@MagicLizi MagicLizi added status:awaiting-author 等作者修改(review-pr 自动维护,仅展示) and removed status:threads-open 还有未 resolve 的评审讨论(review-pr 自动维护,仅展示) labels Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:awaiting-author 等作者修改(review-pr 自动维护,仅展示) touches:core 改动碰到架构核心路径(review-pr 自动维护,仅展示) touches:large-diff 改动量较大(review-pr 自动维护,仅展示)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants