cc-haha/release-notes/v0.5.20.md
你的姓名 e1a8a8ff56 release: v0.5.20
One PR merged into main since v0.5.19:
- #78 fix(agent-limiter): add streak gate + raise verification cap to 12

The original limiter only had a single total-count cap (verification=5)
that hard-blocked the 6th call regardless of whether prior calls
succeeded or failed. Five PRs each verified successfully and the 6th
PR was blocked anyway. Replaced with two complementary gates: total
cap raised to 12, and a new consecutive-FAIL streak gate (3 FAILs in
a row caps immediately, any PASS clears the streak). The streak gate
catches verifier-loop pathology faster and more accurately than a
count-only cap, while the raised total leaves headroom for legitimate
multi-step work.

This release commit prepares v0.5.20 metadata. Tag will be pushed
separately when ready to trigger the desktop release workflow.

See release-notes/v0.5.20.md for full details.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-19 09:22:02 +08:00

2.9 KiB
Raw Blame History

v0.5.20

子代理限流器从单门改双门cap 放宽 + 连续 FAIL 流式阻断,正常多步工作不再被误杀。

修复

  • 子代理限流器双门#78。原 verification 类子代理 cap=55 个连续 PASS 的 PR 验证后第 6 个就被硬阻断——即使每次都成功。源码注释承诺「only fires on pathological loops, not on normal multi-step work」实际行为违背了这条契约。本版把单门改成双门
    • 总 cap 放宽verification 5 → 12。日常多 PR 工作有充足预算。
    • 连续 FAIL streak 门:新增 noteOutcome(agentType, verdict)。3 次连续 FAIL无 PASS 中断)立即 cap与总数无关。任何 PASS / UNKNOWN 清零 streak。这才是真正抓 verifier-loop 的语义。
    • 保守 verdict 解析parseVerdict(text) 解析子代理输出的 VERDICT: PASS|FAIL|CHANGES_NEEDED|APPROVE|UNCONFIRMED 行,附带 SECURITY: PLAN_REVIEW: ROOT CAUSE: 同义词。UNKNOWN 当 soft-PASS ── 一次性研究类子代理(如 Explore没有 verdict 结构的输出不会被误杀。
    • 错误文案区分 cappedReason: 'total' | 'streak' | 'none',用户能看到具体哪个门触发。
    • 环境变量出口保留:CLAUDE_CODE_AGENT_LIMIT_<TYPE>=N 调高 total cap、CLAUDE_CODE_AGENT_LIMITER_OFF=1 整体禁用。

测试

  • src/tools/AgentTool/invocationLimiter.test.ts28 cases / 153 expects 全过。
    • 14 个原测试按新 cap=12 适配
    • 5 个 streak 行为新测试3 FAIL trip / PASS clears / UNKNOWN soft-PASS / per-agent-type 隔离 / 12 PASS 触 total cap not streak
    • 9 个 parseVerdict 测试empty / 标准 VERDICT 行 / FAIL 同义词 / APPROVE / 专家技能同义词 / 无 verdict / markdown 容忍 / 长 input tail
  • 验证子代理独立 PASS含 8 个对抗性场景5 PR PASS 序列、verifier loop 模拟、PASS 中断 streak、跨 type 隔离、真实子代理输出、UNKNOWN soft-PASS、orphan FAIL、12 PASS 后 total cap。

设计审查

  • UNKNOWN 当 soft-PASS 的攻击面:恶意子代理可省略 VERDICT 行避开 streak但 total cap=12 仍兜底;且子代理 prompt 由调用方完全控制,不是普通输入面。
  • throw / abort 场景的 streak 状态noteInvocation 已增计数但 noteOutcome 不跑——streak 保持原值不偏移,下次调用基于既有 streak 起步PASS 仍能清零。
  • 接入点对称性AgentTool.tsxnoteOutcomenoteInvocation 用完全相同的 guard (!toolUseContext.agentId && isBuiltInAgent(selectedAgent) && !isLimiterDisabled()),避免 streak/total 计数不同步。

范围

  • src/tools/AgentTool/invocationLimiter.ts:核心改造,加 streak 状态、noteOutcome、parseVerdict、双门判定。
  • src/tools/AgentTool/AgentTool.tsxcompleted 分支加 noteOutcome 调用。
  • src/tools/AgentTool/invocationLimiter.test.ts14→28 测试。