{"record":{"id":"d00a6baf911f122a","repo":"chenhg5/cc-connect","slug":"s-d00a6b","errorCode":null,"errorMessage":"%s","messagePattern":"%s","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/antigravity/session.go","lineNumber":268,"sourceCode":"\t\t\t}\n\t\t\tif sid != \"\" {\n\t\t\t\tas.chatID.Store(sid)\n\t\t\t\tslog.Debug(\"antigravitySession: detected session ID\", \"session_id\", sid)\n\t\t\t\t// Emit an EventText carrying the session ID back to core.\n\t\t\t\tselect {\n\t\t\t\tcase as.events <- core.Event{Type: core.EventText, SessionID: sid}:\n\t\t\t\tcase <-as.ctx.Done():\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tsid := as.CurrentSessionID()\n\t\tif err != nil {\n\t\t\tstderrMsg := strings.TrimSpace(stderrBuf.String())\n\t\t\tif stderrMsg != \"\" {\n\t\t\t\tslog.Error(\"antigravitySession: process failed\", \"error\", err, \"stderr\", stderrMsg)\n\t\t\t\tselect {\n\t\t\t\tcase as.events <- core.Event{Type: core.EventError, Error: fmt.Errorf(\"%s\", stderrMsg)}:\n\t\t\t\tcase <-as.ctx.Done():\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Finalize turn.\n\t\tselect {\n\t\tcase as.events <- core.Event{Type: core.EventResult, SessionID: sid, Done: true}:\n\t\tcase <-as.ctx.Done():\n\t\t}\n\t}()\n\n\tgo func() {\n\t\t<-ctx.Done()\n\t\t_ = stdout.Close()\n\t}()\n\n\treader := bufio.NewReader(stdout)","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/antigravity/session.go#L250-L286","documentation":"When the antigravity (agy) CLI process exits non-zero, the session's readLoop emits a core.EventError whose message is the process's captured stderr output. cc-connect throws this so the messaging-platform user sees why the agent turn failed. The message text is whatever agy wrote to stderr, not a fixed string.","triggerScenarios":"Running a turn via the antigravity session when the agy process terminates with a non-nil error from cmd.Wait() and stderrBuf contains non-empty output; e.g. bad CLI flags, missing/broken agy install, auth failure, or invalid prompt context.","commonSituations":"agy not installed or not on PATH; antigravity account not authenticated; unsupported --sandbox / --dangerously-skip-permissions flag after an agy version change; project state agy refuses to load.","solutions":["Run the exact agy command by hand in the session workDir and read the same stderr message to see the root cause","Verify agy is installed and current: `agy --version`, upgrade if outdated","Re-authenticate antigravity CLI if the stderr mentions credentials/auth","Check the configured mode in config.toml (yolo/plan/default) still maps to valid agy flags for your agy version","Retry the turn once to rule out a transient process failure"],"exampleFix":"// before (diagnosing)\n// engine logs: \"antigravitySession: process failed\" error=\"exit status 1\" stderr=\"unknown flag: --sandbox\"\n// after\n// remove or correct the mode in config.toml so buildSendArgs() emits only flags your agy supports","handlingStrategy":"try-catch","validationCode":"if _, err := exec.LookPath(\"agy\"); err != nil { log.Fatal(\"agy not installed/on PATH\") }\nout, err := exec.Command(\"agy\", \"--version\").CombinedOutput()\nif err != nil { log.Fatalf(\"agy broken: %v: %s\", err, out) }","typeGuard":"// Go: inspect the event before surfacing\nif evt.Type == core.EventError && evt.Error != nil {\n    var stderrMsg string\n    if errors.As(evt.Error, &stderrMsg) { /* stderr-originated */ }\n}","tryCatchPattern":"for evt := range session.Events() {\n    if evt.Type == core.EventError && evt.Error != nil {\n        slog.Warn(\"agy turn failed\", \"err\", evt.Error) // show stderr text to user\n        continue\n    }\n}","preventionTips":["Keep the agy CLI installed, on PATH, and updated","Re-authenticate antigravity when credentials expire","Test the exact agy command manually after changing mode config","Pin agy version compatible with the flags cc-connect emits"],"tags":["process","stderr","cli","agent"],"backgroundTag":"command-not-found","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}