Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

Fix copilotStatus to merge profile and process env instead of either/or

Cursor Agent4d565d4dfdd0
diff --git a/cli/beacon/internal/endpoint/harness/copilot.go b/cli/beacon/internal/endpoint/harness/copilot.go
index 1340f9b1..6ed917a6 100644
--- a/cli/beacon/internal/endpoint/harness/copilot.go
+++ b/cli/beacon/internal/endpoint/harness/copilot.go
@@ -50,9 +50,16 @@ func copilotStatus(path string, expectedEndpoint ...string) (TelemetryStatus, st
}
return TelemetryMissing, err.Error()
}
- env := copilotEnvFromProcess()
- if !env.configured() {
- env = copilotEnvFromProfile(string(data))
+ env := copilotEnvFromProfile(string(data))
+ procEnv := copilotEnvFromProcess()
+ if procEnv.enabled != "" {
+ env.enabled = procEnv.enabled
+ }
+ if procEnv.endpoint != "" {
+ env.endpoint = procEnv.endpoint
+ }
+ if procEnv.fileExporter != "" {
+ env.fileExporter = procEnv.fileExporter
}
return copilotStatusFromEnv(env, firstNonEmptyString(expectedEndpoint...))
}
diff --git a/cli/beacon/internal/endpoint/harness/harness_test.go b/cli/beacon/internal/endpoint/harness/harness_test.go
index afc75204..0ad8f293 100644
--- a/cli/beacon/internal/endpoint/harness/harness_test.go
+++ b/cli/beacon/internal/endpoint/harness/harness_test.go
@@ -660,6 +660,21 @@ func TestCopilotStatusValidatesExpectedHTTPPort(t *testing.T) {
}
}
+func TestCopilotStatusMergesProfileWithGenericProcessEndpoint(t *testing.T) {
+ clearCopilotEnv(t)
+ t.Setenv("OTEL_EXPORTER_OTLP_ENDPOINT", "http://127.0.0.1:4318")
+
+ path := filepath.Join(t.TempDir(), "profile")
+ if err := os.WriteFile(path, []byte("export COPILOT_OTEL_ENABLED=true\n"), 0600); err != nil {
+ t.Fatalf("write fixture: %v", err)
+ }
+
+ status, msg := copilotStatus(path)
+ if status != TelemetryEnabled {
+ t.Fatalf("copilotStatus = %q (%s), want %q; generic OTEL_EXPORTER_OTLP_ENDPOINT should not suppress profile COPILOT_OTEL_ENABLED", status, msg, TelemetryEnabled)
+ }
+}
+
func clearCopilotEnv(t *testing.T) {
t.Helper()
for _, key := range []string{