Skip to content

feat(subagent): AgentTool 并发/会话/深度护栏 (P2.1, CC 2.1.217 对齐) #81

Closed

Description

@dahai80

背景

P2.1 子代理护栏 (enhance-0819.md §D.4 P2.1)。审计确认 fusion-code AgentTool spawn 路径缺并发/会话/深度上限, 无失控刹车:

设计 (照 CC A.2.1, 3 维度)

本 PR 落地 spec 步骤 1 (并发/会话/深度计数器 + 上限拒)。预算上限 (步骤 2) + 后台默认 (步骤 3) 成本更高/行为变更, 另 PR 处理。

维度 环境变量 默认 检查点
并发 FUSION_MAX_CONCURRENT_SUBAGENTS 20 getRunningTasks(appState) 过滤 local_agent running, >= 拒
会话 FUSION_MAX_SUBAGENTS_PER_SESSION 200 AppState.subagentSpawnCount spawn 时自增, >= 拒, /clear 重置
深度 FUSION_MAX_SUBAGENT_SPAWN_DEPTH 3 toolUseContext.queryTracking?.depth ?? 0, >= 拒

检查位置

AgentTool.call() — spawn 分派前 (sync + async 共用), 在 selectedAgent 解析后, shouldRunAsync 分支前。错误经现有 throw 路径回传模型。

范围外 (defer)

  • 预算上限 --max-budget-tokens 停后台子代理 (dim 4/5, 需 per-agent cost accumulator, 成本高)
  • 子代理默认后台 (行为变更, 非纯护栏)

验收

  • 3 上限生效, 超限 spawn 拒绝 + 清晰错误
  • /clear 重置会话计数
  • typecheck 0, 既有测试全过, 新增护栏单测全绿
  • build + build:dev:full pass

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions