Area
Proxy and routing
What are you trying to accomplish?
I run opencodex as a Windows background service and switch VPN/proxy tools frequently. Today every proxy change (new port, proxy restart, rule change) silently breaks all upstream requests with 502 Provider unreachable until I manually edit ~/.opencodex/config.json and restart the service. I need opencodex to follow the Windows system proxy automatically — including falling back to direct when the proxy is down — so outbound routing keeps working with zero manual maintenance.
What prevents this today?
config.proxy accepts only a static URL (or ${ENV_VAR} reference) that is mirrored into HTTP_PROXY/HTTPS_PROXY once at process start (applyProxyEnv). There is no way to express "use whatever the system proxy is right now":
- a hardcoded URL goes stale the moment the proxy tool changes ports or restarts;
- service-managed instances (Task Scheduler / launchd / systemd) never inherit shell-level
HTTP_PROXY exports;
- on my network OpenAI endpoints (
chatgpt.com) are only reachable through the proxy, while opencode.ai is only reliably reachable via a different route — so "always proxy" and "never proxy" are both wrong as static choices;
- the only current workaround is an external watchdog script that rewrites config and restarts the service, which races with the running proxy's in-memory config and only works for interactive installs.
What should OpenCodex do?
When config.proxy is the special value "auto", opencodex should:
- Read the Windows system proxy (
HKCU\...\Internet Settings ProxyEnable/ProxyServer) at startup and apply it immediately, so the first outbound request already works;
- verify the candidate proxy against upstream targets (e.g.
chatgpt.com, opencode.ai) — any HTTP status < 500 counts as reachable;
- fall back to direct connection when the proxy is unreachable, and keep the last known proxy when both routes fail, with a clear log line in each case;
- re-check every ~60 seconds and apply changes live, without a restart (Bun re-reads
HTTP_PROXY/HTTPS_PROXY per request).
Existing behavior must stay backward compatible: static proxy URLs and ${ENV_VAR} references keep working, user-set HTTP_PROXY/HTTPS_PROXY env vars still win, and NO_PROXY loopback defaults remain appended. On non-Windows platforms auto mode should degrade to direct.
Example usage or interface
{
"proxy": "auto"
}
Before/after: with "proxy": "http://127.0.0.1:7890" and the proxy tool switched to port 7893, every request fails with 502 Provider unreachable. With "proxy": "auto", the service picks up 7893 from the registry within 60 seconds (or falls back to direct) and requests succeed again — no config edits, no restarts.
### Alternatives or workarounds
_No response_
### Additional context
_No response_
### Checks
- [x] I searched existing issues and documentation.
- [x] This request describes a concrete OpenCodex workflow rather than merely naming a desired technology.
- [x] I removed secrets and personal data.
Area
Proxy and routing
What are you trying to accomplish?
I run opencodex as a Windows background service and switch VPN/proxy tools frequently. Today every proxy change (new port, proxy restart, rule change) silently breaks all upstream requests with
502 Provider unreachableuntil I manually edit~/.opencodex/config.jsonand restart the service. I need opencodex to follow the Windows system proxy automatically — including falling back to direct when the proxy is down — so outbound routing keeps working with zero manual maintenance.What prevents this today?
config.proxyaccepts only a static URL (or${ENV_VAR}reference) that is mirrored intoHTTP_PROXY/HTTPS_PROXYonce at process start (applyProxyEnv). There is no way to express "use whatever the system proxy is right now":HTTP_PROXYexports;chatgpt.com) are only reachable through the proxy, whileopencode.aiis only reliably reachable via a different route — so "always proxy" and "never proxy" are both wrong as static choices;What should OpenCodex do?
When
config.proxyis the special value"auto", opencodex should:HKCU\...\Internet SettingsProxyEnable/ProxyServer) at startup and apply it immediately, so the first outbound request already works;chatgpt.com,opencode.ai) — any HTTP status < 500 counts as reachable;HTTP_PROXY/HTTPS_PROXYper request).Existing behavior must stay backward compatible: static proxy URLs and
${ENV_VAR}references keep working, user-setHTTP_PROXY/HTTPS_PROXYenv vars still win, andNO_PROXYloopback defaults remain appended. On non-Windows platforms auto mode should degrade to direct.Example usage or interface
{ "proxy": "auto" } Before/after: with "proxy": "http://127.0.0.1:7890" and the proxy tool switched to port 7893, every request fails with 502 Provider unreachable. With "proxy": "auto", the service picks up 7893 from the registry within 60 seconds (or falls back to direct) and requests succeed again — no config edits, no restarts. ### Alternatives or workarounds _No response_ ### Additional context _No response_ ### Checks - [x] I searched existing issues and documentation. - [x] This request describes a concrete OpenCodex workflow rather than merely naming a desired technology. - [x] I removed secrets and personal data.