Skip to content

Pick the Ask AI provider per deployment, not per request - #4807

Merged
reakaleek merged 3 commits into
mainfrom
remove-x-ai-provider-head-619aa254
Nov 10, 2026
Merged

reakaleek merged 3 commits into
mainfrom
remove-x-ai-provider-head-619aa254

Conversation

@reakaleek

@reakaleek reakaleek commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

The Ask AI provider is now a deployment setting. The API ignores the X-AI-Provider request header and reads DOCUMENTATION_ASK_AI_PROVIDER instead. Docs sites stay on LlmGateway with no config change.

Affects: Docs API, Site UI

Prompt summary: Remove the X-AI-Provider header so docs users can only use LlmGateway. Keep it backwards compatible, so a client that still sends the header gets no change in behaviour. Codex stays on AgentBuilder.

Why

The client picks the provider today. Each request routes to whichever provider its X-AI-Provider header names, so the provider a site uses is not under the deployment's control. Codex needs AgentBuilder and the docs sites need LlmGateway. That choice belongs in each deployment's configuration.

What

Provider comes from configuration

AskAiProviderOptions reads DOCUMENTATION_ASK_AI_PROVIDER once. When the value is unset or empty it means LlmGateway, and AgentBuilder (case-insensitive) selects Agent Builder. Any other value throws when the service is resolved, the same way the Kibana and LLM Gateway options fail on bad config. The "Ask AI provider" section in docs/data/api.md documents the setting.

Header resolver and factories removed

AskAiProviderResolver, AskAiGatewayFactory and StreamTransformerFactory are gone, along with the IHttpContextAccessor registration they needed. ServicesExtension maps IAskAiService and IStreamTransformer to the configured provider directly.

Frontend sends no provider

The chat store no longer keeps, persists or sends aiProvider. Both stream clients drop the header. The unused AiProviderSelector component is deleted. A stored aiProvider field in old browser data does no harm and is ignored.

Risk: Codex must set DOCUMENTATION_ASK_AI_PROVIDER=AgentBuilder before this image reaches it. Otherwise Codex falls back to LlmGateway, which it has no config for. The companion change is https://github.com/elastic/codex-environments/pull/64, and it is safe to merge first.

Verify

dotnet test --project tests/Elastic.Documentation.Api.Tests
# AskAiProviderTests: unset → LlmGateway, AgentBuilder → AgentBuilder, unknown or numeric value → throws
mise run site:test

🤖 Generated with Claude Code

The API reads `DOCUMENTATION_ASK_AI_PROVIDER` once and ignores the `X-AI-Provider` header. An unset value means `LlmGateway`, so docs sites need no config change. Codex keeps `AgentBuilder` by setting the variable in its task definition. The frontend no longer tracks or sends a provider. Old clients that still send the header get `LlmGateway` like everyone else.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@reakaleek
reakaleek requested a review from a team as a code owner November 10, 2026 17:45
@reakaleek
reakaleek requested a review from Mpdreamz November 10, 2026 17:45
…er review by @infra-vault-gh-plugin-prod)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@reakaleek
reakaleek enabled auto-merge (squash) November 10, 2026 17:51
@github-actions

Copy link
Copy Markdown
Contributor

@reakaleek
reakaleek merged commit 5992178 into main Nov 10, 2026
58 of 59 checks passed
@reakaleek
reakaleek deleted the remove-x-ai-provider-head-619aa254 branch November 10, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants