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

Abierto Apto para principiantes
#1,486 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
csharp
Área
backend, cli

Línea de trabajo

Empieza por AgentLauncher, EnvironmentProber y ChatAgent.BuildSessionConfigAsync; después, comprueba cómo se configura SessionConfig.WorkingDirectory en el Copilot SDK. Sigue cómo llega AZCLIPS_CALLER_CWD a la sesión y confirma el valor de reserva cuando no está definida. El trabajo estará hecho cuando la recuperación interactiva resuelva las rutas relativas de shell y de archivos desde la carpeta del llamador; reproduce el problema con los pasos de params.json del issue.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
C#
Estrellas
18
Forks
10
Merge medio
1 d 20 h
PR fusionados (30 d)
157

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Azure/azclips

Todos los issues de Azure/azclips

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.