Skip to content

fix(provider): accept OPENAI_* env fallback alongside CORAGENT_* - #36

Merged
ajianaz merged 1 commit into
developfrom
fix/env-prefix-fallback
Aug 27, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/env-prefix-fallback

Conversation

@ajianaz

@ajianaz ajianaz commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

What

OpenAiConfig::from_env now resolves provider config from complete prefix triples: CORAGENT_* first, then OPENAI_*. The first prefix whose full triple (_BASE_URL, _MODEL, _API_KEY) is present and non-empty wins. Prefixes are never mixed — a half-configured environment cannot silently blend two sources. Whitespace-only values count as absent.

Also: error message now names both accepted prefixes, and CLI docs updated.

Housekeeping in the same PR: the E8 run session log is preserved at docs/e8-session-log.jsonl (the E8 'documented run' artifact, verified secret-free — the only 'sk-' hit was the word 'risk-tiered'), and .tole/ is now gitignored so future runs never leak session files into commits.

Why

The first E8 MVP gate run attempt failed with missing CORAGENT_BASE_URL / CORAGENT_MODEL / CORAGENT_API_KEY on a machine that had a perfectly good OPENAI_* environment — the operator had to hand-map env vars to make the run work (logged in the E8 retro). The standard OpenAI-compatible env names should just work.

Testing

  • New unit test env_prefix_resolution_prefers_coragent_and_never_mixes covers 4 cases: OPENAI-only fallback, CORAGENT priority when both complete, incomplete-CORAGENT + complete-OPENAI (no blending), whitespace-only treated as absent. Env snapshot/restore included; mutex-guarded.
  • 112/112 tests pass, clippy clean.
  • Live validation: rebuilt release binary, exported only OPENAI_* from the real provider env (CORAGENT_* explicitly unset), ran tole run --yes — completed a full read_file turn against the real provider. The exact scenario that failed before this fix now works.

from_env now tries CORAGENT_* then OPENAI_* as complete triples; the
first prefix whose full triple (BASE_URL/MODEL/API_KEY) is present
wins. Prefixes are never mixed — a half-configured environment cannot
silently blend two sources. Whitespace-only values count as absent.

This removes the manual env mapping step that broke the first E8 run
attempt (binary rejected an OPENAI_*-only environment).

Validated live: OPENAI_*-only env, tole run completed a read_file turn
against the real provider. 112/112 tests, clippy clean.

Housekeeping: preserve the E8 run log as docs/e8-session-log.jsonl
(E8 'documented run' artifact, verified secret-free) and gitignore
.tole/ so future runs never leak session files into commits.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit e9286e7 into develop Aug 27, 2026
11 checks passed
@ajianaz
ajianaz deleted the fix/env-prefix-fallback branch August 27, 2026 05:33
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