Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(taskfailure): classify Kiro dispatch failure as retryable provider_network (MUL-8314) (#9621)
Multica Eve55be334864e1
diff --git a/server/pkg/taskfailure/classify.go b/server/pkg/taskfailure/classify.goindex 2ffb95bb8c..4919c7f4dc 100644--- a/server/pkg/taskfailure/classify.go+++ b/server/pkg/taskfailure/classify.go@@ -205,6 +205,18 @@ func Classify(rawError string) Reason {):return ReasonAgentProviderCapacityOrRateLimit+ // 5b. Kiro transport failure. Kiro is built on the AWS SDK for Rust, whose+ // DispatchFailure means the HTTP request never got a response (connect+ // error, reset, I/O timeout). Kiro surfaces it through ACP as a JSON-RPC+ // -32603 "Internal error", and that wrapper phrase alone would send it to+ // rule 6 (provider_server_error), which is not retryable — so a dropped+ // connection mid-turn ended long tasks outright (MUL-8314). It belongs+ // in provider_network: retryable, and resume-safe. Checked after the+ // auth / quota / capacity rules so real provider evidence still wins,+ // and only before rule 6 because of that wrapper.+ case isKiroDispatchFailure(lower):+ return ReasonAgentProviderNetwork+// 6. Provider 5xx / server error. The 5xx regex is checked here// rather than as plain string matches because the SQL uses an// anchored regex — see providerHTTP5xxRe's docstring.@@ -545,6 +557,35 @@ var legacyCursorProviderNetworkReasons = map[string]bool{"agent_error": true,}+// Kiro's stream-error witness, as it appears in session/prompt failures:+//+// kiro session/prompt failed: session/prompt: Internal error (code=-32603,+// data=Encountered an error in the response stream: An unknown error+// occurred: dispatch failure)+//+// Both phrases are required. The stream prefix alone also wraps deterministic+// request rejections (e.g. an oversized history image) that a+// retry would only reproduce; "dispatch failure" alone is too generic to treat+// as provider evidence when it comes from a tool or MCP server.+const (+ kiroResponseStreamErrorPhrase = "encountered an error in the response stream"+ kiroDispatchFailurePhrase = "dispatch failure"+)++func isKiroDispatchFailure(lower string) bool {+ return strings.Contains(lower, kiroResponseStreamErrorPhrase) &&+ strings.Contains(lower, kiroDispatchFailurePhrase)+}++// legacyKiroDispatchFailureReasons are the buckets a daemon predating rule 5b+// files a Kiro dispatch failure under: provider_server_error via the+// "Internal error" wrapper, or the catchalls.+var legacyKiroDispatchFailureReasons = map[string]bool{+ string(ReasonAgentProviderServerError): true,+ string(ReasonAgentUnknown): true,+ "agent_error": true,+}+func isPiProviderNetworkError(lower string) bool {for _, message := range []string{"connection error.", "request timed out."} {if lower == message ||@@ -658,6 +699,13 @@ func NormalizeDaemonReason(reason, rawError string) Reason {isCursorProviderNetworkError(lowerError) && Classify(rawError) == ReasonAgentProviderNetwork {return ReasonAgentProviderNetwork}+ // MUL-8314: same mixed-version gap for Kiro's dispatch failure. Classify+ // must still agree, so a co-occurring auth / quota / capacity signal keeps+ // the more specific reason.+ if legacyKiroDispatchFailureReasons[reason] && isKiroDispatchFailure(lowerError) &&+ Classify(rawError) == ReasonAgentProviderNetwork {+ return ReasonAgentProviderNetwork+ }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.gonew file mode 100644index 0000000000..d801167a28--- /dev/null+++ b/server/pkg/taskfailure/kiro_dispatch_failure_test.go@@ -0,0 +1,70 @@+package taskfailure++import "testing"++// kiroDispatchFailureErr is verbatim from failed Kiro runs (MUL-8314): the AWS+// SDK's DispatchFailure, wrapped in ACP's -32603 "Internal error".+const kiroDispatchFailureErr = `kiro session/prompt failed: session/prompt: Internal error (code=-32603, data=Encountered an error in the response stream: An unknown error occurred: dispatch failure)`++func TestClassifyKiroDispatchFailure(t *testing.T) {+ t.Parallel()++ cases := []struct {+ name string+ in string+ want Reason+ }{+ // Transport failure: retryable and resume-safe, not a provider 5xx.+ {"dispatch failure", kiroDispatchFailureErr, ReasonAgentProviderNetwork},+ // A deterministic rejection under the same stream wrapper must not be+ // retried as network flakiness.+ {+ "oversized image under the same wrapper",+ `kiro session/prompt failed: session/prompt: Internal error (code=-32603, data=Encountered an error in the response stream: messages.14.content.0.image.source.base64.data: At least one of the image dimensions exceed max allowed size: 8000 pixels)`,+ ReasonAgentProviderServerError,+ },+ // "dispatch failure" without Kiro's stream witness is not provider evidence.+ {"bare dispatch failure", "mcp tool returned: dispatch failure", ReasonAgentUnknown},+ // Real provider evidence still wins over the transport witness.+ {+ "rate limit co-occurring",+ `kiro session/prompt failed: session/prompt: Internal error (code=-32603, data=Encountered an error in the response stream: 429 rate limit: dispatch failure)`,+ ReasonAgentProviderCapacityOrRateLimit,+ },+ }+ for _, tc := range cases {+ t.Run(tc.name, func(t *testing.T) {+ t.Parallel()+ if got := Classify(tc.in); got != tc.want {+ t.Errorf("Classify(%q) = %q, want %q", tc.in, got, tc.want)+ }+ })+ }+}++// An installed daemon predating the Classify rule reports+// provider_server_error; the server must upgrade it so the retry applies+// without waiting on the daemon fleet.+func TestNormalizeDaemonReasonUpgradesKiroDispatchFailure(t *testing.T) {+ t.Parallel()++ for _, legacy := range []string{+ string(ReasonAgentProviderServerError),+ string(ReasonAgentUnknown),+ "agent_error",+ } {+ if got := NormalizeDaemonReason(legacy, kiroDispatchFailureErr); got != ReasonAgentProviderNetwork {+ t.Errorf("NormalizeDaemonReason(%q, dispatch failure) = %q, want %q", legacy, got, ReasonAgentProviderNetwork)+ }+ }++ // A more specific reason the daemon chose is left alone.+ if got := NormalizeDaemonReason(string(ReasonAgentProviderAuthOrAccess), kiroDispatchFailureErr); got != ReasonAgentProviderAuthOrAccess {+ t.Errorf("auth reason was overwritten: got %q", got)+ }+ // A genuine server error without the dispatch witness is untouched.+ const serverErr = `kiro session/prompt failed: session/prompt: Internal error (code=-32603, data=Encountered an error in the response stream: 503 service unavailable)`+ if got := NormalizeDaemonReason(string(ReasonAgentProviderServerError), serverErr); got != ReasonAgentProviderServerError {+ t.Errorf("plain server error was upgraded: got %q", got)+ }+}