Skip to content

Commit 094b927

Browse files
pieternTanishqDatabricks
authored andcommitted
acc: unset AI-agent env vars instead of setting them empty (databricks#5240)
Move the agent env var scrub from `acceptance/test.toml` into `acceptance_test.go` and use `os.Unsetenv` so the keys are truly absent in child processes. The old `Env.X = ""` approach left them present with an empty value; since SDK v0.132 the user-agent detector treats that as a match and stamps `agent/multiple` onto recorded requests. This pull request and its description were written by Isaac.
1 parent d584f11 commit 094b927

2 files changed

Lines changed: 16 additions & 9 deletions

File tree

acceptance/acceptance_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,22 @@ func testAccept(t *testing.T, inprocessMode bool, singleTest string) int {
198198
// Consistent behavior of locale-dependent tools, such as 'sort'
199199
t.Setenv("LC_ALL", "C")
200200

201+
// Unset AI-agent detection env vars so the SDK's user-agent does not
202+
// pick up the host's agent. Setting these to "" via test.toml is not
203+
// enough: the SDK (since v0.132.0) treats empty values as a truthy
204+
// signal because os.LookupEnv reports them as present.
205+
for _, v := range []string{
206+
"ANTIGRAVITY_AGENT",
207+
"CLAUDECODE",
208+
"CLINE_ACTIVE",
209+
"CODEX_CI",
210+
"CURSOR_AGENT",
211+
"GEMINI_CLI",
212+
"OPENCODE",
213+
} {
214+
os.Unsetenv(v) //nolint:usetesting // t.Setenv cannot unset
215+
}
216+
201217
buildDir := getBuildDir(t, cwd, runtime.GOOS, runtime.GOARCH)
202218

203219
// Set up terraform for tests. Skip on DBR - tests with RunsOnDbr only use direct deployment.

acceptance/test.toml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,6 @@ Env.PYTHONDONTWRITEBYTECODE = "1"
1717
Env.PYTHONUNBUFFERED = "1"
1818
Env.PYTHONUTF8 = "1"
1919

20-
# Clear agent env vars to prevent them from affecting test output
21-
Env.ANTIGRAVITY_AGENT = ""
22-
Env.CLAUDECODE = ""
23-
Env.CLINE_ACTIVE = ""
24-
Env.CODEX_CI = ""
25-
Env.CURSOR_AGENT = ""
26-
Env.GEMINI_CLI = ""
27-
Env.OPENCODE = ""
28-
2920
EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["terraform", "direct"]
3021
EnvMatrixExclude.noplantf = ["DATABRICKS_BUNDLE_ENGINE=terraform", "READPLAN=1"]
3122
EnvRepl.DATABRICKS_BUNDLE_ENGINE = false

0 commit comments

Comments
 (0)