Skip to content

ai-assistant: docs: Add provider auto-detection guide#880

Open
illume wants to merge 1 commit into
headlamp-k8s:mainfrom
illume:docs/ai-assistant-provider-auto-detection
Open

ai-assistant: docs: Add provider auto-detection guide#880
illume wants to merge 1 commit into
headlamp-k8s:mainfrom
illume:docs/ai-assistant-provider-auto-detection

Conversation

@illume

@illume illume commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Adds docs/provider-auto-detection.md explaining how the AI assistant automatically detects available providers (Ollama, OpenAI-compatible endpoints) from the environment and presents detected options to the user.

Assisted by Copilot.

Part of the ai-assistant documentation series.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new documentation page intended to explain “provider auto-detection” for the AI Assistant, including the proposed provider list, architecture/flow, security properties, and test instructions.

Changes:

  • Introduces provider-auto-detection.md describing automatic discovery of providers (Copilot/Azure/Ollama).
  • Documents a proposed detection flow and security constraints (CLI allowlist, timeouts, sentinel auth).
  • Adds a tests section with example commands.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -0,0 +1,50 @@
# Provider Auto-Detection

Automatically detects available AI providers on the user's machine — no manual API key entry required.
Comment on lines +5 to +6
## Supported providers

Comment on lines +7 to +11
| Provider | Detection method | Auth |
|----------|-----------------|------|
| **GitHub Copilot** | `gh auth token` → validate → model catalog | Sentinel `__GH_CLI_AUTH__` (token refreshed at runtime) |
| **Azure OpenAI** | `az` CLI → account enumeration → deployment filtering | Sentinel `__AZ_CLI_AUTH__` (key refreshed at runtime) |
| **Ollama** | HTTP probe to `localhost:11434` | None |
Comment on lines +15 to +19
Detection logic is in `ai-common/src/providers/providerAutoDetect.ts` (platform-agnostic). It receives a `CommandRunner` from the host app for CLI execution.

UI is in `ai-ui/src/components/settings/`:
- `AutoDetectProvider.tsx` — Dialog + `useAutoDetect()` hook
- `ModelSelector` — Integrates the "Auto Detect" button
Comment on lines +24 to +28
User clicks "Auto Detect"
→ useAutoDetect() → detectProviders(existingConfigs, dismissedKeys, commandRunner)
├── detectCopilotProvider() → gh auth token → validate → model catalog
├── collectAzureOpenAIProviders() → az account → list accounts → deployments
└── detectOllamaProvider() → HTTP GET localhost:11434/api/tags
├── detectCopilotProvider() → gh auth token → validate → model catalog
├── collectAzureOpenAIProviders() → az account → list accounts → deployments
└── detectOllamaProvider() → HTTP GET localhost:11434/api/tags
→ DetectedProvidersDialog → User adds or dismisses
Comment on lines +34 to +36
- **Command allowlist**: Only `gh` and `az` are permitted.
- **15 s timeout** on all CLI commands.
- **Sentinel values**: Real tokens are never stored in config. Sentinel strings are stored; actual tokens are fetched from CLI only at model-creation time via `refreshGitHubToken()` / `refreshAzureOpenAIKey()`.
Comment on lines +38 to +40
## Dismissal & deduplication

Dismissed providers are tracked by key (`copilot`, `local`, `azure:<accountName>`) and excluded on subsequent detection runs. Providers already in the user's config are also excluded.
Comment on lines +44 to +46
- `ai-common/src/providers/providerAutoDetect.test.ts` — core detection logic
- `ai-ui/src/components/settings/AutoDetectProvider.test.ts` — UI orchestration

Comment on lines +47 to +50
```bash
packages/ai-common
npx vitest run src/providers/providerAutoDetect.test.ts
```
@illume illume force-pushed the docs/ai-assistant-provider-auto-detection branch 2 times, most recently from 8b5796b to 68f44e3 Compare July 8, 2026 11:52
…on guide

Documents the automatic provider detection system.

Supported providers detected without manual API key entry:
- GitHub Copilot: via `gh auth token`, validated against model catalog.
- Azure OpenAI: via `az` CLI account enumeration and deployment filtering.
- Ollama: via HTTP probe to localhost:11434.

Detection logic lives in `ai-common/src/providers/providerAutoDetect.ts` and
accepts an injected `CommandRunner` so the same code works in both the browser
(Electron IPC) and the CLI (Node child_process) contexts. Sentinel strings
(`__GH_CLI_AUTH__`, `__AZ_CLI_AUTH__`) mark credentials that are refreshed at
runtime rather than stored.

Signed-off-by: René Dudfield <renedudfield@microsoft.com>
Co-authored-by: Ashu Ghildiyal <aghildiyal@microsoft.com>
Signed-off-by: Ashu Ghildiyal <aghildiyal@microsoft.com>
@illume illume force-pushed the docs/ai-assistant-provider-auto-detection branch from 68f44e3 to 35f3995 Compare July 8, 2026 11:59
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.

2 participants