You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Tests in some packages write to the developer's real home directory #5013
area/ragFor work/issues that have to do with the RAG featuresarea/runtimeRuntime engine, agent loop execution, tool dispatch, loop detectionarea/skillsSkills system and custom slash commandsarea/telemetryTelemetry, tracing, and metricsarea/testingTest infrastructure, CI/CD, test runners, evaluation
A few test packages write into the real home directory of whoever runs go test ./..., because they have no TestMain using testutil.RunWithTempHome (or equivalent). This predates #4999 and happens on main; that PR only changes where the files land.
What gets written
Found by running each package with HOME pointed at an empty directory and listing what appeared:
Package
File left behind
pkg/skills
<cache-dir>/skills/<hash>/remote-skill/SKILL.md and SKILL.md.meta
A full go test ./... run leaves exactly these four kinds of file. The user-uuid row may be incomplete: I only checked the packages above individually, and other packages that initialise telemetry could write it too.
Why it matters
Tests read and write developer state, so results can depend on what is already in the home directory.
user-uuid is the telemetry identity; a test run can create it on a machine where the developer never ran Docker Agent.
pkg/runtime leaves a 7 MB catalog in the developer's cache.
Suggested fix
Add a TestMain calling testutil.RunWithTempHome(m.Run) to each package above, as the other state-touching packages already do. Then a CI check that fails when a go test ./... run leaves anything under a throwaway HOME would keep it from regressing.
Thanks for writing this up. I ran it on current main (af7c8a66a, macOS) with HOME pointed at an empty directory, each test package on its own, and all seven packages in your table reproduce exactly as described.
A few things to add.
The list is longer. pkg/fake, pkg/evaluator/provider and pkg/model/provider/dmr also write user-uuid, and pkg/remote leaves an empty <data-dir>/store directory. #5018 already found those four. The one I think everybody has missed is e2e: go test ./e2e -run TestDebug_Toolsets_None on its own leaves <config-dir>/.cagent_first_run and the 7 MB models_dev.json. It doesn't show up in a full run. From reading the code I think that's because chatserver_test.go passes --cache-dir/--config-dir/--data-dir first, and those overrides are process-global and never reset, so later tests inherit them. I'd expect -shuffle=on to expose it. pkg/model/provider/gemini probably writes user-uuid too, same gateway path, but those tests skip without the opt-in env var so I couldn't confirm.
Two details on what gets written. The skills cache and the RAG db are keyed by a hash of a random port or temp dir, so every run adds two new directories of each instead of overwriting. On a real home that just keeps growing. And models_dev.json is there because the six teamloader.Load calls in the pkg/runtime tests don't set ModelsDevStoreOverride, so unit tests do a live GET to models.dev. That network dependency bothers me more than the 7 MB.
On the fix. Wrapping in RunWithTempHome is right for user-uuid, the RAG db and the store dir. For the cache dir I think it's only complete on macOS and plain Linux: the helper sets HOME (plus USERPROFILE on Windows), but the cache dir comes from os.UserCacheDir(), which uses XDG_CACHE_HOME on Linux and %LocalAppData% on Windows. So the skills cache and models_dev.json would still escape there, including in test-windows. I haven't run that, it's from reading pkg/paths and pkg/testutil/home.go. #4999's version of the helper covers it, so the order those two land in matters.
For pkg/runtime I'd rather inject a store at those six call sites than wrap the package. With an always-empty temp home, wrapping turns "cached for a day" into "download 7 MB on every run".
Worth knowing: leaving user-uuid alone was a deliberate call in #4893 ("It is not a setting, so they are left alone"). I agree with you that it should be isolated, a test run shouldn't mint a telemetry ID on someone's machine, but a maintainer may want to weigh in. Instead of wrapping N packages, userid's default resolver could skip persisting under testing.Testing(), the way pkg/chatgpt and the keyring token store already do. That would also cover gemini, e2e and whatever comes next.
The CI check is a good idea but it can't literally be "nothing left under HOME". Go's build cache, module cache and its own telemetry land there, and pkg/tools/builtin/lsp spawns gopls, which writes its cache and telemetry too when it's installed. It would need GOCACHE/GOMODCACHE/GOPATH pinned and should only look at the three cagent directories. It could be a step in the existing test-linux job, so gate.needs doesn't change. It still wouldn't catch the e2e case in default order.
Small one: I didn't find a test whose pass/fail depends on what's in the home dir, so "results can depend on" reads a bit strong. What does change is behaviour: an existing models_dev.json suppresses the fetch, and an invalid user-uuid gets overwritten. Shout if you've seen an actual flake from it.
area/ragFor work/issues that have to do with the RAG featuresarea/runtimeRuntime engine, agent loop execution, tool dispatch, loop detectionarea/skillsSkills system and custom slash commandsarea/telemetryTelemetry, tracing, and metricsarea/testingTest infrastructure, CI/CD, test runners, evaluation
Activity
test: isolate test suites from the developer's home directory
lmilbaum commentedon Nov 24, 2026
Thanks for writing this up. I ran it on current main (
af7c8a66a, macOS) withHOMEpointed at an empty directory, each test package on its own, and all seven packages in your table reproduce exactly as described.A few things to add.
The list is longer.
pkg/fake,pkg/evaluator/providerandpkg/model/provider/dmralso writeuser-uuid, andpkg/remoteleaves an empty<data-dir>/storedirectory. #5018 already found those four. The one I think everybody has missed ise2e:go test ./e2e -run TestDebug_Toolsets_Noneon its own leaves<config-dir>/.cagent_first_runand the 7 MBmodels_dev.json. It doesn't show up in a full run. From reading the code I think that's becausechatserver_test.gopasses--cache-dir/--config-dir/--data-dirfirst, and those overrides are process-global and never reset, so later tests inherit them. I'd expect-shuffle=onto expose it.pkg/model/provider/geminiprobably writesuser-uuidtoo, same gateway path, but those tests skip without the opt-in env var so I couldn't confirm.Two details on what gets written. The skills cache and the RAG db are keyed by a hash of a random port or temp dir, so every run adds two new directories of each instead of overwriting. On a real home that just keeps growing. And
models_dev.jsonis there because the sixteamloader.Loadcalls in thepkg/runtimetests don't setModelsDevStoreOverride, so unit tests do a live GET to models.dev. That network dependency bothers me more than the 7 MB.On the fix. Wrapping in
RunWithTempHomeis right foruser-uuid, the RAG db and the store dir. For the cache dir I think it's only complete on macOS and plain Linux: the helper setsHOME(plusUSERPROFILEon Windows), but the cache dir comes fromos.UserCacheDir(), which usesXDG_CACHE_HOMEon Linux and%LocalAppData%on Windows. So the skills cache andmodels_dev.jsonwould still escape there, including intest-windows. I haven't run that, it's from readingpkg/pathsandpkg/testutil/home.go. #4999's version of the helper covers it, so the order those two land in matters.For
pkg/runtimeI'd rather inject a store at those six call sites than wrap the package. With an always-empty temp home, wrapping turns "cached for a day" into "download 7 MB on every run".Worth knowing: leaving
user-uuidalone was a deliberate call in #4893 ("It is not a setting, so they are left alone"). I agree with you that it should be isolated, a test run shouldn't mint a telemetry ID on someone's machine, but a maintainer may want to weigh in. Instead of wrapping N packages,userid's default resolver could skip persisting undertesting.Testing(), the waypkg/chatgptand the keyring token store already do. That would also cover gemini, e2e and whatever comes next.The CI check is a good idea but it can't literally be "nothing left under HOME". Go's build cache, module cache and its own telemetry land there, and
pkg/tools/builtin/lspspawns gopls, which writes its cache and telemetry too when it's installed. It would needGOCACHE/GOMODCACHE/GOPATHpinned and should only look at the three cagent directories. It could be a step in the existingtest-linuxjob, sogate.needsdoesn't change. It still wouldn't catch the e2e case in default order.Small one: I didn't find a test whose pass/fail depends on what's in the home dir, so "results can depend on" reads a bit strong. What does change is behaviour: an existing
models_dev.jsonsuppresses the fetch, and an invaliduser-uuidgets overwritten. Shout if you've seen an actual flake from it.