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

Copilot CLI enters on recoverable state after : Execution failed CAPI Error

Open AlaRaies opened this issue 7 months ago • 2 comments

Describe the bug

Subscription : GitHub Copilot Business subscription. While running an active CLI session, I accidentally submitted a prompt that included an image. The CLI correctly returned an error indicating that image-based prompts are not supported. However, after this exception occurred, the CLI entered an unrecoverable state. From that point onward, any subsequent input—whether a text-only prompt or the execution of any CLI command—results in the same exception being thrown, even though no image is included in the prompt. Restarting the prompt flow within the same session does not resolve the issue. I also believe this same behavior occurs when using models that do not have vision capabilities at all, not only when vision is disabled by organizational policy. Exception observed : Execution failed: CAPI Error ...

Attachments: An image and a video demonstrating the steps to reproduce the issue are attached.

UnrecoverableState.zip

Affected version

GitHub Copilot CLI 1.0.32.

Steps to reproduce the behavior

  • The issue occurs consistently.
  • I reproduced the problem in a separate, fresh session with the same results.

Expected behavior

After encountering an error related to an unsupported image prompt, the CLI should recover gracefully and continue to operate normally for supported, text-only prompts and commands.

Additional context

No response

AlaRaies avatar Apr 20 '26 08:04 AlaRaies

I hit this same issue (vision disabled by org policy) and dug into the session storage — root cause and a manual workaround below, in case it helps triage.

Root cause: the image isn't stored inline in the session. The user message event in ~/.copilot/session-state/<session-id>/events.jsonl carries an attachments array referencing a file in the OS temp directory:

"attachments":[{"type":"file","path":"C:\\Users\\...\\AppData\\Local\\Temp\\copilot-image-xxxxxx.png","displayName":"copilot-image-xxxxxx.png"}]

On every turn — including after a full CLI restart and --resume — the CLI re-reads this temp file and re-attaches the image to the request, so the vision/CAPI 400 fires regardless of what the user types. This is why the session never recovers. A text marker ([📷 copilot-image-xxxxxx.png]) is also persisted in the turns table of ~/.copilot/session-store.db.

Manual workaround (CLI closed, files backed up first):

  1. Delete the event line containing the attachments array from events.jsonl (grep for copilot-image- or "attachments")
  2. Remove the matching row from the sqlite store:
   DELETE FROM turns WHERE user_message LIKE '%copilot-image-xxxxxx%';
   PRAGMA wal_checkpoint(TRUNCATE);
  1. Resume — the session works normally afterwards

Suggested fixes:

  • Reject/strip image attachments at input time when the org policy or model doesn't support vision, before they're persisted to session history
  • Or: on a vision-related 400, drop image attachments from the replayed history and retry, with a notice to the user
  • Side note: storing attachments as temp-file paths means session integrity silently depends on temp files surviving OS cleanup — probably worth embedding or copying them into the session folder instead

Environment:

  • Copilot CLI version:
  • OS: Windows 11
  • Model: Claude Opus 4.6
  • Org policy: vision not enabled
  • Request ID from the error: A257:179944:6277BDC:68A0430:6A2987F7

Sniipe avatar Jun 10 '26 16:06 Sniipe

This appears to be resolved as of GitHub Copilot CLI v1.0.85. Please update to that release or a newer stable version. We're closing this as completed. If it still happens, please comment with your version and reproduction steps.

copilot-cli-bot[bot] avatar Sep 16 '26 10:09 copilot-cli-bot[bot]