Files
CLIProxyAPI/sdk/cliproxy/executor/request_proxy.go
Luis Pater d582067c06 feat(executor): support execution-scoped request proxy overrides
- Add context helpers to manage execution-scoped proxy overrides
- Prioritize request proxy over credential and global proxy settings across HTTP and uTLS clients
- Propagate request proxy in conductor execution and plugin host adapters
- Isolate Codex WebSocket connection reuse by proxy endpoint

Closes: #6013
2026-09-22 03:54:34 +08:00

37 lines
1.0 KiB
Go

package executor
import (
"context"
"strings"
)
type requestProxyContextKey struct{}
// WithRequestProxyURL replaces the execution-scoped proxy override.
// An empty proxy clears any override inherited from the parent context.
func WithRequestProxyURL(ctx context.Context, proxyURL string) context.Context {
proxyURL = strings.TrimSpace(proxyURL)
if ctx == nil {
ctx = context.Background()
}
return context.WithValue(ctx, requestProxyContextKey{}, proxyURL)
}
// WithoutRequestProxyURL removes an execution-scoped proxy override.
// Credential refresh uses this so token exchange keeps the account or global proxy.
func WithoutRequestProxyURL(ctx context.Context) context.Context {
if ctx == nil {
return context.Background()
}
return context.WithValue(ctx, requestProxyContextKey{}, "")
}
// RequestProxyURL returns the execution-scoped proxy override, or empty when unset.
func RequestProxyURL(ctx context.Context) string {
if ctx == nil {
return ""
}
proxyURL, _ := ctx.Value(requestProxyContextKey{}).(string)
return strings.TrimSpace(proxyURL)
}