{Agent} Semantic search API over CLI and PowerShell reference docs for the AI recovery agent

Aperta
#1,494 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
csharp

Direzione di ricerca

Start by reading the agent help implementation in Agent/Tools/Help/HelpTools.cs and the related issue #1483. The proposed API needs a Docs team decision on ingesting azclips reference docs and whether it can serve sovereign clouds; the issue also describes chunking, versioning, and search requirements for both CLI and PowerShell. Done means Docs agrees on an approach and the API returns relevant, versioned reference chunks for the requested surface.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

act-experience-enablement-squad act-quality-productivity-squad

Target surface: Both

What problem are you trying to solve?

The AI error-recovery agent needs command reference (names, parameters, examples) to fix a failed command. Today it gets that reference in a way that will not scale and that only works with the CLI.

1. The full command list will not fit in the model's context.
When the agent does not know which command to use, it calls list_commands, which returns the whole command index (Agent/Tools/Help/HelpTools.cs). Measured with the current format:

Catalog Commands Tokens for a full listing
azclips today 126 commands, 20 groups ~4.7k
Classic Azure CLI 2.93.0 6,600 commands, 1,546 groups ~257k (extrapolated)
+ classic Az PowerShell 14.3.0 +6,064 cmdlets ~465k (extrapolated)

As azclips grows toward classic coverage, the listing alone exceeds the context window. The agent needs only the commands related to the problem.

2. Long commands bring too many parameters.
az vm create / New-AzVM has 29 parameters today (5 required). For a given failure the agent needs the required ones plus the few optional ones related to the problem, not all of them.

3. Reference data is tied to the CLI.
The catalog is generated by the CLI (az agent tool docs generate, rerun when extensions are installed, upgraded or removed), and the agent references help types in Core.Cli at compile time. PowerShell users who do not have the CLI cannot get it, and PowerShell-only cmdlets and parameters are missing (for example Undo-AzKeyVaultSecretRemoval, Set-AzKeyVaultSecret -SecretValue).

What we tried before (Azure Copilot project)

A. Microsoft Learn knowledge search (Azure CLI handler). Learn chunked the published Azure CLI reference docs (one page per command group, one section per command, for example az acat onboard) into chunks of about 500 tokens and served hybrid search over them. Request, from src/common/services/learn_service_wrapper.py in azure-client-tools-copilot:

POST https://learn.microsoft.com/api/v1/knowledge-search?api-version=2023-11-01-preview&top=5
Authorization: Bearer <Microsoft Entra token for https://learn.microsoft.com/.default>
Content-Type: application/json

{
  "input": "Create a virtual machine with Trusted Launch enabled",
  "filter": "depotName eq 'Azure.azure-cli-docs' and (pageType eq 'reference' and tags/any(t: t eq 'azure-cli'))",
  "searchType": "hybrid"
}

Response items have chunk, score (@search.rerankerScore in hybrid mode), title and url. Result: command accuracy rose from 91.1% to 95.7%.

B. Own Azure AI Search service (Azure PowerShell handler). A weekly job parsed the Az PowerShell help files into one document per cmdlet (Cosmos DB) and indexed GPT-enhanced descriptions with embeddings in Azure AI Search. Queries were rewritten into 3 variants and run as hybrid search with the semantic ranker (src/azps/src/services/azure_ai_search_wrapper.py, top=7). Cmdlets were not split, so New-AzVM came back whole. It worked, but our team had to run the pipeline, index, embeddings and service.

Proposed solution

One standalone semantic search API over azclips reference docs, for CLI and PowerShell, run by the Docs (Learn) team.

  • Standalone: callable without the CLI or PowerShell installed and without starting az or pwsh. The agent depends only on this API.
  • One endpoint: the input is the problem in natural language, then |, then the command the agent guesses. The agent may not know the right command, but a guess on both levels (what it wants to do, and which command it thinks does it) improves accuracy. The API returns the closest reference chunks for the requested surface only.

CLI example:

{ "input": "create a VM without a public IP address | az vm create", "surface": "cli", "top": 5 }

Expected: the az vm create chunk with its 5 required parameters (--name, --resource-group, --location, --size, --admin-username), plus the chunk with --public-ip-address and its note specify "" for none, plus the matching example. The other 20+ optional parameters are not returned, and no other command group is listed in full.

PowerShell example:

{ "input": "restore a key vault secret that was deleted by mistake | Restore-AzKeyVaultSecret", "surface": "powershell", "top": 5 }

Expected: Undo-AzKeyVaultSecretRemoval first (azclips has no Restore-AzKeyVaultSecret; the natural-language part still finds the right cmdlet), with its required parameters (-VaultName, -Name) and an example.

Requirements for the chunking and the response:

  1. Required parameters are never dropped. When a chunk belongs to a command, the command's required parameters are complete in that chunk.
  2. Chunking rule for long commands. One chunk for the command (name, summary, required parameters). Optional parameters grouped into further chunks, each carrying the command name, so a hit can be tied back to its command.
  3. Both surfaces in one index, filtered by surface. CLI commands and PowerShell cmdlets, including PowerShell-only cmdlets and parameters; a request returns only the requested surface.
  4. Version on every chunk. The extension or module version, so the agent can tell when the user's installed version differs.

Why Docs, not us

Approach B shows we can build this ourselves, but we do not want to own a search service long term (index pipeline, embeddings, model updates, deployments). Docs already chunks and serves reference docs for Azure CLI (approach A), so one owner for chunking and search is cheaper for everyone. We will provide the chunking rule above, the reference source (per-command reference pages in the same shape as the Azure CLI reference linked above, for both CLI and PowerShell), and evaluation queries from real recovery failures.

Additional context

  • Industry direction: coding agents (Claude Code, Codex CLI, Continue) dropped embedding indexes over code in favor of search tools, but hosted semantic search is still the common pattern for large documentation sets (Microsoft Learn MCP, Context7) and for finding the right command in large CLIs (AWS API MCP server, Azure MCP's azcli/copilot).
  • Open question for Docs: azclips reference is not published on Learn yet. What does Docs need from us to ingest it (source repo, format, cadence)? Is the API reachable from sovereign clouds?
  • Queries can contain parts of a failed command and its error. The agent will strip values and secrets before sending.
  • Related: #1483.
Lingua principale
C#
Stelle
18
Fork
10
Merge medio
1g 20h
PR unite (30g)
157

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Azure/azclips

Tutte le issue di Azure/azclips

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.