Skip to content

chore(config): consolidate LLM config truth + harden ENV error paths#164

Merged
KailasMahavarkar merged 1 commit intomainfrom
fix/config-truth-consolidation
Apr 20, 2026
Merged

chore(config): consolidate LLM config truth + harden ENV error paths#164
KailasMahavarkar merged 1 commit intomainfrom
fix/config-truth-consolidation

Conversation

@KailasMahavarkar
Copy link
Copy Markdown
Contributor

Follow-up to #163. Config-subsystem behaviour audit turned up four issues; fixed in one PR.

1. Truth fork (HIGH)

tools/finetune/training.py read its own tools/finetune/training_config.json with a bespoke loader that ignored the shared /.env and tools/autoresearch/config.json.

Replaced with a 10-line delegation to tools.autoresearch.providers.resolve_providers. Training now uses the same single source of truth as autoresearch and every bench.

  • Preferred training model hardcoded: _DEFAULT_TRAINING_MODEL = "deepseek/deepseek-v3.2:nitro" (overridable via OPENROUTER_TRAINING_MODEL env var).
  • Deleted tools/finetune/training_config.json.

2. Silent fallback on missing env_key (HIGH)

providers.resolve_providers used to fall back to api_key="ollama" when a provider's env_key field was missing - hid misconfiguration in bogus auth failures far from root cause.

Now: non-local providers without env_key raise ValueError at resolve time. Local providers (Ollama) still tolerate missing env_key.

3. ENV KeyError lost field list (MEDIUM)

ENV["typo"] previously raised bare KeyError('typo'). Restored: KeyError("ENV: unknown key 'typo'. Known: [...]").

4. Silent .env load (MEDIUM)

env.py now emits a DEBUG-level log line with count of vars loaded from /.env (or "no .env; shell env only" when absent).

Verified

  • ENV typed access + KeyError show field list
  • Missing env_key on non-local provider raises ValueError
  • resolve_providers returns 5 candidates for current /.env + config
  • 1802 tests pass, 101 skipped

🤖 Generated with Claude Code

Follow-up to #163. The behaviour audit of the config subsystem turned
up four issues; fixing them all here.

1. Truth fork (HIGH)
   tools/finetune/training.py was reading its own tools/finetune/
   training_config.json with a bespoke loader (`load_openrouter_config`)
   that ignored the shared /.env and tools/autoresearch/config.json.
   Replace with a 10-line delegation to `tools.autoresearch.providers.
   resolve_providers`. Training now uses the same single source of truth
   as autoresearch and every bench. The preferred training model is
   hardcoded as `_DEFAULT_TRAINING_MODEL = "deepseek/deepseek-v3.2:nitro"`
   (overridable via OPENROUTER_TRAINING_MODEL env var).

   Delete tools/finetune/training_config.json entirely.

2. Silent fallback on missing env_key (HIGH)
   providers.resolve_providers used to fall back to api_key="ollama" when
   a provider's env_key field was missing. That hid misconfiguration in
   bogus auth failures far from the root cause. Now: non-local providers
   without env_key raise ValueError at resolve time with a pointer at
   what to add. Local providers still tolerate missing env_key (Ollama
   accepts any non-empty key string).

3. ENV KeyError lost field list (MEDIUM)
   ENV["typo"] previously raised bare `KeyError('typo')`. Restore the
   earlier format: `KeyError("ENV: unknown key 'typo'. Known: [...]")`.

4. Silent .env load (MEDIUM)
   env.py now emits a DEBUG-level log line with the count of variables
   loaded from /.env (or "no .env; shell env only" when absent).

Verified end-to-end:
  - ENV typed access + KeyError show field list
  - Missing env_key on non-local provider raises ValueError
  - resolve_providers returns 5 candidates for current /.env + config
  - 1802 tests pass, 101 skipped

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@KailasMahavarkar KailasMahavarkar merged commit 6968f1f into main Apr 20, 2026
4 checks passed
@KailasMahavarkar KailasMahavarkar deleted the fix/config-truth-consolidation branch April 20, 2026 10:45
KailasMahavarkar added a commit that referenced this pull request Apr 20, 2026
After #163 (.env + typed env.py) and #164 (env_key pointer in
provider config), the autoresearch README still documented the old
"inline api_key in config.json" shape. Updated:

* Config example now shows env_key pointers (ollama_key, openrouter_key)
  instead of api_key strings
* Added a short preamble explaining that secrets live in /.env and
  config.json is shape-only
* Setup section now tells the user to copy both config.example.json
  AND .env.example, and edit /.env for real keys
* "Add a new model" section points at env.py + .env.example for
  provider-level onboarding

Other README.md files in the repo were scanned; only this one had
stale config refs. Nothing else needs updating.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
KailasMahavarkar added a commit that referenced this pull request Apr 20, 2026
After #163 (.env + typed env.py) and #164 (env_key pointer in
provider config), the autoresearch README still documented the old
"inline api_key in config.json" shape. Updated:

* Config example now shows env_key pointers (ollama_key, openrouter_key)
  instead of api_key strings
* Added a short preamble explaining that secrets live in /.env and
  config.json is shape-only
* Setup section now tells the user to copy both config.example.json
  AND .env.example, and edit /.env for real keys
* "Add a new model" section points at env.py + .env.example for
  provider-level onboarding

Other README.md files in the repo were scanned; only this one had
stale config refs. Nothing else needs updating.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
KailasMahavarkar added a commit that referenced this pull request Apr 20, 2026
After #163 (.env + typed env.py) and #164 (env_key pointer in
provider config), the autoresearch README still documented the old
"inline api_key in config.json" shape. Updated:

* Config example now shows env_key pointers (ollama_key, openrouter_key)
  instead of api_key strings
* Added a short preamble explaining that secrets live in /.env and
  config.json is shape-only
* Setup section now tells the user to copy both config.example.json
  AND .env.example, and edit /.env for real keys
* "Add a new model" section points at env.py + .env.example for
  provider-level onboarding

Other README.md files in the repo were scanned; only this one had
stale config refs. Nothing else needs updating.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant