feat: configurable Pi provider priority for OpenAI web search - #276
Merged
nicobailon merged 2 commits intoAug 21, 2026
Merged
Conversation
|
| Filename | Overview |
|---|---|
| openai-search.ts | Adds unconditional provider-list validation and routes Pi credential resolution through the configured priority order; the previously reported context-gated validation issue is fixed. |
| test/search-providers.test.mjs | Covers provider priority, skipping an unregistered provider, and malformed configuration with and without an extension context. |
| README.md | Documents defaults, priority behavior, skipped providers, and empty-list API-key fallback. |
| CHANGELOG.md | Records the new configurable OpenAI search provider priority. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Load web-search configuration] --> B[Validate openaiSearchProviders]
B --> C{ExtensionContext available?}
C -->|Yes| D[Try configured Pi providers in order]
D --> E{Pi credentials resolved?}
E -->|Yes| F[Use selected Pi provider credentials]
E -->|No| G[Try configured or environment OpenAI API key]
C -->|No| G
G --> H{API key available?}
H -->|Yes| I[Use API-key credentials]
H -->|No| J[Report OpenAI search unavailable]
Reviews (3): Last reviewed commit: "fix: validate openaiSearchProviders on t..." | Re-trigger Greptile
Contributor
Author
|
Fair catch on the context-gated validation — malformed |
nicobailon
force-pushed
the
openai-search-provider-config
branch
from
August 21, 2026 01:44
898ad77 to
f9089a3
Compare
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.
openai-search.tshardcodes which Pi providers it resolves auth from:Since
openai-codexis tried first and wins whenever it's signed in, there's no way to route search spend anywhere else — e.g. to a meteredopenaiAPI key instead of the Codex subscription's weekly limit, or to a second Codex account slot registered viapi.registerProvider()(my case: I keep a separate account for background/automation traffic and wantedweb_searchbilled there rather than against my main subscription).Everything downstream of the list already generalizes: auth resolves through
getApiKeyAndHeaders, the endpoint is chosen by inspecting the token (isCodexJwt), andchatgpt-account-idis extracted from the JWT itself. The provider list is the only hardcoded piece, so this PR just makes it configurable:{ "openaiSearchProviders": ["openai-codex-work", "openai-codex"] }Purely additive:
["openai-codex", "openai"])[]skips Pi credentials entirely, so theopenaiApiKey/OPENAI_API_KEYfallback applies (useful for "signed into Codex, but bill searches to my API key")Added two tests in
test/search-providers.test.mjscovering priority order (including skipping an unregistered entry) and config validation.npx tscandnode --testpass, plus a README note and a changelog line.