[Agent] Interactive recovery runs shell commands in the install folder, not the user's folder

Aperta Adatta ai principianti
#1,486 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
csharp
Ambito
backend, cli

Direzione di ricerca

Inizia da AgentLauncher, EnvironmentProber e ChatAgent.BuildSessionConfigAsync, poi verifica come viene configurato SessionConfig.WorkingDirectory nel Copilot SDK. Traccia il percorso di AZCLIPS_CALLER_CWD fino alla sessione e conferma il valore di ripiego quando non è impostata. Il lavoro è completato quando il ripristino interattivo risolve i percorsi relativi della shell e dei file a partire dalla cartella del chiamante; riproduci il problema seguendo i passaggi params.json dell’issue.

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

Descrizione

act-experience-enablement-squad bug
Affected surface

Agent (interactive recovery: powershell / bash / view tool calls)

Describe the bug

This behavior already exists on main.

The Copilot session runs in the agent install folder instead of the folder where the user ran az. Shell commands and file reads that the agent runs with a relative path therefore resolve against the install folder.

  1. AgentLauncher starts the agent process with WorkingDirectory set to the agent install folder. .NET needs this to resolve relative probing paths. The user's folder is forwarded in AZCLIPS_CALLER_CWD.
  2. EnvironmentProber reads AZCLIPS_CALLER_CWD and reports it as cwd in the injected <environment> block, so the model is told the right folder.
  3. ChatAgent.BuildSessionConfigAsync doesn't set SessionConfig.WorkingDirectory, so the Copilot session, and every shell tool it runs, uses the agent process folder.

Repro (interactive mode, packaged build):

  1. In C:\work, create params.json and run az config get --key @params.json.
  2. Run az troubleshoot recover --style interactive and approve the plan.
  3. The <environment> block shows cwd: C:\work. The session's cwd is ...\Programs\azcli\. The agent runs Get-ChildItem -Path .\params.json, which fails with exit code 1 although the file exists in C:\work.

One-shot recovery isn't affected: the plan's relative paths are run by the user from their own folder. Reading files that the failed command names isn't affected either, because FailedCommandFiles resolves them against AZCLIPS_CALLER_CWD.

Expected behavior

The Copilot session runs in the user's folder, so relative paths in agent commands resolve the same way as in the user's failed command.

Additional context

Possible fix: set SessionConfig.WorkingDirectory (a GitHub Copilot SDK option) to the AZCLIPS_CALLER_CWD value, and fall back to the current behavior when it is unset.

Found while testing #1457, which doesn't change this path. Priority: P2.

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.