copilot-cli icon indicating copy to clipboard operation
copilot-cli copied to clipboard

invalid session id

Open scarf005 opened this issue 10 months ago • 23 comments

Describe the bug

using opus 4.5, fails to run any bash tasks. on macOS Sequoia 15.6.1 arm64, fish version 4.0.8 related: #640

note: i have switched to https://opencode.ai because of it

Affected version

GitHub Copilot CLI 0.0.396.

Steps to reproduce the behavior

  1. ask it to do any task
  2. it fails to run any bash tools

Expected behavior

it works?

Additional context


● Check git status
  $ cd /run/media/home/scarf/repo/cata/Cataclysm-BN-worktrees/feat-lua-options-migration && git status --porcelain
   └ 1 line...

Read shell output:
Waiting up to 5 seconds for command output
  Invalid session ID: 0. Please supply a valid session ID to read output from.

  <no active sessions>

● Simple echo test
  $ echo "hello"
   └ 1 line...

Read shell output:
Waiting up to 5 seconds for command output
  Invalid session ID: 1. Please supply a valid session ID to read output from.

  <no active sessions>

● Check pwd
  $ pwd
   └ 1 line...

Read shell output:
Waiting up to 10 seconds for command output
  Invalid session ID: 2. Please supply a valid session ID to read output from.

  <no active sessions>

● List tmp directory
  $ ls /tmp
   └ 1 line...

Read shell output:
Waiting up to 30 seconds for command output
  Invalid session ID: test_session. Please supply a valid session ID to read output from.

  <no active sessions>

● The bash tool continues to fail with invalid session IDs. Let me try the task agent:

● Task: Build and check git status
 ● Check directory contents
   $ ls -la /run/media/home/scarf/repo/cata/Cataclysm-BN-worktrees/feat-lua-options-migration/ | head -20
    └ 1 line...
 ● Check current directory
   $ pwd && ls -la
    └ 1 line...

○ Task: Test basic commands
 ● Run three simple commands
   $ echo "test" && pwd && ls /
    └ 1 line...

 Resume this session with copilot                           --resume=ddbbd824-7d98-4de5-8925-e03e7fdae733

scarf005 avatar Jan 28 '26 07:01 scarf005

Facing the same issue on Windows 11, with opus 4.5 copilot CLI version 0.0.396 (also tried prerelease variant, same issue

mitsha-microsoft avatar Jan 28 '26 15:01 mitsha-microsoft

I'm experiencing this issue on all models.

MichaelAtVirtueScript avatar Jan 28 '26 16:01 MichaelAtVirtueScript

Same issue on macOS M4, with Copilot CLI v0.0.397 and Claude Sonnet 4.5.

HuaYuan-Tseng avatar Jan 28 '26 17:01 HuaYuan-Tseng

Bash is working on 0.0.395.

saw235 avatar Jan 28 '26 18:01 saw235

My issue is with PowerShell. Every time it runs a command in PowerShell, I get this error. I believe the problem may have started with v0.0.395.

MichaelAtVirtueScript avatar Jan 28 '26 18:01 MichaelAtVirtueScript

I'm running into the same issue. Started happening with 0.0.397. Copilot CLI with model Sonnet 4.5 on headless Ubuntu box.

maxatchief1 avatar Jan 28 '26 19:01 maxatchief1

This is now fixed with v0.0.398.

MichaelAtVirtueScript avatar Jan 29 '26 14:01 MichaelAtVirtueScript

I still see this with v0.0.398

bnomis avatar Jan 29 '26 16:01 bnomis

I see this with v0.0.399


✗ Read shell output: Waiting up to 180 seconds for command output
  Invalid shell ID: 11. Please supply a valid shell ID to read output from.



❯ copilot --version
GitHub Copilot CLI 0.0.399.
Run 'copilot update' to check for updates.

eval-exec avatar Jan 30 '26 06:01 eval-exec

I see this with 0.0.405

NoahOsmonth avatar Feb 06 '26 04:02 NoahOsmonth

Same issue with 0.0.407-1 using Windows 11. Fresh install of powershell and copilot cli. Also tried with cmd and git bash but similar error with both.

✗ Read shell output: Reading command output "shellId": Expected string, received number

✗ Read shell output: Waiting up to 10 seconds for command output Invalid shell ID: 1. Please supply a valid shell ID to read output fr

eksek avatar Feb 11 '26 13:02 eksek

I see this with 0.0.408, tried with different shells (zsh and bash), but still failing

vinimmelo avatar Feb 12 '26 16:02 vinimmelo

Also seeing this with the latest version v0.0.411-0 and all of the other versions mentioned above.

I even stripped out all of my bash profile/rc files to try and reduce it to the simpliest thing possible.

ChatGPT suggested it's something potentially about ghostty and Wayland, but I also experienced it on gnome-terminal and tmux.

Not seeing much of interest when I try to strace the invocation for bad calls or environment variables. It'd be nice if we could get that sort of debug info out of the copilot itself.

bpkroth avatar Feb 16 '26 23:02 bpkroth

Figured it out. My INPUTRC had the following line in it. Commented it out and it seems to fix things:

# BREAKS Warp!, also copilot
"\C-j": redraw-current-line

(previous test with a fresh user had retained the INPUTRC env var for a silly reason)

bpkroth avatar Feb 19 '26 18:02 bpkroth

I have the same issue, but mapping Ctrl-J to something else. It seems like doing so is the particular reason Copilot breaks.

I have a repro here: https://github.com/ericsuh/copilot-cli-bug-example

ericsuh avatar Feb 20 '26 23:02 ericsuh

I am experiencing this same issue with v0.0.414 and NixOS/Flakes.

Summary:

  • In my setup, the bash that ended up first in PATH was the Nix stdenv bash (a nix-store binary like /nix/store/*-bash-5.3p3/bin/bash) which is built without readline. That bash has no libreadline and therefore no "\C-j": accept-line binding; Copilot CLI spawns interactive bash sessions and relies on newline being interpreted as "accept-line", so commands never complete and you get the "invalid shell/session id" symptoms.
  • I originally tried adding an INPUTRC with a "\C-j": accept-line binding, but a bash without readline ignores bind/inputrc so that approach is not reliable.

How I verified it on my machine: (inside the dir with direnv/nix develop active)

which bash
echo $BASH_VERSION
ldd $(which bash) | grep -i readline    # if this prints nothing, bash has no readline
bash -ic 'bind -p | grep "C-j"' || true # if this prints nothing, C-j is not bound

What I changed (working fix):

  • Add bashInteractive to the devshell buildInputs so a readline-enabled bash appears first in PATH:

    devShells.default = pkgs.mkShell {
      buildInputs = with pkgs; [
        bashInteractive
        rustToolchain
        pkg-config
        # ... rest of inputs
      ];
    
      shellHook = ''
        export RUST_BACKTRACE=1
        # ...
      '';
      # ...
    };
    

Result:

  • After adding bashInteractive, which bash points to a bash-interactive store path (e.g. /nix/store/-bash-interactive-/bin/bash), ldd shows libreadline and bash -ic 'bind -p | grep "C-j"' prints:

    "\C-j": accept-line
    

    Copilot CLI sessions in the devshell then work normally.

Notes:

  • This affects any devshell/devbox setup that puts a non-readline stdenv bash first in PATH; adding bashInteractive to buildInputs (or otherwise ensuring a readline-enabled bash is first) is a simple and robust fix. It may be worth adding a diagnostics/warning in Copilot CLI when the spawned shell binary lacks libreadline, or documenting this pitfall for Nix/devbox devshells.

au-phiware avatar Feb 21 '26 12:02 au-phiware

Same issue with 0.0.407-1 using Windows 11. Fresh install of powershell and copilot cli. Also tried with cmd and git bash but similar error with both.

✗ Read shell output: Reading command output "shellId": Expected string, received number

✗ Read shell output: Waiting up to 10 seconds for command output Invalid shell ID: 1. Please supply a valid shell ID to read output fr

Hi, I can confirm my issue was solved between 0.0.407-1 and 0.0.417 as it started working today when I updated. Also had another user confirming this in our environment.

eksek avatar Feb 25 '26 07:02 eksek

Same issue here on Windows 11 and Copilot CLI v0.0.421-1 fresh installation
✗ Read shell output: Waiting up to 30 seconds for command output Invalid shell ID: 0. Please supply a valid shell ID to read output from.

<no active shell sessions>

DavideDelVecchio avatar Mar 03 '26 16:03 DavideDelVecchio

still happening for me with 0.0.421. on macOS. At a glance, the issue happens because copilot is attempting to use the system bash shell, probabòy through bin/sh, but my bashrc is setup for my own bash shell from macports.

It would be nice if copilot just inherited the shell from the current session, also because on macOS the default shell is now zsh, so you get a spammy

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.

every time a command is executed

riffraff avatar Mar 05 '26 09:03 riffraff

Hi, I see that this was reopened and then closed again three days ago.

Unfortunately, I am still experiencing this issue on GNU/Linux when using devbox (Nix-based).

Warning

I always get warnings like this one:

✗ Read shell output: Waiting up to 5 seconds for command output
  Invalid shell ID: 6. Please supply a valid shell ID to read output from.

  <no active shell sessions>

Environment

My environment:

$ copilot --version
GitHub Copilot CLI 1.0.3.
Run 'copilot update' to check for updates.

$ copilot update
Checking for updates...
No update needed, current version is 1.0.3, fetched latest release is v1.0.3

$ which bash
/nix/store/2hjsch59amjs3nbgh7ahcfzm2bfwl8zi-bash-5.3p9/bin/bash

Edit: There are also #731 and #1838, but I still think that #1161 should be reopened. 😸

redtux avatar Mar 10 '26 00:03 redtux