makecindy / makecindy/cindy

[Bug] 上游模型单轮工具调用计数把 subagent 的调用也算入,导致误判死循环并中断任务

Open
#1,193 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
2.7k
Forks
395
Avg merge
21h 48m
Merged PRs (30d)
776

Description

**提交人**: cf
**客户端版本**: 0.1.23

---

## 现象

在 Claude Code 中,当模型调用 subagent 执行子任务时,很容易触发如下报错,当前 turn 被自动中断:

> 上游模型单轮已累计 101 次工具调用仍未收敛,疑似陷入死循环,已自动中断当前 turn。可以直接发下一条消息继续,已完成的 tool result 都保留。

## 复现步骤 / 使用场景

- 客户端:Claude Code
- 在任务中启用 **3 个 subagent 并行执行**子任务,几乎必现,而且触发非常快(几个回合内就会撞到上限)。
- subagent 数量越多、单个 subagent 内部工具调用越多,越容易触发。

## 疑似原因

上游模型单轮的工具调用计数把 subagent 内部的工具调用也一并累计了。上游本身工具调用没到上限,但因为每个 subagent 都在内部大量调用工具,总和很快达到 101 次,被误判为"死循环"。

## 期望行为

1. **subagent 的工具调用不计入上游模型单轮工具调用计数**,subagent 应有独立的工具调用配额/上限,按 agent 层级分别统计;
2. 或针对 subagent 场景**提高单轮阈值**,给正常的多 agent 编排任务留出余量,避免误杀;
3. 两者兼顾为佳。

## 环境

- 客户端:Claude Code(具体客户端版本/OS 由系统附加)
---
**版本区域**: CN
**OS**: win32 x64 (10.0.26200)
**界面语言**: zh-CN

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure in Claude Code with three parallel subagents and trace how the 101-tool-call count is accumulated across agent levels. Done means parent-agent counting no longer includes subagent calls, with separate per-agent limits or an explicitly adjusted threshold, and the multi-agent scenario no longer aborts prematurely.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
ai
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.