[BUG] Background agents consume full rate limit but produce zero output when rate-limited mid-execution
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Description:
## Problem
When launching multiple background agents (via Task tool) that perform web searches,
the agents consume a large portion of the rate limit during their research phase
(web searches, analysis) but get terminated before they can write their final output.
This results in significant token consumption with zero usable results returned to the user.
What Should Happen?
Expected Behavior
At minimum, one of the following:
- Agents should be aware of remaining rate limit and prioritize saving intermediate
results before exhaustion
- Graceful degradation: when approaching rate limit, agent should flush
whatever results it has gathered so far to the output file
- Token consumption from failed agents should be refunded or not counted
against the rate limit
- A warning/budget mechanism: agents should have a "reserve budget" for
writing final output, and stop research when only the reserve remains
## Actual Behavior
- Agents spend 100% of available tokens on research (web search, analysis)
- 0% of tokens remain for output generation
- Output files are completely empty
- User receives nothing despite heavy rate limit consumption
## Impact
- User loses entire rate limit window 2 times (I even tried 2 times, and they went gone all.) and even api billing(it says: more than 5$ was spent) was used for this, but loses everything.
- All research work is non-recoverable (transcripts are also empty)
- Must redo the same work from scratch after reset, consuming another full limit cycle
- Effectively doubles (or more) the cost of the task
Error Messages/Logs
● 일부 에이전트가 API 한도에 도달했다. 수집된 결과를 확인해보겠다.
● Read 5 files (ctrl+o to expand)
● 5개 에이전트 모두 API rate limit에 걸려서 최종 결과를 출력하지 못했다. 에이전트들이 내부적으로 웹 검색과
분석을 수행했지만, 결과를 쓰기 전에 한도에 도달한 상태다.
현재 상황:
- 에이전트 1 (영상분석), 에이전트 5 (치료계획)는 아직 실행 중일 수 있음
- 완료된 에이전트 2, 3, 4는 출력 파일이 비어 있음 (한도 초과)
대응 방안:
- API 한도가 리셋(오후 7시)된 후 리서치를 재개하거나
- 지금 이 세션에서 웹 검색 없이 훈련 데이터 기반으로 5개 영역을 정리할 수 있음
어떻게 진행할지 — 리셋 후 재실행할 것인지, 지금 가능한 범위에서 정리할 것인지?
✻ Cogitated for 39s
❯ api한도 풀림. continue
● 5개 리서치 에이전트를 모두 재실행한다.
● 5 Task agents launched (ctrl+o to expand)
├─ 치과 AI 영상분석/진단 리서치
│ ⎿ Running in the background (shift+↑ to manage)
├─ 치과 보험청구/행정 자동화 리서치
│ ⎿ Running in the background (shift+↑ to manage)
├─ 치과 환자 커뮤니케이션 에이전트 리서치
│ ⎿ Running in the background (shift+↑ to manage)
├─ 치과 시술 문서화/AI 스크라이브 리서치
│ ⎿ Running in the background (shift+↑ to manage)
└─ 치과 치료계획 수립 AI 리서치
⎿ Running in the background (shift+↑ to manage)
● 5개 에이전트 모두 재실행 중이다. 각각 결과를 파일로 저장하도록 지시했다.
┌─────┬────────────────────────────┬─────────────────────────────┬─────────┐
│ # │ 활용안 │ 저장 파일 │ 상태 │
├─────┼────────────────────────────┼─────────────────────────────┼─────────┤
│ 1 │ AI 영상분석/진단 보조 │ research_1_imaging.md │ 실행 중 │
├─────┼────────────────────────────┼─────────────────────────────┼─────────┤
│ 2 │ 보험청구/행정 자동화 │ research_2_claims.md │ 실행 중 │
├─────┼────────────────────────────┼─────────────────────────────┼─────────┤
│ 3 │ 환자 커뮤니케이션 에이전트 │ research_3_communication.md │ 실행 중 │
├─────┼────────────────────────────┼─────────────────────────────┼─────────┤
│ 4 │ 시술 문서화/AI 스크라이브 │ research_4_scribe.md │ 실행 중 │
├─────┼────────────────────────────┼─────────────────────────────┼─────────┤
│ 5 │ 치료계획 수립 보조 AI │ research_5_treatment.md │ 실행 중 │
└─────┴────────────────────────────┴─────────────────────────────┴─────────┘
완료되면 알려주겠다.
✻ Baked for 2m 8s
● Agent "치과 AI 영상분석/진단 리서치" completed
● 이전 배치(파일 저장 지시 없었던 것)의 잔여 에이전트가 종료된 것이다. 현재 실행 중인 새 배치 5개는 모두
정상 진행 중 — 각각 웹 검색 + 분석 단계를 수행하고 있다. 완료되면 알려주겠다.
● Agent "치과 치료계획 수립 AI 리서치" completed
● 이것도 이전 배치의 잔여 에이전트다. 새 배치 5개는 계속 실행 중이다.
● Agent "치과 시술 문서화/AI 스크라이브 리서치" completed
⎿ You've hit your limit · resets 12am (Asia/Seoul)
❯ /rate-limit-options
⎿ Login successful
● Agent "치과 환자 커뮤니케이션 에이전트 리서치" completed
● 에이전트들이 다시 rate limit에 걸리고 있다. 파일 저장이 되었는지 확인하겠다.
● Searched for 1 pattern (ctrl+o to expand)
● 파일 저장 전에 한도에 도달했다. 아직 실행 중인 에이전트 2개(1번 영상분석, 2번 보험청구)의 결과를
기다려보겠다. 만약 그것들도 실패하면, 한도 리셋 후 재시도하거나 이 세션에서 직접 작성하는 방식으로
전환해야 한다.
● Agent "치과 치료계획 수립 AI 리서치" completed
● Task Output(non-blocking) a7d0d94
⎿ Read output (ctrl+o to expand)
● Task Output(non-blocking) ab868ca
⎿ Read output (ctrl+o to expand)
● Searched for 1 pattern (ctrl+o to expand)
● 5개 에이전트 모두 rate limit으로 파일 저장에 실패했다.
상황 정리:
- opus 모델 병렬 에이전트 5개가 웹 검색까지는 수행했지만, 결과 작성/저장 전에 한도 초과
- 다음 리셋: 자정 (Asia/Seoul)
대안:
1. 자정 이후 재시도
2. 지금 이 세션에서 sonnet 모델로 직접 웹 검색 + 리서치 수행 (에이전트 아닌 직접 작업)
3. 에이전트를 1개씩 순차 실행 (병렬 대신 한도 분산)
어떻게 진행할지?
● Agent "치과 보험청구/행정 자동화 리서치" completed
● 마지막 에이전트도 한도 초과로 종료됐다. 전체 5개 모두 결과 저장 실패.
자정 리셋 후 재시도하거나, 다른 방식으로 전환할지 알려달라.
● Agent "치과 AI 영상분석/진단 리서치" completed
● 전체 결과 확인 완료. 5개 에이전트 모두 웹 검색/분석 단계까지 진행했으나, 결과 파일 저장 전에 rate limit
도달.
자정 리셋 대기 중이다. 리셋되면 알려달라.
❯ 5개 리서치 결과가 저장안되고 날라가서 처음부터 다시해야하는거야?
● 에이전트 트랜스크립트 파일에 중간 결과가 남아있을 수 있다. 확인해보겠다.
● Read 5 files (ctrl+o to expand)
● 트랜스크립트 파일도 전부 비어있다. 결과가 모두 유실됐고, 처음부터 다시 해야 한다.
원인 분석: opus 모델 에이전트 5개를 병렬 실행하면 토큰 소모가 폭발적으로 증가한다. 각 에이전트가 웹 검색
15-20회를 수행하면서 한도를 빠르게 소진했고, 최종 결과 작성/저장 단계에 도달하지 못했다.
Steps to Reproduce
## Steps to Reproduce
- Launch 5 background agents in parallel using
opusmodel - Each agent performs 15-20 web searches + analysis
- Agents hit rate limit during execution
- All agents terminate with "You've hit your limit" message
- Output files are empty (0 bytes of usable content)
- All consumed tokens are lost with no results
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.45
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
PyCharm terminal
Additional Information
## Environment
- Claude Code CLI
- Model: claude-opus-4-6 (background agents)
- Platform: Windows (MINGW64)
- 5 parallel background agents, each performing web research tasks
<img width="941" height="1779" alt="Image" src="https://github.com/user-attachments/assets/dd0a82b4-1b10-4ab4-ab23-ed20dc5acc92" />
<img width="957" height="1754" alt="Image" src="https://github.com/user-attachments/assets/6461c08b-139a-4d65-b260-3da9db0926b1" />
<img width="936" height="1138" alt="Image" src="https://github.com/user-attachments/assets/486457b8-fdb7-4b3d-b12c-94923afb2323" />
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗