Skip to content

test(mock-llm-server): gemini router 告警改为连续 streak 并忽略无 marker 请求 - #2630

Merged
deepcoldy merged 1 commit into
masterfrom
test/gemini-router-streak-followup-2619
Oct 31, 2026
Merged

deepcoldy merged 1 commit into
masterfrom
test/gemini-router-streak-followup-2619

Conversation

@deepcoldy

@deepcoldy deepcoldy commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

背景

#2619 评审中发现的 P2,该 PR 已 squash 合入(3e6283675),此为跟进修复。

P2:server.ts 的 geminiRouterHits 只在 wantsJsonVerdict(router)分支自增,functionCall/text 分支从不重置,因此告警文案声称「hit N times without a main-model call」,实际判据是「该 marker 累计问过 router >2 次」。两个真实假阳性(用真实 MockLlmServer 复现):

  1. 正常多步回合(router→主模型 tool call→继续→文本)重复 3 次,每次主模型都被调用,仍告警;
  2. 无 ACK marker 的 generateJson 请求(标题/摘要)全落到兜底 key ACK-test-message-received,无死循环也告警;且 mock server 是跑道级实例、计数只增不清,多 bot 共用一个 server 时桶越攒越高。

只影响诊断告警的可信度,不动 src/、不影响任何用例红绿。

改动(test/helpers/mock-llm-server + 两个测试文件)

  • functionCall 与 text 分支 geminiRouterHits.delete(marker):主模型一旦应答,连续段结束;
  • router 分支仅在提取到真实 marker 时计数;无 marker 的 generateJson 请求不进任何桶;
  • 新增 3 条回归用例(真实 MockLlmServer,非 mock):functionCall 后重置、text 后重置、无 marker 连打 4 次不告警;
  • 顺手落实复审 P3:buildGeminiShellEnvSnapshotFragment 对 marker 加 shell 引号安全字符集断言(/^[A-Za-z0-9_\-.:#@ ]*$/),不把注入安全押在 marker-extractor 将来不改正则,并配 1 条用例。

未采纳的其余 P3(诊断值完整打进公开 CI 日志、单测共享 /tmp 路径、bun test 腿不含 helpers 目录):不阻断,留给后续按需处理。

验证

  • bun x tsc --noEmit 0 错;bun run typecheck:test-mocks 0 错;
  • bun run test test/helpers/mock-llm-server/gemini-shell-env.test.ts test/mock-llm-server.test.ts:29/29 绿;bun test 同文件 5/5 绿;
  • 变异复验(vitest/bun 双引擎):删 functionCall 重置→functionCall 用例红;删 text 重置→text 用例红;去 rawMarker 守卫→无 marker 用例红;掏空字符集断言→断言用例双引擎红;原 PR 的 4 枪变异在新代码下仍各自咬红。全部恢复后 29/29 复绿。

🤖 Generated with Claude Code

#2619 复审 P2(随 squash 合入后跟进):geminiRouterHits 只在 router 分支
自增、主模型分支从不重置,告警判据实际是「该 marker 累计问过 router >2
次」而非文案声称的「没有主模型调用」。正常多步回合(router→主模型→
router)以及无 ACK marker 的 generateJson 共用兜底桶都会误报,且 mock
server 全跑道实例级共享、只增不清。

- functionCall/text 分支 delete(marker):主模型一旦应答即结束连续段
- router 分支仅在提取到真实 marker 时计数,无 marker 的标题/摘要
  generateJson 请求不进任何桶
- 补 3 条真实 MockLlmServer 回归用例(functionCall 重置、text 重置、
  无 marker 不告警),各守卫变异独立咬红
- 顺手落实复审 P3:buildGeminiShellEnvSnapshotFragment 对 marker 加
  shell 引号安全字符集断言,不把注入安全押在 extractor 正则上,配测试

Co-Authored-By: Claude Code <[email protected]>
@deepcoldy
deepcoldy merged commit 3bf0b36 into master Oct 31, 2026
14 of 15 checks passed
deepcoldy pushed a commit that referenced this pull request Oct 31, 2026
同步最新 master(#2585 回复页脚控制台入口、#2605 TraeX 额度池顺序续跑、
#2630、#2619、#2473、#2568 共 6 提交)。与本 PR 仅在四个 i18n/页面文件
交集(bot-defaults-page.tsx、dashboard/web/i18n.ts、i18n zh/en),均为
各自新增不同键的同段并存,git 自动合并无冲突:本 PR 的 sharedSandbox* /
sandbox_advice.* 全套与 master 的 replyFooter / autoModelQuota* 键共存。

Co-Authored-By: Claude Code <[email protected]>
@github-actions

Copy link
Copy Markdown

@deepcoldy 合入 master 后的 Midscene E2E 失败:Feishu live Midscene 失败。

这次运行覆盖 3bf0b36。

用例 跑道 状态 失败信息
Gemini basic bot flow feishu-core-clis failed waitFor timeout: Based on the screenshot, the title bar at the top of the right-side chat area displays "ClaudeSandbox" followed by "botmux E2E 测试 Bot (ClaudeSandbox CLI)". It does not display "Gemin…

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

🚀 Released in v3.56.0

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.

1 participant