0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

背景

この記事見て、まさにそれ! となったので、実際に手元の環境へ適用した記録。

結論だけ先に書くと、 User 設定で以下のように書いて対応した

User settings.json
  "terminal.integrated.defaultProfile.windows": "PowerShell 7",
  "chat.tools.terminal.terminalProfile.windows": {
      "path": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
      "icon": "terminal-powershell"
    },
  "terminal.integrated.profiles.windows": {
    "PowerShell 7": {
      "path": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
      "icon": "terminal-powershell"
    },
    ...

元記事だと、 chat.tools でも、profile 指定が出来そうだったが、自分の環境 VSCode 1.125.1 ではまだ未対応?だったので、 Path指定してます

概要

Token 節約方法他にないかなぁとか探してる中で実用的なものが見つかったので入れてみることにした。

  • Windows では PowerShell 7
  • WSL では bash
  • project ごとに毎回設定しない(User settings で寄せる)

VS Code 1.125.1

概要

今回やったことはシンプル

  • User settings に PowerShell 7 の profile を定義
  • 人間が開く既定ターミナルを PowerShell 7 に固定
  • Agent の run in terminal 用 profile も PowerShell 7 実行ファイルを明示
  • 最新仕様を調べて、chat.tools 側は「文字列」ではなく「object」へ

これで、Windows 側のシェル差分起因の無駄リトライを減らせると期待 :laughing:

詳細

1. まず PowerShell 7 の実行パスを確認

PowerShell 7 が標準パスにあるかを確認します。

Test-Path 'C:\Program Files\PowerShell\7\pwsh.exe'

True ならそのまま使えます。

2. User settings に反映した設定

今回の最小構成は次です。

{
  "terminal.integrated.defaultProfile.windows": "PowerShell 7",
  "chat.tools.terminal.terminalProfile.windows": {
    "path": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
    "icon": "terminal-powershell",
  },
  "terminal.integrated.profiles.windows": {
    "PowerShell 7": {
      "path": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
      "icon": "terminal-powershell",
    },
    "Command Prompt": {
      "path": [
        "${env:windir}\\Sysnative\\cmd.exe",
        "${env:windir}\\System32\\cmd.exe",
      ],
      "args": [],
      "icon": "terminal-cmd",
    },
    "Git Bash": {
      "source": "Git Bash",
    },
  },
}

元から設定あったりするので、気を付けましょう。
自分も、設定してはいたんですが、 profile が、powershell を探す用にしていたので、path 指定にした感じです。
powershell 5.1 になってることもあったのかなぁ・・と :thinking:

3. ハマりポイント: chat.tools 側の型

最初は次のように profile 名の文字列で設定したくなります。

"chat.tools.terminal.terminalProfile.windows": "PowerShell 7"

ただ、2026-06-21 時点の VS Code 本体ソースでは、
chat.tools.terminal.terminalProfile.windowsobject | null です。

なので、文字列で反応しないのは仕様として起こり得ます。

この設定は Agent の run in terminal ツール専用設定です。通常の integrated terminal の default profile 設定とは別物です。

4. 補足: PowerShell profile が 2 つ必要か?

今回の件で、powershell 7 用と、以前からあった探索用 Powershell を共存しておいてもいいのか?って話

結論は「不要」

  • terminal.integrated.profiles.windows.PowerShell 7 を path で定義
  • 既定を PowerShell 7 に向ける

ここまでで実運用は成立します。

"PowerShell": { "source": "PowerShell" } を残すのは、一覧表示や fallback の都合がある場合のみで OK

5. 期待する効果

  • シェル差分でコマンドが転ぶ回数が減る
  • リトライ回数が減って会話が短くなる
  • 結果としてトークン節約につながる

とはいえ、これまで && でこけてた記憶は、かなり昔で、最近もあったんだろうか?という疑問は若干ある。

ただ、可能性を考慮するとやっておいた方が良さそうって結論ですね

あとがき

「トークン節約したい」と思っていたところに、まさに刺さる記事でした。
実際に適用してみると、設定の肝は思ったより少ないので、まずは入れてみるってとこかな。

参考リンク

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?