Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(taskfailure): classify Kiro service throttling as rate limit (MUL-9320) (#10677)

Bohan Jiangc42dcacee68b
diff --git a/server/pkg/taskfailure/classify.go b/server/pkg/taskfailure/classify.go
index c8303370fa..bd2aeafb64 100644
--- a/server/pkg/taskfailure/classify.go
+++ b/server/pkg/taskfailure/classify.go
@@ -202,12 +202,15 @@ func Classify(rawError string) Reason {
):
return ReasonAgentProviderQuotaLimit
- // 5. Capacity / rate limit. 429 / 529 / overloaded / rate limit.
+ // 5. Capacity / rate limit. 429 / 529 / overloaded / rate limit, and
+ // Kiro's throttling message, which carries none of those words and
+ // would otherwise reach rule 6 through its "Internal error" wrapper.
case httpCapacityCodeRe.MatchString(lower),
containsAny(lower,
"rate limit",
"overloaded",
"no capacity available",
+ kiroThrottledWitness,
):
return ReasonAgentProviderCapacityOrRateLimit
@@ -578,6 +581,17 @@ const (
kiroDispatchFailurePhrase = "dispatch failure"
)
+// kiroThrottledWitness is Kiro CLI's fixed message for a throttled request
+// (GH #10652), surfaced through the same -32603 response-stream wrapper:
+//
+// kiro session/prompt failed: session/prompt: Internal error (code=-32603,
+// data=Encountered an error in the response stream: The request was
+// throttled by the service (request_id: ...))
+//
+// The whole phrase is matched rather than a bare "throttled", which also
+// appears in unrelated text such as log or heartbeat descriptions.
+const kiroThrottledWitness = "request was throttled by the service"
+
func isKiroDispatchFailure(lower string) bool {
return strings.Contains(lower, kiroResponseStreamErrorPhrase) &&
strings.Contains(lower, kiroDispatchFailurePhrase)
@@ -713,6 +727,14 @@ func NormalizeDaemonReason(reason, rawError string) Reason {
Classify(rawError) == ReasonAgentProviderNetwork {
return ReasonAgentProviderNetwork
}
+ // GH #10652: a daemon predating kiroThrottledWitness files Kiro's
+ // throttling under the same wrapper buckets. Neither bucket is retryable,
+ // so this only corrects the label; Classify must still agree.
+ if legacyKiroDispatchFailureReasons[reason] &&
+ strings.Contains(lowerError, kiroThrottledWitness) &&
+ Classify(rawError) == ReasonAgentProviderCapacityOrRateLimit {
+ return ReasonAgentProviderCapacityOrRateLimit
+ }
if legacyOpencodeStreamEndedReasons[reason] &&
(strings.HasPrefix(lowerError, opencodeStreamEndedPrefix) ||
strings.HasPrefix(lowerError, codeartsStreamEndedPrefix)) {
diff --git a/server/pkg/taskfailure/kiro_dispatch_failure_test.go b/server/pkg/taskfailure/kiro_dispatch_failure_test.go
index d801167a28..5dd324ade8 100644
--- a/server/pkg/taskfailure/kiro_dispatch_failure_test.go
+++ b/server/pkg/taskfailure/kiro_dispatch_failure_test.go
@@ -68,3 +68,38 @@ func TestNormalizeDaemonReasonUpgradesKiroDispatchFailure(t *testing.T) {
t.Errorf("plain server error was upgraded: got %q", got)
}
}
+
+// kiroThrottledErr is verbatim from GH #10652.
+const kiroThrottledErr = `kiro session/prompt failed: session/prompt: Internal error (code=-32603, data=Encountered an error in the response stream: The request was throttled by the service (request_id: eb275a9a-ad2a-481e-b072-37a1d1ec63f4))`
+
+func TestClassifyKiroThrottled(t *testing.T) {
+ t.Parallel()
+
+ if got := Classify(kiroThrottledErr); got != ReasonAgentProviderCapacityOrRateLimit {
+ t.Errorf("Classify(throttled) = %q, want %q", got, ReasonAgentProviderCapacityOrRateLimit)
+ }
+ // A bare "throttled" is not provider evidence.
+ if got := Classify("log output throttled to 1 line per second"); got == ReasonAgentProviderCapacityOrRateLimit {
+ t.Errorf("bare throttled classified as rate limit")
+ }
+}
+
+// An installed daemon predating the throttling witness reports
+// provider_server_error; the server upgrades the label.
+func TestNormalizeDaemonReasonUpgradesKiroThrottled(t *testing.T) {
+ t.Parallel()
+
+ for _, legacy := range []string{
+ string(ReasonAgentProviderServerError),
+ string(ReasonAgentUnknown),
+ "agent_error",
+ } {
+ if got := NormalizeDaemonReason(legacy, kiroThrottledErr); got != ReasonAgentProviderCapacityOrRateLimit {
+ t.Errorf("NormalizeDaemonReason(%q, throttled) = %q, want %q", legacy, got, ReasonAgentProviderCapacityOrRateLimit)
+ }
+ }
+ // A more specific reason the daemon chose is left alone.
+ if got := NormalizeDaemonReason(string(ReasonAgentProviderAuthOrAccess), kiroThrottledErr); got != ReasonAgentProviderAuthOrAccess {
+ t.Errorf("auth reason was overwritten: got %q", got)
+ }
+}