Skip to content

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

Go

fix(antigravity): keep the conversation after a cancelled run or a new workdir (#11344)

kevin94e7ca78997e
diff --git a/server/internal/daemon/daemon.go b/server/internal/daemon/daemon.go
index c45f143c91..f50363416d 100644
--- a/server/internal/daemon/daemon.go
+++ b/server/internal/daemon/daemon.go
@@ -7052,6 +7052,11 @@ func providerNeedsInlineSystemPrompt(provider string) bool {
// Requiring the prior cwd as well would discard reachable history whenever a
// local_directory task gets a new worktree (#9062). An empty or unavailable
// store must still drop the resume, even when the cwd matches (#6806).
+// Antigravity keeps every conversation under its global app data directory
+// (<app data dir>/brain/<conversation id>), not under the cwd, so a follow-up
+// in a new workdir can still pass `--conversation` (#11316). If agy cannot load
+// the id after all, the run reports no session and the fresh-session retry
+// covers it.
// Codex also has a conversation-scoped store for local_directory tasks. A
// continued worktree may use a new cwd while retaining its branch and rollout.
// Managed Codex tasks still require the same existing directory.
@@ -7165,7 +7170,7 @@ func gateResumeToReachableSession(task *Task, taskCtx *execenv.TaskContextForEnv
var reachable bool
if providerUsesPiSessionFile(provider) {
reachable = piSessionResumable(task.PriorSessionID, refusesMissingSessionCwd)
- } else if provider == "hermes" {
+ } else if provider == "hermes" || provider == "antigravity" {
reachable = sessionHomeReachable
} else if provider == "codex" && codexWorktreeResumeEligible {
reachable = sessionHomeReachable
diff --git a/server/internal/daemon/daemon_test.go b/server/internal/daemon/daemon_test.go
index 8cded80357..9e69418d43 100644
--- a/server/internal/daemon/daemon_test.go
+++ b/server/internal/daemon/daemon_test.go
@@ -2380,6 +2380,33 @@ func TestGatePiResumeToSessionFile(t *testing.T) {
}
}
+// Antigravity stores conversations under its global app data directory, so a
+// follow-up that lands in a new workdir must keep the prior conversation
+// (#11316).
+func TestGateAntigravityResumeAcrossWorkdirs(t *testing.T) {
+ t.Parallel()
+
+ base := t.TempDir()
+ priorDir := filepath.Join(base, "prior-workdir")
+ envDir := filepath.Join(base, "fresh-workdir")
+ for _, dir := range []string{priorDir, envDir} {
+ if err := os.MkdirAll(dir, 0o755); err != nil {
+ t.Fatalf("create %s: %v", dir, err)
+ }
+ }
+ const conversationID = "27a6d8f2-8523-46fc-8fc9-87e630cbe295"
+ task := Task{PriorSessionID: conversationID, PriorWorkDir: priorDir}
+ taskCtx := execenv.TaskContextForEnv{PriorSessionResumed: true}
+
+ if !gateResumeToReachableSession(&task, &taskCtx, "antigravity", envDir, true, false, false, false, slog.Default()) {
+ t.Fatal("antigravity conversation should stay reachable from a new workdir")
+ }
+ if task.PriorSessionID != conversationID || !taskCtx.PriorSessionResumed || taskCtx.PriorSessionResumeUnavailable {
+ t.Fatalf("resume state changed: session=%q resumed=%v unavailable=%v",
+ task.PriorSessionID, taskCtx.PriorSessionResumed, taskCtx.PriorSessionResumeUnavailable)
+ }
+}
+
func TestGatePiResumeDropsUnusableSessionFile(t *testing.T) {
t.Parallel()
diff --git a/server/pkg/agent/antigravity.go b/server/pkg/agent/antigravity.go
index cebf0f9a99..a695fe7fb7 100644
--- a/server/pkg/agent/antigravity.go
+++ b/server/pkg/agent/antigravity.go
@@ -510,6 +510,18 @@ func (b *antigravityBackend) Execute(ctx context.Context, prompt string, opts Ex
scanner := newAgentStreamScanner(stdout)
trySend(msgCh, Message{Type: MessageStatus, Status: "running"})
+ // Announce the conversation id the moment agy names it so the daemon
+ // pins the resume pointer mid-run. A run that is cancelled or killed
+ // never reaches the terminal Result, and without the pin its follow-up
+ // would start a brand-new conversation.
+ var announcedSessionID string
+ announceSession := func(id string) {
+ if id == "" || id == announcedSessionID {
+ return
+ }
+ announcedSessionID = id
+ trySend(msgCh, Message{Type: MessageStatus, Status: "running", SessionID: id})
+ }
streamLoop:
for scanner.Scan() {
@@ -521,6 +533,7 @@ func (b *antigravityBackend) Execute(ctx context.Context, prompt string, opts Ex
streamSessionID = event.ConversationID
streamModel = event.Init.Model
supplements.activate(streamSessionID)
+ announceSession(streamSessionID)
case "step_update":
if event.StepUpdate == nil {
turn.invalid = true
@@ -541,6 +554,7 @@ func (b *antigravityBackend) Execute(ctx context.Context, prompt string, opts Ex
if event.StepUpdate.ConversationID != "" {
streamSessionID = event.StepUpdate.ConversationID
supplements.activate(streamSessionID)
+ announceSession(streamSessionID)
}
turn.confirmInjected(supplements, transcript, streamSessionID)
for _, message := range antigravityToolMessages(event.StepUpdate, streamTools) {
diff --git a/server/pkg/agent/antigravity_test.go b/server/pkg/agent/antigravity_test.go
index ddf4257564..e2353d5eb1 100644
--- a/server/pkg/agent/antigravity_test.go
+++ b/server/pkg/agent/antigravity_test.go
@@ -1442,6 +1442,40 @@ func TestAntigravityBackendSumsCompletedStepsWhenCancelled(t *testing.T) {
}
}
+// A cancelled run never reaches the terminal Result the daemon reads the
+// session from, so the conversation id must be announced as soon as agy names
+// it (#11316).
+func TestAntigravityBackendAnnouncesConversationBeforeCancel(t *testing.T) {
+ t.Parallel()
+
+ fakePath := filepath.Join(t.TempDir(), "agy")
+ writeTestExecutable(t, fakePath, []byte(fakeAgyCancelledStreamJSONScript()))
+ backend, err := New("antigravity", Config{ExecutablePath: fakePath, Logger: quietAntigravityLogger()})
+ if err != nil {
+ t.Fatalf("new antigravity backend: %v", err)
+ }
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+ session, err := backend.Execute(ctx, "prompt-ignored", ExecOptions{})
+ if err != nil {
+ t.Fatalf("execute: %v", err)
+ }
+ var announced []string
+ for msg := range session.Messages {
+ if msg.Type == MessageStatus && msg.SessionID != "" {
+ announced = append(announced, msg.SessionID)
+ }
+ if msg.Type == MessageText && msg.Content == "working" {
+ cancel()
+ }
+ }
+ <-session.Result
+ want := []string{"27a6d8f2-8523-46fc-8fc9-87e630cbe295"}
+ if !slices.Equal(announced, want) {
+ t.Fatalf("announced session ids = %q, want %q (once, before the cancel)", announced, want)
+ }
+}
+
func TestAntigravityCurrentTurnRecovery(t *testing.T) {
t.Parallel()
step := func(index int, kind, state, text string) string {