Skip to content

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

Go

MUL-8244: fix(agent): preserve recovered Antigravity stream responses (#9534)

Dante2de89ff46e87
diff --git a/server/pkg/agent/antigravity.go b/server/pkg/agent/antigravity.go
index 11bd2a8acb..b8b2f26788 100644
--- a/server/pkg/agent/antigravity.go
+++ b/server/pkg/agent/antigravity.go
@@ -190,6 +190,10 @@ type antigravityStreamEvent struct {
// has to stay a literal match alongside the transport patterns below.
const antigravityNetworkIssueError = "There was a network issue connecting to the server, please try again."
+// agy 1.4.6 may carry this historical/recovered stream error into a resumed
+// turn's result even when the current final response is DONE (#9528).
+const antigravityStreamInterruptedError = "The stream was interrupted. Please continue the task you were working on."
+
// antigravityTransportErrorRe matches the causes Go's http client reports when
// a round trip never produced a response: socket, DNS and TLS failures. These
// are the strings that appear inside the `*url.Error` agy wraps as
@@ -217,7 +221,7 @@ func antigravityTrailingTransportError(providerError string) bool {
if trimmed == "" {
return false
}
- if strings.EqualFold(trimmed, antigravityNetworkIssueError) {
+ if strings.EqualFold(trimmed, antigravityNetworkIssueError) || strings.EqualFold(trimmed, antigravityStreamInterruptedError) {
return true
}
return antigravityTransportErrorRe.MatchString(trimmed)
@@ -273,8 +277,13 @@ func antigravityResultStatus(status string) string {
// provider-side rejection is a real failure), agy has to have handed back a
// non-empty canonical response, and the latest agent_response step has to have
// reached DONE — an ACTIVE step means the answer was still being written when
-// the connection went away.
-func antigravityCompletedDespiteTrailingNetworkError(providerError, response string, agentResponseDone bool) bool {
+// the connection went away. The stream-interrupted sentence also requires a
+// successful process exit, since a DONE step can precede a genuinely interrupted
+// tool call in the same turn.
+func antigravityCompletedDespiteTrailingNetworkError(providerError, response string, agentResponseDone, exitedSuccessfully bool) bool {
+ if strings.EqualFold(strings.TrimSpace(providerError), antigravityStreamInterruptedError) && !exitedSuccessfully {
+ return false
+ }
return antigravityTrailingTransportError(providerError) &&
strings.TrimSpace(response) != "" &&
agentResponseDone
@@ -497,7 +506,7 @@ func (b *antigravityBackend) Execute(ctx context.Context, prompt string, opts Ex
finalStatus = "aborted"
finalError = "execution cancelled"
} else if status := antigravityResultStatus(streamResultStatus); finalStatus == "completed" && status != "completed" {
- if antigravityCompletedDespiteTrailingNetworkError(streamResultError, streamResponse, streamLatestAgentResponseDone) {
+ if antigravityCompletedDespiteTrailingNetworkError(streamResultError, streamResponse, streamLatestAgentResponseDone, waitErr == nil) {
// agy can emit a complete DONE response and only then fail a
// follow-up network operation. Preserve the finished answer instead
// of presenting that trailing transport error as a failed turn.
diff --git a/server/pkg/agent/antigravity_test.go b/server/pkg/agent/antigravity_test.go
index b552748963..580f964a39 100644
--- a/server/pkg/agent/antigravity_test.go
+++ b/server/pkg/agent/antigravity_test.go
@@ -966,6 +966,55 @@ func TestAntigravityBackendIgnoresTrailingNetworkErrorAfterDoneResponse(t *testi
}
}
+// agy 1.4.6 can retain an earlier interruption in the result of a resumed
+// conversation, even after the current response finishes successfully (#9528).
+func TestAntigravityBackendRecoveredStreamInterruption(t *testing.T) {
+ t.Parallel()
+
+ for _, tc := range []struct {
+ done bool
+ exitCode int
+ }{
+ {done: true, exitCode: 0},
+ {done: false, exitCode: 0},
+ {done: true, exitCode: 1},
+ } {
+ t.Run(fmt.Sprintf("response_done=%v/exit=%d", tc.done, tc.exitCode), func(t *testing.T) {
+ t.Parallel()
+ fakePath := filepath.Join(t.TempDir(), "agy")
+ script := strings.ReplaceAll(fakeAgyTrailingNetworkErrorScript(tc.done), antigravityNetworkIssueError,
+ "The stream was interrupted. Please continue the task you were working on.")
+ script = strings.ReplaceAll(script, "exit 1", fmt.Sprintf("exit %d", tc.exitCode))
+ writeTestExecutable(t, fakePath, []byte(script))
+
+ backend, err := New("antigravity", Config{ExecutablePath: fakePath, Logger: quietAntigravityLogger()})
+ if err != nil {
+ t.Fatalf("new antigravity backend: %v", err)
+ }
+ session, err := backend.Execute(context.Background(), "follow-up", ExecOptions{
+ ResumeSessionID: "37a6d8f2-8523-46fc-8fc9-87e630cbe295",
+ })
+ if err != nil {
+ t.Fatalf("execute: %v", err)
+ }
+ for range session.Messages {
+ }
+ result, ok := <-session.Result
+ if !ok {
+ t.Fatal("result channel closed without a value")
+ }
+ wantStatus := "failed"
+ completed := tc.done && tc.exitCode == 0
+ if completed {
+ wantStatus = "completed"
+ }
+ if result.Status != wantStatus || result.Output != "Complete answer." || (result.Error == "") != completed {
+ t.Fatalf("result = status %q output %q error %q", result.Status, result.Output, result.Error)
+ }
+ })
+ }
+}
+
func TestAntigravityBackendIgnoresStaleActiveStepAfterDoneResponse(t *testing.T) {
t.Parallel()
@@ -1081,6 +1130,7 @@ func TestAntigravityTrailingTransportErrorClassification(t *testing.T) {
err: " THERE WAS A NETWORK ISSUE CONNECTING TO THE SERVER, PLEASE TRY AGAIN. ",
want: true,
},
+ {name: "recovered stream interruption", err: "The stream was interrupted. Please continue the task you were working on.", want: true},
{name: "unexpected EOF", err: `Post "https://host/v1": unexpected EOF`, want: true},
{name: "connection reset", err: `read tcp 1.2.3.4:443: connection reset by peer`, want: true},
{name: "broken pipe", err: `write tcp 1.2.3.4:443: broken pipe`, want: true},
@@ -1150,6 +1200,7 @@ func TestAntigravityCompletedDespiteTrailingNetworkErrorRequiresAllThree(t *test
{name: "response whitespace only", err: transport, response: " \n ", agentResponseDone: true, want: false},
{name: "response empty", err: transport, response: "", agentResponseDone: true, want: false},
{name: "answer still being written", err: transport, response: "partial", agentResponseDone: false, want: false},
+ {name: "interrupted response whitespace only", err: "The stream was interrupted. Please continue the task you were working on.", response: " ", agentResponseDone: true, want: false},
{name: "provider rejection", err: quota, response: "answer", agentResponseDone: true, want: false},
{name: "no error at all", err: "", response: "answer", agentResponseDone: true, want: false},
}
@@ -1157,7 +1208,7 @@ func TestAntigravityCompletedDespiteTrailingNetworkErrorRequiresAllThree(t *test
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
- got := antigravityCompletedDespiteTrailingNetworkError(tc.err, tc.response, tc.agentResponseDone)
+ got := antigravityCompletedDespiteTrailingNetworkError(tc.err, tc.response, tc.agentResponseDone, false)
if got != tc.want {
t.Fatalf("antigravityCompletedDespiteTrailingNetworkError(%q, %q, %v) = %v, want %v",
tc.err, tc.response, tc.agentResponseDone, got, tc.want)