fix(claude-cli): preserve CLAUDE_CODE_OAUTH_TOKEN in env filter

filterCLIEnv was stripping all CLAUDE* env vars including the OAuth
token needed for CLI subprocess authentication.

Closes #541
This commit is contained in:
viettranx committed 2026-03-31 08:19:58 +07:00
1 parent dbc93aae8e
commit fe163eca30
1 file changed
+5 -3
+5 -3
View File
@@ -272,7 +272,8 @@ func ResetCLISession(baseWorkDir, sessionKey string) {
}
}
// filterCLIEnv removes CLAUDE* env vars to prevent nested session conflicts.
// filterCLIEnv removes CLAUDE* env vars to prevent nested session conflicts,
// but preserves CLAUDE_CODE_OAUTH_TOKEN for authentication.
func filterCLIEnv(environ []string) []string {
var filtered []string
for _, e := range environ {
@@ -280,8 +281,9 @@ func filterCLIEnv(environ []string) []string {
if before, _, ok := strings.Cut(e, "="); ok {
key = before
}
// Filter out variables that could cause nested CLI conflicts
if strings.HasPrefix(key, "CLAUDE") {
// Filter out variables that could cause nested CLI conflicts,
// but preserve auth token needed by the subprocess.
if strings.HasPrefix(key, "CLAUDE") && key != "CLAUDE_CODE_OAUTH_TOKEN" {
continue
}
filtered = append(filtered, e)