# agent: Show errors when provider is not authenticated but model is configured \(\#60417\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/69664ab9d33590a524df1164a74767c4285f6086)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 69664ab9d33590a524df1164a74767c4285f6086

Requested commit: 69664ab9d33590a524df1164a74767c4285f6086

Commit: 69664ab9d33590a524df1164a74767c4285f6086

Tree: f6cb01b0cc851b4994862d9a66b5a3ef4d8d9e88

Author: Bennet Bo Fenner

Committer: GitHub

## Message

```
agent: Show errors when provider is not authenticated but model is configured (#60417)

This PR improves the onboarding experience when using the agent panel.
Previously we would pick a fallback model in case the provider failed to
authenticate/was slow to resolve models. However, this code had a race
condition (for providers that resolve models dynamically like
Anthropic/GitHub Copilot), since we pick a fallback immediately after
all providers have been authenticated. However, at that point the
configured provider might not have resolved its models, so we would fall
back to a different provider. At some point we added a workaround for
the zed.dev provider.
We landed on a much simpler approach that eliminates the race condition:
We only pick a fallback model in case the user actually has no model
configured in his settings. In case the user has a model configured, we
won't fallback and show an actionable error message:

1. Model is not set and no fallback available

<img width="862" height="78" alt="image"
src="https://github.com/user-attachments/assets/e8e7472a-1c05-4cd2-8efc-49e6d921b0a4"
/>

2. Model is set, but provider is not authenticated

<img width="865" height="65" alt="image"
src="https://github.com/user-attachments/assets/3c8cbf1d-7dd5-4b2e-809a-61e6662721a3"
/>

3. Model is set, provider is authenticated, but model is not in model
list

<img width="863" height="63" alt="image"
src="https://github.com/user-attachments/assets/b97defa2-3fb4-4ec0-b3c6-26878d1c815c"
/>

4. Model is set, but provider is not recognised

<img width="865" height="67" alt="image"
src="https://github.com/user-attachments/assets/ecff1e3f-4f6b-47eb-a25d-125a104baafc"
/>



This plays well with the reason why we have the fallback model in the
first place: We only want to pick a fallback for users that open Zed for
a first time and e.g. have an Anthropic API key present in their
environment. As soon as the user manually changes his provider/model we
won't apply the fallback anymore.



Release Notes:

- agent: Improved error messaging when provider is not configured
- agent: Improve fallback model selection

---------

Co-authored-by: cameron <cameron.studdstreet@gmail.com>
```

## Parents

- [01568e5569b4952b721af8b545173d44c029baaa](https://git.cafe/gitcafe/zed/commit/01568e5569b4952b721af8b545173d44c029baaa?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/69664ab9d33590a524df1164a74767c4285f6086?format=markdown)
