Listen to Claude Code's StopFailure hook to detect API-failed turns immediately

Đã đóng
#865 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

Start by reading the Claude profile's hook registration in bmad-loop init, then trace how the relay journals Stop and how the engine handles transport or environment faults. The issue does not name specific files or tests, so first locate those entry points and existing recovery paths. Done means StopFailure is registered and journaled, transient errors recover without charging a dev attempt, and account or quota errors pause with an escalation.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Describe your idea
Register Claude Code's StopFailure hook event in the relay, so a turn that ends on an API error is seen at once instead of through the stall budget.

Why is this needed?
On bmad-loop 0.13.0 (Claude Code adapter, herdr backend, Linux), a dev session finished its work, then its turn ended on an API error ("Connection lost mid-response"). The relay recorded no Stop for that session. The pane sat idle for about 34 minutes until I unblocked it by hand with a message. Policy at the time: session_timeout_min = 90, dev_stall_grace_s = 600, dev_stall_nudges = 2. From the hook events alone I cannot tell whether the stall nudges fired.

bmad-loop init registers SessionStart, Stop, SessionEnd, PreCompact and Notification. Claude Code also emits StopFailure when a turn ends because of an API error. Its input carries error (rate_limit, overloaded, server_error, unknown, authentication_failed, billing_error, ...), error_details and last_assistant_message (type StopFailureHookInput in Claude Code's hook type definitions). Today this signal is lost, and the loop can only learn about the failure from silence. I found no mention of StopFailure in the 0.13.1 release notes or in existing issues.

How should it work?

  • init registers StopFailure for the claude profile, next to the existing events, and the relay journals it like Stop.
  • On StopFailure, the engine classifies the turn as a transport or environment fault without charging a dev attempt, then recovers through the existing path (nudge or relaunch) instead of waiting for the grace to expire.
  • error drives the choice: transient values (overloaded, server_error, unknown) retry; account or quota values (rate_limit, billing_error, authentication_failed) pause the run with a clear escalation, since a retry cannot succeed.

Additional context
Related: #194 (API failure charged as a timeout), #470 (stall detection arming), #764 (late transient 5xx classified as an environment fault), #610 (usage-limit pattern).

Ngôn ngữ chính
Python
Star
178
Fork
73
Merge trung bình
17 giờ 56 phút
Pull request đã merge (30 ngày)
95

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của bmad-code-org/bmad-loop

Tất cả issue của bmad-code-org/bmad-loop

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.