Skip to content

[Feature] 子代理 idle / 总时长超时改为可选(默认不启用),并增加活性可视化 / Re-add optional idle & duration timeouts for subagents (opt-in, off by default) plus liveness visibility #107

Description

@Alonso-li

Problem / 问题

自 0.13.7("Keep background subagents running until you stop them or the parent stops them")起,子代理的 idle / 总时长 watchdogs 被整体移除:sidecar.jsstartWatchdogs() 已是空实现,注释标明 "Idle and duration watchdogs are withdrawn (D328). Stopping a delegate is the parent agent's TaskStop or the user's Stop, not a timer."

这对长任务是好事(不会被打断),但它把选择权也从用户手里拿走了:

  1. 一个卡住的子代理(模型不再产生任何 token、也不再调用工具)现在只能靠手动 Stop / TaskStop 终止,没有任何自动兜底;
  2. 后台跑批量子代理时没盯着屏幕,卡住的 delegate 可能永远占着卡片、"运行中"直到天荒地老;
  3. 旧实现(feat(subagent): replace turn-limit termination with idle (600s) & duration (6h) timeouts; enable Bash for explorer #12 / f8868b8,0.10.1)的 SUBAGENT_IDLE_TIMEOUTSUBAGENT_DURATION_TIMEOUT 错误码、timed_out 状态和 i18n 都还在,UI 也保留着 "Timed out" 文案——只是 runtime 不再触发,属于半成品状态。

Proposed change / 期望改动

把 idle 超时改回可选,默认行为保持 0.13.7 之后的样子(不打断):

  1. 按子代理定义可选启用idleTimeoutSeconds / maxDurationSeconds 未配置时 = 无限期(行为与现在完全一致);显式配置正整数才启用看门狗。这样既有"跑到底"的自由,也有"卡了自动止损"的选择。
  2. 沿用 0.10.1 已验证的语义(f8868b8 / ADR 0119):lifecycle / message / tool 事件重置 idle 计时;tool_execution_starttool_execution_end 之间暂停 idle(正在跑命令不算发呆);总时长含工具执行时间。超时返回 timed_out + SUBAGENT_IDLE_TIMEOUT / SUBAGENT_DURATION_TIMEOUT,保留最新部分输出。
  3. 活性可视化(与 [Bug] 不知道什么原因执行过程过会卡住一段时间,没有任何提示和渲染,用户不清楚是否还在正常执行 #56 的阶段提示互补):卡片显示"最后活跃于 X 秒前"或"无活动 N 分钟",让不看日志也能判断 delegate 是否真的卡住。
  4. 保持手动和 A2A 之外的终止权:已配置超时只在超时后触发任务级 abort,不改变 parent 会话。

Alternatives / 其他方案

  • 维持现状:只靠用户手动 Stop(Do nothing);卡死 delegate 永远占资源。
  • 仅做活性可视化、不做自动超时(治标:能看见但还是要手动停)。
  • 仅恢复默认 600s idle(对长任务不友好,会破坏 0.13.7 的权衡)。

Additional context / 补充信息

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

    area: agent-runtimeAgent execution, subagents, tools, and runtime behavior

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions