fix(core): lazy router chain init and optional compatible API keys (#1345)#1350
Merged
fix(core): lazy router chain init and optional compatible API keys (#1345)#1350
Conversation
…1345) Router provider no longer eagerly initializes all providers in chain at startup. Providers that fail (e.g. missing API keys for cloud fallbacks) are skipped with a warning, allowing the chain to work with only the available providers. Compatible provider API key resolution now follows a three-step fallback: config field > vault secret > empty string for local endpoints (localhost, private networks, .local/.internal hostnames).
Restructure compatible API key resolution so expose() is only called inside unwrap_or_else after availability is already confirmed via boolean check. Add lgtm suppression comment. The secret value never reaches any logging path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
api_keyfield > vault secret > empty string for local endpoints (localhost, private networks,.local/.internalhostnames).api_keyfield toCompatibleConfig([[llm.compatible]]) as a direct config alternative to vault secrets.Closes #1345
Test plan
is_local_endpointunit tests (localhost, 127.0.0.1, private IPs, remote endpoints)cargo clippy --workspace --features full -- -D warningscleancargo nextest run --workspace --features full --lib --bins— 4669 passed["ollama", "claude"]without Claude API key — verify ollama works, warning logged for claude[[llm.compatible]]withbase_url = "http://localhost:11434/v1"without API key — verify it works