Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

AI/agent terminal sessions pollute PSReadLine history

Aperta
#5,123 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
55/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
csharp, powershell
Ambito
cli

Direzione di ricerca

Start by locating PSReadLine initialization and the AddToHistoryHandler/history persistence path, including the text and SQLite modes mentioned in the issue. Confirm that PSREADLINE_HISTORY_SAVE=0 selects MemoryOnly before history writes, preserves current-session recall, and avoids persistent saves regardless of profile loading.

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

Descrizione

Needs-Triage :mag:

Summary

When AI agents (e.g., GitHub Copilot, VS Code terminal agents) execute commands in PowerShell terminals, those commands are saved to PSReadLine history indistinguishably from user-typed commands. This pollutes history recall with commands the user never typed, inflates frequency counts, and degrades the usefulness of history recall.

Problem

AI coding assistants routinely run commands like Get-ChildItem, dotnet build, git status, etc. in integrated terminals. These get recorded to PSReadLine history (both text file and SQLite modes) as if the user typed them. Over time this means:

  • History recall is noisy — Up arrow surfaces agent commands the user didn't type
  • Frequency-based ranking is skewed — location-aware recall ranks agent-repeated commands higher than user favorites
  • HistoryNoDuplicates doesn't help — the commands are real commands, just not user-initiated

Current Workaround

Users can add this to their $PROFILE:

# Requires the agent to set this env var before launching pwsh
if ($env:PSREADLINE_HISTORY_SAVE -eq '0') {
    Set-PSReadLineOption -AddToHistoryHandler { [Microsoft.PowerShell.AddToHistoryOption]::MemoryOnly }
}

But this is fragile because:

  1. The agent must set the env var — requires cooperation from VS Code / Copilot
  2. Agents that use pwsh -NoProfile bypass the check entirely
  3. Users must manually add the snippet

Proposal

Add a built-in environment variable check in PSReadLine's initialization, so that agent-spawned terminals can opt out of persistent history without requiring profile configuration:

// During PSReadLine init, before any history writes
if (Environment.GetEnvironmentVariable("PSREADLINE_HISTORY_SAVE") == "0")
{
    Options.AddToHistoryHandler = _ => AddToHistoryOption.MemoryOnly;
}

This way:

  • Any agent framework just sets PSREADLINE_HISTORY_SAVE=0 as a process environment variable before launching pwsh
  • Works regardless of -NoProfile
  • No user configuration needed
  • Commands still available in the current session's memory (Up arrow works), just not persisted to disk

Environment

  • VS Code with GitHub Copilot agent terminals
Lingua principale
C#
Stelle
4.4k
Fork
341
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Apri la guida per i contributori

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 PowerShell/PSReadLine

Tutte le issue di PowerShell/PSReadLine

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.