…viders
--record and --fake always pointed the runtime's models gateway at their
local capture proxy so every provider call could be intercepted. The proxy
binds to localhost, which environment.IsTrustedDockerURL treats as a
trusted Docker AI Gateway address, so provider clients refused to build
without a real Docker Desktop token even when the configured provider
(e.g. OpenRouter) has nothing to do with the Docker AI Gateway.
Supply a placeholder Docker token via the runtime config's environment
provider chain only when the gateway actually configured before the proxy
took over isn't itself a trusted Docker gateway. The proxy already
discards this placeholder and re-authenticates with the provider's own
credentials (or, for a genuine upstream Docker gateway, the real token
keeps flowing through unaffected).
Fixes #4250
Fixes #4250.
--record/--fake always point runConfig.ModelsGateway at their local capture proxy (localhost) so every provider call can be intercepted. environment.IsTrustedDockerURL treats any localhost address as a trusted Docker AI Gateway — a heuristic meant for genuine local Docker gateways — so provider clients refused to build without a real Docker Desktop token, even for providers (e.g. OpenRouter) that have nothing to do with the Docker AI Gateway.
Fix: a new Config.EnvOverrides map[string]string, layered in front of the computed environment provider chain (RuntimeConfig.EnvProvider()), lets --record/--fake supply a placeholder Docker token — but only when the gateway actually configured before the proxy took over isn't itself a trusted Docker gateway. The recording proxy already discards this placeholder and re-authenticates with the provider's own credentials (pkg/fake/proxy.go); a genuine upstream Docker gateway keeps using the real token, unaffected.
Verified end-to-end with the exact repro from the issue (OpenRouter provider, no Docker Desktop, --record --exec): the run now gets past client construction and correctly forwards to https://openrouter.ai/..., recording the interaction to the cassette.
Testing: task build, task test, task lint all pass (pre-existing unrelated pkg/rag/treesitter CGO failure aside). Added unit tests in cmd/root/record_test.go and pkg/config/runtime_test.go covering: no gateway configured, non-Docker upstream gateway, genuine trusted Docker upstream gateway (real token preserved), --fake proxy, and EnvOverrides/Clone() semantics.
Reviewed by an independent pass (approved); two low-severity, non-blocking observations were raised (EnvOverrides is visible to the whole env-provider chain, not just gateway-auth checks; and encrypted-config forwarding is reachable more often now, an unrelated pre-existing behavior) — noted here for visibility, not addressed as out of scope for this fix.