feat: pause room work on the Claude usage limit and resume after reset

Before, a Claude run that hit the account usage limit closed the open
paired task as claude_usage_limit, posted the reset time and consumed the
user's messages, so the work was lost and had to be re-requested.

Now the room is paused instead:
- The failed turn is released without touching the paired task (no
  failure count, no status change, no follow-up) and the queue keeps the
  human messages unconsumed, so the same turn can run again.
- The room is recorded in router_state `claude_usage_pause` with the reset
  time (error text, else cached usage API reset, else a 10 min retry). A
  banner time that just passed is read as "now", not tomorrow.
- While the limit lasts, paused rooms run nothing and any other room's
  Claude turn pauses that room without spawning a run (the limit is
  account-wide). A stop request still goes through and drops the room
  from the resume list.
- The scheduler tick clears the pause 1 min after the reset, posts a
  resume notice and re-queues the rooms; the pending turn or the kept
  messages then run again. The state survives restarts.

Safety refusals keep closing the task as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Codex
2026-10-13 13:14:56 +09:00
parent 1167023a13
commit aed7371cfa
19 changed files with 893 additions and 90 deletions

View File

@@ -13,7 +13,7 @@
- 마무리(finalize) 턴 비용 절감. (가) 리뷰어가 owner의 첫 TASK_DONE 답변을 첫 리뷰에서 바로 승인했고(리뷰 1회, owner 수정·중재 턴 없음) 승인 이후 작업 폴더가 그대로면 owner를 다시 실행하지 않고 그 답변(상태 줄 제외)을 최종 메시지로 올리고 task를 완료함. 검토 생략 답변에 "검토해줘"로 받은 리뷰가 바로 승인되면 답변을 반복하지 않고 `-# 검토 완료: …` 한 줄만 올림. (나) 그 밖의 마무리 턴은 task의 긴 작업 세션을 resume하지 않는 새 세션에서, 이번 task의 사용자 요청과 최근 turn 출력(최대 6개)과 마무리 형식 안내만 담은 프롬프트로 실행하고 세션을 저장하지 않음(방 메모리 브리핑도 생략). owner 규칙에 첫 TASK_DONE 답변도 최종 답변 형식을 따라야 한다고 명시
- paired 방의 owner·리뷰어 세션을 paired task 단위로 새로 시작. 같은 task 안의 후속 턴(리뷰 반영, 같은 task에 들어온 사용자 후속 메시지)은 그 세션을 이어 쓰고, 새 task의 첫 턴은 이전 세션을 resume하지 않음. 세션이 어느 task 것인지는 `router_state`의 `paired_session_task:<세션 폴더>`에 기록. 이전 task의 마지막 최종 답변은 새 task의 turn 0(carry-forward)으로 계속 전달되며, 이를 위해 `PAIRED_CARRY_FORWARD_LATEST_OWNER_FINAL` 기본값을 `true`로 변경. single 방은 그대로
- Claude가 사용 한도에 도달하면 Codex로 넘기는 대신 방에 "Claude 사용 한도에 도달했습니다. 21:40에 재개할 수 있습니다."처럼 재개 시각(KST)을 바로 알리고, 열린 paired task를 `claude_usage_limit`으로 닫음. 재개 시각은 오류 문구(`resets 9:40pm (Asia/Seoul)` 등)에서 읽고, 없으면 사용량 API 캐시에서, 그것도 없으면 "잠시 후 다시 시도해 주세요"로 안내. 조용한 자동 재시도는 하지 않음
- Claude가 사용 한도에 도달하면 Codex로 넘기지 않고 그 방의 작업을 일시정지했다가, 사용량이 초기화되면 자동으로 이어서 진행함. 한도에 걸린 turn은 실패로 세지 않고 paired task 상태를 그대로 두며, 처리하던 사용자 메시지도 처리 완료로 넘기지 않음. 방에는 "Claude 사용 한도에 도달해서 이 방의 작업을 일시정지했습니다. 21:40에 사용량이 초기화되면 자동으로 이어서 진행합니다."처럼 재개 시각(KST)을 알림. 한도는 계정 전체에 걸리므로 일시정지 중에는 다른 방의 Claude turn도 실행하지 않고 같은 방식으로 일시정지함(일시정지되지 않은 방의 Codex turn은 그대로 실행). 일시정지 상태는 `router_state`의 `claude_usage_pause`에 저장되어 재시작 후에도 유지되고, 스케줄러 tick이 초기화 시각 1분 뒤에 "Claude 사용량이 초기화되어서 일시정지했던 작업을 이어서 진행합니다."를 보내고 방들을 다시 큐에 넣음. 재개 시각은 오류 문구(`resets 9:40pm (Asia/Seoul)` 등)에서 읽고, 없으면 사용량 API 캐시에서, 그것도 없으면 10분 뒤에 다시 시도함. 일시정지 중 "중단"을 보내면 그 방의 작업을 버리고 재개 대상에서 뺌
- 기본 Claude 모델을 Claude Opus 5.5(`claude-opus-5-5`)로 상향. Opus 5.5는 Claude Code CLI 2.1.280 이상이 필요해 `@anthropic-ai/claude-agent-sdk`를 0.3.153 → 0.3.286(번들 CLI 2.1.286)으로 올림 (8b68885)
- `@openai/codex`를 0.133.0 → 0.159.3으로 상향. 구버전이 매 실행마다 내던 `failed to decode models response: unknown variant max` 오류와 로그 폭주가 사라지고, 단순 리뷰 턴이 49초 → 5초로 단축됨 (a7f2e02)