go-env-config-override-llm-client
Done. There was no repository in the environment (only /workspace/problem.json), so I reconstructed the fix as a compilable, self-contained Go module and verified it.
Artifacts
- /workspace/solution.md — full write-up: root cause, exact fix, wiring, verification.
- /workspace/solution/config/config.go — the ordered resolver.
- /workspace/solution/config/config_test.go — 6 regression tests.
- /workspace/solution/go.mod
Core diagnosis
1. Env overrides had no single ordered resolution point, so env-only setups left the model empty and llm.DefaultConfig later leaked gpt-4o into the DeepSeek client → HTTP 400 → breaker → paused sessions.
2. The DeepSeek default must be gated on DefaultModel == "" (empty string), never a "gpt-4o" sentinel — that value isn't present in the resolver path since it lives only in llm.DefaultConfig.
Fix
- applyEnvOverrides: reads CONSENSUS_LLM_MODEL / CONSENSUS_LLM_PROVIDER, env > config file, runs first.
- applyDeepSeekKeyDefaults: only when DEEPSEEK_API_KEY is set, parses the effective base URL with net/url (scheme-tolerant, port-stripped) and strings.EqualFold(u.Hostname(), "api.deepseek.com"); then, and only if DefaultModel is empty, sets deepseek-v4-flash.
Verification
go vet ./... # clean
go test ./... -v # 6/6 PASS, ok dfconsensus14/config 0.002s
Covered: env model precedence, env provider precedence, env-only DeepSeek default, non-DeepSeek negative, explicit-env model survival, explicit-config model survival.
# Evidence - Problem class: go-env-config-override-llm-client - Model: openrouter/deepseek/deepseek-v4.1-flash - Solved: 2026-09-25T03:22:07.185Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "DF-CONSENSUS-14 (consensus, Go): env-only LLM setup sent model=gpt-4o to DeepSeek -> HTTP 400 x3 -> circuit breaker -> paused sessions. Working approach: put env overrides in the single applyEnvOverrides resolution point (CONSENSUS_LLM_MODEL/CONSENSUS_LLM_PROVIDER, env > config file); in the DEEPSEEK_API_KEY branch parse the EFFECTIVE base URL (net/url, EqualFold hostname api.deepseek.com) and only when no explicit model is set default the model to a provider-valid id (deepseek-v4-flash). Key subtlety: the compiled default config leaves DefaultModel empty (the gpt-4o default lives in llm.DefaultConfig, a different path), so gate the provider default on empty-string, never on a sentinel model name. 6 regression tests: 2 precedence, default, non-DeepSeek negative, explicit-env + explicit-config survival.", "environment": "", "language": "", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "go-env-config-override-llm-client", "provider": "openrouter", "solved_at": "2026-09-25T03:22:07.186Z", "version": ""}