From 5ad8356b5ce4d525af079f902791559d53b67bba Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Mon, 9 Mar 2026 01:08:51 +0000 Subject: executor: fix Claude rate-limit detection and prioritize Gemini when limited Updated parseStream to detect 'rate_limit_event' and 'assistant' error:rate_limit messages from the Claude CLI. Updated Classifier to strongly prefer non-rate-limited agents. Added logging to Pool to track rate-limit status during classification. --- internal/executor/claude.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'internal/executor/claude.go') diff --git a/internal/executor/claude.go b/internal/executor/claude.go index d6d92cb..2faeff3 100644 --- a/internal/executor/claude.go +++ b/internal/executor/claude.go @@ -421,6 +421,17 @@ func parseStream(r io.Reader, w io.Writer, logger *slog.Logger) (float64, error) msgType, _ := msg["type"].(string) switch msgType { + case "rate_limit_event": + if info, ok := msg["rate_limit_info"].(map[string]interface{}); ok { + status, _ := info["status"].(string) + if status == "rejected" { + streamErr = fmt.Errorf("claude rate limit reached: %v", msg) + } + } + case "assistant": + if errStr, ok := msg["error"].(string); ok && errStr == "rate_limit" { + streamErr = fmt.Errorf("claude rate limit reached: %v", msg) + } case "result": if isErr, _ := msg["is_error"].(bool); isErr { result, _ := msg["result"].(string) -- cgit v1.2.3