fix: pass agent context config explicitly instead of reading env (#24759)

The CODER_AGENT_EXP_* env vars are agent-internal options. When set
in the workspace environment they leak to MCP subprocesses and user
shells.

ReadEnvConfig() captures the values and ClearEnvVars() strips them
before the reinit loop, so config survives agent restarts. NewAPI
and ReadEnvConfig both use applyDefaults() to fill zero fields.
The chatd test passes config via agenttest.WithContextConfigFromEnv().
This commit is contained in:
Mathias Fredriksson
2026-04-28 17:58:28 +03:00
committed by GitHub
parent 1666bff1f9
commit 3c450899ea
7 changed files with 165 additions and 57 deletions
+1 -1
View File
@@ -8324,7 +8324,7 @@ func TestAgentContextFilesAndSkillsLoadedIntoChat(t *testing.T) {
workspace := coderdtest.CreateWorkspace(t, client, template.ID)
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
_ = agenttest.New(t, client.URL, agentToken)
_ = agenttest.New(t, client.URL, agentToken, agenttest.WithContextConfigFromEnv())
coderdtest.NewWorkspaceAgentWaiter(t, client, workspace.ID).Wait()
// Capture LLM requests so we can inspect the system prompt.