Skip to content

Getting "Unauthorized: token expired" during conversation #4992

Closed

Description

@grahamcropley

Description

During normal interaction while the agent is working / responding, it will occasionally abruptly stop with a red bordered message that just says "Unauthorized: unauthorised: token expired". I'm using Github Copilot as the provider, and seen it happen on Claude-Sonnet-4.5 for certain.

All I have to do is say "carry on" or similar, and it continues fine.

Image

Only observed this in the last couple of days, I believe it only started since around the version that introduced support for GPT-5.1-codex via Githob Copilot (i.e., the API endpoint change)... nnot that I'm using that model at the moment.... hope that helps?!

I appreciate this is intermittent, perhaps only 2-3 times today of pretty much constant use. Is there any useful settings or command line parameters that I could use, to help catch some details when/if it happens again?

OpenCode version

1.0.126

Steps to reproduce

Talk to the agent. I can't say if there is any specific trigger, it has happened while delegating to a sub-agent as well as a straight forward single agent interaction.

Screenshot and/or share link

Image

Operating System

Windows 11 > WSL 2 > Ubuntu 24.04

Terminal

Windows Terminal WSL

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Dec 2, 2025
  2. github-actions commented on Dec 2, 2025

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  3. removed
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Dec 2, 2025
  4. rekram1-node commented on Dec 2, 2025

    @rekram1-node
    Contributor

    Hm any chance you are using copilot on multiple platforms at the same time (ex: vscode + opencode same time)? I heard some people say that the copilot api sometimes invalidates other refresh tokens or something

  5. rekram1-node commented on Dec 2, 2025

    @rekram1-node
    Contributor

    @grahamcropley have you tried opencode auth login and then doing copilot again?

  6. rekram1-node commented on Dec 2, 2025

    @rekram1-node
    Contributor

    does it automatically recover? Or how did you resolve it

  7. self-assigned this
    on Dec 2, 2025
  8. moddi3 commented on Dec 3, 2025

    @moddi3

    i'm experiencing the same issue. it seems to have started around the 1.120–1.122 updates.

    i'm using opencode and sometimes copilot in vscode for small fixes. however, i can't say there's a direct connection between using copilot in vscode and the opencode copilot session expiring. if there is a relation, it's not immediate — the opencode session does not expire right after i use copilot in vscode.

  9. rekram1-node commented on Dec 3, 2025

    @rekram1-node
    Contributor

    I don't know if it is related to any recent updates, I talked to several people in discord who seemed to say this has always been a thing, annoyingly no one opened issues recently lol

  10. moddi3 commented on Dec 3, 2025

    @moddi3

    i can assure you this only started recently. I’ve been using the copilot provider the entire time I’ve used opencode, and until now it was fine.

    at the moment, though, I have to log in again every 20–30 minutes. For example, just now I was waiting for copilot/opus 4.5 to respond, asked it one more question right after, and immediately got an “unauthorized” error.

  11. moddi3 commented on Dec 3, 2025

    @moddi3

    when I first started using opencode, I logged in once and didn’t have to touch auth again until these recent issues started ☹️
    and i also don't know if it related to some updates, maybe this is just a coincidence that i noticed it after 1.120

  12. rekram1-node commented on Dec 3, 2025

    @rekram1-node
    Contributor

    Hm this is very strange, I use copilot exclusively in opencode and haven't had to login since the first time I did

  13. rekram1-node commented on Dec 3, 2025

    @rekram1-node
    Contributor

    Are you sure you have to reauth everytime? You can't send followups? Other people said it would handle it after sending a followup automatically

  14. moddi3 commented on Dec 3, 2025

    @moddi3

    i think i didn't try to send follow ups when this issue occurs, i just log in again
    strange that i didnt tried that, will try and write to you, thank yo

  15. moddi3 commented on Dec 3, 2025

    @moddi3

    i cant send follow ups when this issue happens

    Image
  16. moddi3 commented on Dec 5, 2025

    @moddi3

    It no longer logs me out, since yesterday evening, maybe it is github's issue?
    i did not update opencode all this time

  17. grahamcropley commented on Dec 5, 2025

    @grahamcropley
    Author

    @rekram1-node thank you for the followups.

    1. Not actively using github copilot in multiple places, but Visual Studio was open, I wasn't interacting with Github Copilot there.
    2. yes, I tried that, it did happen again afterwards (not straight away)
    3. it doesn't 'automatically' recover, but all I have to do is just send a message, I say something like 'carry on', and it does.

    I can confirm as @moddi3 mentioned, this didn't occur to me until recently, and I've been working on this specific project for 2+ months, hours and hours a day inside opencode.

    @moddi3 whereas I can send follow ups, and it immediately continues where it left off.

    I've actually had a couple of days without touching it, but I'll keep an eye out for any more occurrences on the latest versions.

  18. grahamcropley commented on Dec 5, 2025

    @grahamcropley
    Author

    Happened again, v1.0.133 - only using Github Copilot Claude Opus 4.5 - no delegation happening, just a single agent. Not using any other instances of Github Copilot anywhere.

    Image

    And simply prompting it again, continues without missing a beat. (other that that 'token expired' one)

    Image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions