From 33e3d92de0f2171d3eba3b902535bfd203cebc4f Mon Sep 17 00:00:00 2001 From: Jan Rose Date: Wed, 3 Jun 2026 16:30:47 +0200 Subject: [PATCH] acceptance: unset all SDK-known AI-agent env vars before tests The SDK derives its user-agent from agent-detection env vars and, since v0.132.0, treats even empty values as present, so clearing them via test.toml does not help. The previous list covered only a subset, leaving acceptance output dependent on which agent launched the test runner. Expand it to mirror useragent.listKnownAgents and split the generic AGENT/AI_AGENT fallback vars into their own list. Co-authored-by: Isaac --- acceptance/acceptance_test.go | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/acceptance/acceptance_test.go b/acceptance/acceptance_test.go index f6ec0805fb2..0cffc23fb1b 100644 --- a/acceptance/acceptance_test.go +++ b/acceptance/acceptance_test.go @@ -202,15 +202,34 @@ func testAccept(t *testing.T, inprocessMode bool, singleTest string) int { // pick up the host's agent. Setting these to "" via test.toml is not // enough: the SDK (since v0.132.0) treats empty values as a truthy // signal because os.LookupEnv reports them as present. - for _, v := range []string{ + // Keep this list in sync with the SDK's useragent.listKnownAgents. + knownAgents := []string{ + "AMP_CURRENT_THREAD_ID", "ANTIGRAVITY_AGENT", + "AUGMENT_AGENT", "CLAUDECODE", "CLINE_ACTIVE", "CODEX_CI", + "COPILOT_CLI", "CURSOR_AGENT", "GEMINI_CLI", + "GOOSE_TERMINAL", + "KIRO", + "OPENCLAW_SHELL", "OPENCODE", - } { + "VSCODE_AGENT", + "WINDSURF_AGENT", + } + + // AGENT and AI_AGENT are not in listKnownAgents; the SDK consults them as + // a generic fallback (useragent.agentEnvFallback) when none of the + // specific agents above is set. + genericAgents := []string{ + "AGENT", + "AI_AGENT", + } + + for _, v := range slices.Concat(knownAgents, genericAgents) { os.Unsetenv(v) //nolint:usetesting // t.Setenv cannot unset }